Skip to content

fix(provider): respect configured small_model and add opencode handling to smallOptions#31092

Open
lexlian wants to merge 1 commit into
anomalyco:devfrom
lexlian:fix/small-model-title-agent-fix
Open

fix(provider): respect configured small_model and add opencode handling to smallOptions#31092
lexlian wants to merge 1 commit into
anomalyco:devfrom
lexlian:fix/small-model-title-agent-fix

Conversation

@lexlian
Copy link
Copy Markdown

@lexlian lexlian commented Jun 6, 2026

Issue for this PR

Closes #31042

Type of change

  • Bug fix

What does this PR do?

Two bugs cause the symptoms in #31042:

Bug 1 — silent fallback in getSmallModel. When small_model is configured but the model isn't in the provider catalog, the function returns undefined and the title agent silently uses the main model. The fallback behavior is correct (per the documented design and the changelog: "Invalid small_model config no longer poisons fallback paths"), but the user has no way to know their config was ignored. The fix adds a WARN log inside the catchTag handler so users see why.

Bug 2 — smallOptions missing opencode handling. When the title agent calls the LLM with small: true for an opencode provider model, smallOptions returned {} because it only handled openai, openrouter/llmgateway, and venice. The opencode API call was missing the include and reasoningSummary options that options() already sets for opencode, so the request would fail/behave unexpectedly, and the LLM runtime would retry — that's the ~90s delay users reported. The fix adds the same opencode options to smallOptions, scoped to the small-model call path.

Related: #8609 (misleading docs), #14807 (silent failure), #30662 (smallOptions missing opencode).

How did you verify your code works?

cd packages/opencode
bun typecheck                                          # passes
bun test ./test/provider/provider.test.ts              # 88/88 pass
bun test ./test/provider/transform.test.ts             # 250/250 pass (was 248, +2 new for opencode)
bun test ./test/session/prompt.test.ts -t "loop calls LLM"  # passes

To verify the warning manually: set small_model: "opencode/some-invalid-model" in your config, start a session, and you should see a WARN line configured small_model not found, falling back to main model in the logs.

Screenshots / recordings

N/A — no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…ng to smallOptions

Closes anomalyco#31042

Two compounding bugs caused the symptoms in anomalyco#31042:

1. When cfg.small_model is configured but the model is not in the
   provider catalog, getSmallModel silently returned undefined and
   the caller fell back to the main model with no indication to the
   user. Added a warning log so users know their config was ignored.
   The fallback behavior itself matches the documented design
   (per anomalyco#14807 and the changelog: "Invalid small_model config no
   longer poisons fallback paths").

2. smallOptions() in transform.ts was missing opencode provider
   handling — only openai, openrouter/llmgateway, and venice were
   handled. For opencode models it returned an empty options object,
   causing the opencode API call to fail/behave unexpectedly and
   trigger LLM retries (the 90s delay users reported). Added the
   same include and reasoningSummary that options() already sets for
   opencode models, scoped to the small-model call path.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 6, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

small_model ignored for title agent + FreeUsageLimitError retry loop blocks session for ~90s

1 participant