fix(chat): only leave agent mode when the model really has no tool support#5767
Open
MummIndia wants to merge 1 commit into
Open
fix(chat): only leave agent mode when the model really has no tool support#5767MummIndia wants to merge 1 commit into
MummIndia wants to merge 1 commit into
Conversation
…pport Both checks match a bare "tool" or "auto" anywhere in the error text, which catches a lot that has nothing to do with tool support: a tool timing out, an MCP server dropping, any message containing "automatic". At the first site the consequences are not cosmetic. The real error is replaced with "This model doesn't support agent tools", so the actual cause is lost. The UI leaves agent mode. And the choice is written to localStorage, so every later message in that conversation also runs without tools, with nothing on screen explaining why. It presents as "agent mode works in a new chat but not in this one", which sends you looking at the model, the session, or the endpoint rather than at a substring match in the error path. Diagnosing it took a while precisely because the message you are shown is the one thing that is not true. The second site is milder -- it appends a hint rather than switching -- but appending "this model may not support tools" to an unrelated failure still points the user at the wrong fix. Match the provider's actual wording instead. Ollama returns "<model> does not support tools"; the pattern also covers "doesn't support tools" and "tools are not supported". The original error text is kept in both cases so a genuine failure stays diagnosable. Checked against the strings that used to misfire -- "tool execution timed out", "MCP server not connected", "automatic retry failed", "tool_choice auto is invalid", "peer closed connection" -- none of which now demote, while the three real phrasings still do. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Summary
Both checks in
static/js/chat.jsmatch a baretoolorautoanywhere in the errortext, which catches a great deal that has nothing to do with tool support: a tool
timing out, an MCP server dropping, any message containing "automatic".
At the first site the consequences are not cosmetic. The real error is replaced with
"This model doesn't support agent tools", so the actual cause is lost. The UI leaves
agent mode. And the choice is written to
localStorage, so every later message inthat conversation also runs without tools, with nothing on screen explaining why. It
presents as "agent mode works in a new chat but not in this one", which sends you
looking at the model, the session or the endpoint rather than at a substring match in
the error path.
The second site is milder — it appends a hint rather than switching — but appending
"this model may not support tools" to an unrelated failure still points the user at
the wrong fix.
This matches the provider's actual wording instead. Ollama returns
<model> does not support tools; the pattern also covers "doesn't support tools" and "tools are notsupported". The original error text is kept in both branches so a genuine failure
stays diagnosable.
Target branch
dev, notmain.Linked Issue
Fixes #5766
Type of Change
Checklist
devdocker compose up) and verified the change works end-to-end.How to Test
In agent mode with a model that does support tools, trigger a failure whose message
contains
toolorauto— killing an MCP server mid-turn, or letting a tool timeout, both work.
Before the change — the message shown is "This model doesn't support agent
tools", the mode toggle flips to Chat, and
localStoragekeeps it there. Sending asecond message in the same conversation runs without tools.
After the change — the real error text is displayed and agent mode stays on.
Regression check on the strings that used to misfire — none of these demote any
more, while the three real phrasings still do:
Visual / UI changes — REQUIRED if you touched anything that renders
This touches
static/js/chat.js, so I want to be explicit rather than tick "none".What changes on screen: an error message string, and the state of the mode
toggle in the cases where it previously flipped by mistake. No styling, layout,
spacing, colour, font, icon, HTML structure or CSS is touched — the diff is a regular
expression and the two conditions that use it.
I have not attached a screenshot because producing one means provoking an artificial
backend failure, and the resulting image would show one arbitrary error string in a
message bubble — it would not illustrate the defect, which is which errors are
matched. The regression table above is a more faithful account of the change.
Happy to attach a before/after capture if you would rather have one — say the word and
I will provoke the failure and record it.