Skip to content

fix(tune): stop sending native tools in XML/JSON tool mode - #2095

Merged
will-lamerton merged 3 commits into
mainfrom
fix/tune-tool-mode-native-tools
Nov 11, 2026
Merged

will-lamerton merged 3 commits into
mainfrom
fix/tune-tool-mode-native-tools

Conversation

@will-lamerton

Copy link
Copy Markdown
Member

What was wrong

/tune → Native Tool Calling → XML (or JSON) sets toolsDisabled in useChatHandler (and the equivalents in plain/shell.ts and AcpAgent.buildSystemPromptForSession), which appends the tool definitions to the system prompt as text. But the request itself goes through handleChat (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 tools list; result.toolsDisabled came back false, 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

  • ModeOverrides gains nativeToolsDisabled. handleChat treats it like a config disable: no native tools on the request, toolsDisabled: true on the result, and no second copy of the tool definitions (the caller's prompt already has them).
  • The three loops set it from the same source as their prompt: the TUI loop and --plain/run loop from getTuneToolMode(tune), ACP from a per-session nativeToolsDisabled set beside aggressiveCompact when 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, nativeToolsDisabled sends no tools, returns toolsDisabled: true, and does not append definitions again. Fails on main.
  • plain/conversation.spec.ts: tune toolMode: 'xml' reaches the client as nativeToolsDisabled: true.
  • acp-agent.spec.ts: switching a session to a provider whose tune picks XML sets session.nativeToolsDisabled.
  • Ran acp-agent, acp-conversation, plain/conversation, plain/shell, conversation-loop, chat-handler specs (all pass individually), tsc --noEmit, biome.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the area:tui Terminal UI label Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

nc-review could not produce a verdict this run (agent exit 1). This is a problem with the review agent, not with your pull request. A maintainer can retry with /re-review.

…tive-tools

# Conflicts:
#	source/plain/conversation.ts
@will-lamerton

Copy link
Copy Markdown
Member Author

Merged origin/main. After #2097 the plain loop builds its request in the plain adapter's prepareTurn, so nativeToolsDisabled is now set there (turn-engine itself is unchanged; it already forwards prepared.modeOverrides to client.chat). The new ACP spec now uses cwd: testConfigDir like its neighbours since #2100 made sessions read their own folder's config.

…tive-tools

# Conflicts:
#	source/acp/acp-conversation.ts
@will-lamerton

Copy link
Copy Markdown
Member Author

Merged origin/main again after #2102. ACP turns now run on turn-engine, so nativeToolsDisabled moved into the ACP adapter's prepareTurn mode overrides (same place as plain). Added an acp-conversation spec asserting the flag reaches client.chat; it fails without that line.

@will-lamerton
will-lamerton merged commit b75d0f6 into main Nov 11, 2026
18 checks passed
@will-lamerton
will-lamerton deleted the fix/tune-tool-mode-native-tools branch November 11, 2026 18:30
jay23606 added a commit to jay23606/nanocoder that referenced this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant