Skip to content

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

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

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

@lexlianlexlian commented Jun 6, 2026

Copy link
Copy Markdown

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
Closesanomalyco#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-actionsgithub-actionsBot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 6, 2026
@github-actionsgithub-actionsBot 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

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

@beenotung

Copy link
Copy Markdown

This PR will also fix issue #30662 (Auto session title generation fails for opencode provider models). The root cause is the same - smallOptions() missing opencode provider handling.

@Jackdrakes

Copy link
Copy Markdown

Hi maintainers! Could someone please review and approve the workflow for this PR? It's been waiting for about three weeks now, and we're looking forward to having this feature available. Thanks for your time and all your work on the project!

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@beenotung

Copy link
Copy Markdown

Requesting this PR be reopened. It was auto-closed by the cleanup bot (created >1 month ago, <2 positive reactions), but it fixes a real, still-active bug — it should not have been swept up.

The bug is still present in the latest release (v1.18.19): auto session title generation silently fails for opencode (Zen) provider models, because smallOptions() in src/provider/transform.ts still has no opencode branch (it only handles openai, openrouter/llmgateway, and venice). Issue #30662 is open and multiple users are affected.

This PR is the proper fix: it adds the missing opencode handling to smallOptions() (the same promptCacheKey/include/reasoningSummary that options() already sets), plus a useful warning when a configured small_model isn't found. Author verified: bun typecheck passes, provider tests 88/88, transform tests 250/250 (+2 new for opencode).

A config workaround exists ("small_model": "<working-model>"), but it shouldn't be required — users on the opencode provider hit silent title failure by default. Could a maintainer review and reopen this so it can be merged?

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

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

3 participants

@lexlian@beenotung@Jackdrakes