opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(opencode): correct model fallback index tracking and config parsing

Open manascb1344 opened this issue 17 hours ago • 1 comments

Fixes #1267

Summary

  • Fix fallbackIndex never incrementing after successful model switch, causing infinite retry loop on same failing model
  • Add models to knownKeys in config transform to prevent it being moved to options
  • Add tests for edge cases: empty models array, options isolation, native agent fallbacks

What changed

processor.ts

  • Increment fallbackIndex before calling tryFallbackModel, not after
  • Simplified the helper to take targetIndex directly

config.ts

  • Added "models" to the known keys set so the config transform preserves it correctly

agent.test.ts

  • Added 3 new test cases covering edge cases

How I verified

  • Ran bun test test/agent/agent.test.ts — all 31 tests pass
  • Ran bun run typecheck — no errors
  • Ran bun run test — 666 pass, 1 skip
  • Reviewed the logic: each error now advances to the next fallback model instead of retrying the same one

manascb1344 avatar Jan 15 '26 12:01 manascb1344