fix(opencode): stop sending tools when tool_call is false#35433
Open
tobwen wants to merge 1 commit into
Open
Conversation
9e930a9 to
02d535b
Compare
02d535b to
eb36a5e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #19966
Closes #35432
Type of change
What does this PR do?
tool_call: falsein model config was stored incapabilities.toolcallbut never checked in the prompt loop.SessionTools.resolve()ran unconditionally, tools were sent in every LLM request withtool_choice: "auto". Providers that do not support tool calling (e.g. local Ollama models, morphllm without special flags) returned 400.Three changes in
packages/opencode/src/session/prompt.ts:SessionTools.resolve()behindmodel.capabilities.toolcall- skip tools entirely whenfalse.toolChoice: "none"whentoolcallisfalse(the defaultundefinedbecomes"auto"at the provider).format.type === "json_schema"andtoolcallisfalse, fail fast with a clearStructuredOutputErrorinstead of pushing a misleading system prompt and making a doomed LLM call.How did you verify your code works?
prepareToolsAndToolChoicedrops both empty tools andtoolChoicebefore the HTTP body is serialized, so notoolsortool_choicekey reaches the provider when toolcalling is disabled.bun typecheckpasses.noLLMServer.instancethat verifies the loop does not crash withtool_call: false.Screenshots / recordings
Not a UI change.
Checklist