Repository navigation
fix(tune): stop sending native tools in XML/JSON tool mode - #2095
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
nc-review could not produce a verdict this run (agent exit |
…tive-tools # Conflicts: # source/plain/conversation.ts
|
Merged origin/main. After #2097 the plain loop builds its request in the plain adapter's |
…tive-tools # Conflicts: # source/acp/acp-conversation.ts
|
Merged origin/main again after #2102. ACP turns now run on turn-engine, so |
…ective#2095) Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
What was wrong
/tune→ Native Tool Calling → XML (or JSON) setstoolsDisabledinuseChatHandler(and the equivalents inplain/shell.tsandAcpAgent.buildSystemPromptForSession), which appends the tool definitions to the system prompt as text. But the request itself goes throughhandleChat(source/ai-sdk-client/chat/chat-handler.ts), which only disables native tools from provider config (disableTools/disableToolModels) or a model rejection. Tune's choice never reached it.So with tune on XML mode against a normal provider, every request carried both the XML tool instructions in the prompt and the full native
toolslist;result.toolsDisabledcame backfalse, so the loop also skipped the fallback notice and treated the turn as a native one. The mode the user picked never actually took effect.Fix
ModeOverridesgainsnativeToolsDisabled.handleChattreats it like a config disable: no native tools on the request,toolsDisabled: trueon the result, and no second copy of the tool definitions (the caller's prompt already has them).--plain/runloop fromgetTuneToolMode(tune), ACP from a per-sessionnativeToolsDisabledset besideaggressiveCompactwhen the session's prompt is built. One line in each loop, to stay out of the way of the ongoing loop refactors.Testing
chat-handler.spec.ts: new test,nativeToolsDisabledsends notools, returnstoolsDisabled: true, and does not append definitions again. Fails on main.plain/conversation.spec.ts: tunetoolMode: 'xml'reaches the client asnativeToolsDisabled: true.acp-agent.spec.ts: switching a session to a provider whose tune picks XML setssession.nativeToolsDisabled.acp-agent,acp-conversation,plain/conversation,plain/shell,conversation-loop,chat-handlerspecs (all pass individually),tsc --noEmit, biome.🤖 Generated with Claude Code