r/ClaudeCode • • 15m ago

Tips & Workflows I logged 3,548 MCP Code Mode runs in Claude Code over 9 days. Turn-one tokens barely moved (-2.2%), but mid-conversation tool outputs dropped 81%.

Anthropic added an experimental Code Mode to Claude Code (v2.1.323, behind CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1), where the model writes short JavaScript to chain tool calls instead of calling them one turn at a time. Since that flag only works in interactive terminal sessions and not in stream-json or wrapped desktop sessions, I built an MCP-level version (search + a sandboxed JavaScriptCore run_script with a 20-call cap and no filesystem/network access) and measured 9 days of actual Claude Code transcripts (Nov 24 to Dec 3, deduplicated by realpath and tool_use.id).

1. Turn-one prompt tokens barely changed

With 9 connected MCP services (280 connector tools + 58 core tools), turning Code Mode on shrank tools/list from 644.3 KB down to 65.3 KB (-89.9%). Yet matched sessions before and after showed median first-turn input tokens only moved from 62,864 to 61,482 (-2.2%, cache creation 34,825 to 32,579).

The reason is simple: Claude Code's native ToolSearch already withheld 336 of 338 schemas on turn one. Hiding them behind a Code Mode gateway mostly trimmed deferred name lines. (For comparison, Codex dropped 0% and called the MCP wrapper 0 times over the same 9 days because it already runs native code mode.)

2. The actual savings happened mid-conversation

Across 3,548 run_script calls in 145 Claude Code sessions:

  • 60.0% (2,130 of 3,548) chained two or more callTool() calls or ran a loop in a single turn (6,577 static inner calls total).
  • Error rate was 2.4% (84 of 3,547 results).
  • Mean tool result size fell 81.1% (5.3x smaller): 2,278 bytes (median 651 B, p90 6,462 B) vs. 12,028 bytes (median 178 B, p90 13,328 B) across 79,307 direct MCP calls in the same window.

The unexpected part was which tools Claude Code pulled into JS. Nearly half of all inner calls (3,129) were browser_* tools, followed by gmail_* (794) and slack_* (742), even though every browser tool stayed directly exposed on tools/list. Given both paths, the model used direct calls for quick clicks/waits and moved noisy DOM snapshots and multi-tab reads into JS to filter them before returning to context.

3. Three things that broke in practice

  • Per-inner-call approvals: The host CLI only sees run_script, not whether the script calls gmail_read_thread or gmail_send_message. Session-allowing one read script would bypass confirmation for later writes, so authorization had to move inside the MCP broker per inner callTool(), with external writes always prompting and Plan or read-only mode refusing state-changing calls.
  • Double-deferral overhead: Before marking both meta-tools anthropic/alwaysLoad: true and returning structured JSON with inline inputSchema when 10 or fewer tools match, Claude Code burned an extra ToolSearch turn just to discover the search tool.
  • Screenshots and UI-rendering tools: Distilling script output to JSON strips binary screenshots and collapses UI-rendering tool calls into one script row. Those had to be excluded from callTool() so the model keeps calling them directly.

Caveats: One developer's daily workload on macOS, not a controlled benchmark. Direct calls have a lower median (178 B vs 651 B) because clicks and short waits return tiny acks; Code Mode cuts the heavy tail from browser snapshots, email threads, and Slack histories.

Full write-up with the 10-CLI comparison table (Claude Code, Codex, OpenCode, Pi, Cursor, Grok, Hermes, Kiro, Antigravity, Kimi): https://yardlet.app/blog/what-is-code-mode-direct-tool-calling.html

2 Upvotes

4 comments sorted by

•

u/AutoModerator 15m ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Ai-ate-my-hamster 9m ago

This looks promising

1

u/Live-Distribution125 6m ago

you cut tools/list by 90% and turn-one tokens by 2.2%. ToolSearch was already doing your job, you just added a gateway in front of it.