Summarize this article with:
The 4.7x token overhead gap between Claude Code and OpenCode is a design trade-off, not a defect. Claude Code's 33,000-token baseline buys richer tool definitions, safety constraints, and context scaffolding that improve reliability on complex tasks. OpenCode's 7,000-token baseline buys speed, cost efficiency, and cache stability that excel on simple tasks.
The cost implications compound through three mechanisms:
- The 33K baseline is paid on every turn, not just the first
- Claude Code's unstable cache prefix triggers 54x more cache-write tokens than OpenCode at a 25% price premium
- Subagent fan-out multiplies the baseline across parallel agents, with documented incidents reaching $47,000 in a single session.
The winning strategy is hybrid routing: use low-overhead harnesses with cheap models for discovery and simple edits, reserve Claude Code with frontier models for hard tasks where the overhead is justified by higher success rates. Teams that adopt this pattern report 62% cost reductions while maintaining quality. The question is not which agent to use - it is which agent to use for which step.
When you fire up Claude Code and type a one-word prompt, the harness has already consumed roughly 33,000 tokens of system prompt, tool definitions, and injected scaffolding before the model processes a single character of your instruction. OpenCode, the open-source terminal coding agent from the SST team, sends approximately 7,000 tokens for the same task. That 4.7x difference in fixed overhead is not a rounding error - it is a structural design choice that directly determines your API bill, response latency, and throughput ceiling.
A team at Systima AI ran both harnesses on the same model (Claude Sonnet 4.5), same machine, and same tasks with a logging proxy spliced between the harness and the model endpoint. Their findings, published in July 2026, confirmed what developers had suspected since early 2025: Claude Code's baseline payload is a platform bootstrap, not a chat greeting.
Token Overhead Breakdown:
Tool schemas are the dominant cost driver for both harnesses. Roughly 24,000 of Claude Code's 33,000 baseline tokens are tool definitions: file operations, shell commands, search, the entire background-agent and orchestration suite (CronCreate, Monitor, the Task family, worktree management, push notifications). OpenCode ships 10 classic coding tools totaling about 4,800 tokens. The remaining gap comes from Claude Code's three injected <system-reminder> blocks that catalogue agent types, available skills, and user context before the user prompt arrives.
Even with all tools stripped (--tools ""), Claude Code's system prompt alone weighs 26,891 characters (~6.5K tokens) - over three times OpenCode's 8,811 characters (~2K tokens). The residual is behavioral doctrine: tone rules, safety guidance, task-management instructions, and environment description.
Where the Tokens Go: System Prompts, Tool Schemas, and Scaffolding
The 33K baseline is not monolithic. It decomposes into six categories, each with different implications for optimization.
Component-Level Token Allocation
Most developers make two mistakes when estimating token costs. First, they calculate spend based on prompt length plus expected response length, forgetting the 33,000-token baseline that every Claude Code call starts with. A 2025 survey by Latent Space found that 68% of Claude Code users underestimated actual token consumption by at least 40%. Second, they assume all coding agents have similar overhead. They do not: GitHub Copilot's chat mode uses roughly 12,000 tokens of overhead, Cursor's agent mode sits around 15,000, OpenCode's 7,000 is the lowest among popular tools, and Claude Code's 33,000 is the highest.
Inspecting Your Own Payload
You can measure what your harness actually sends by routing traffic through a logging proxy:
import json
from mitmproxy import http
class TokenLogger:
def request(self, flow: http.HTTPFlow):
if "anthropic.com" in flow.request.pretty_host:
body = json.loads(flow.request.content)
system = body.get("system", [])
tools = body.get("tools", [])
messages = body.get("messages", [])
system_tokens = sum(len(json.dumps(s)) // 4 for s in system)
tool_tokens = sum(len(json.dumps(t)) // 4 for t in tools)
msg_tokens = sum(len(json.dumps(m)) // 4 for m in messages)
print(f"System: {system_tokens}t | "
f"Tools: {tool_tokens}t | "
f"Messages: {msg_tokens}t | "
f"Tools count: {len(tools)}")
addons = [TokenLogger()]
Run this proxy, execute a trivial task ("Reply with exactly: OK"), and you will see exactly how many tokens each component burns before your instruction reaches the model.
Prompt Caching: The Hidden Cost Multiplier
Prompt caching is the single highest-leverage cost optimization for Claude API workloads in 2026. Anthropic's pricing model: cache writes cost 1.25x the base input price, cache reads cost 10% of the base input price. If your harness sends a stable, byte-identical prefix on every request, you pay the write premium once and read it back for pennies.
OpenCode exploits this perfectly. Its request prefix - system block, tool schemas, and message structure - is byte-identical across every run the Systima team captured. It pays to cache its 7,000-token payload once per session and reads it back at one-tenth the input price on subsequent turns.
Claude Code does not. It rewrites tens of thousands of prompt-cache tokens mid-session, run after run. On the same task, Claude Code wrote up to 54x more cache tokens than OpenCode. Because cache writes are billed at a 25% premium over standard input, this behavior is why the usage dashboard climbs faster with Claude Code even when the task is identical.
Cache Economics Example
Model: Claude Sonnet 4.6 ($3/M input, $15/M output)
Cache write: $3.75/M (1.25x base)
Cache read: $0.30/M (0.10x base)
Scenario: 1,000 API calls, 33K baseline per call
Without caching:
33,000 tokens x 1,000 = 33M tokens
Cost: 33 x $3 = $99.00
With stable caching (OpenCode pattern):
Write once: 33K tokens x $3.75/M = $0.12
Read 999 times: 33K x 999 x $0.30/M = $9.89
Total: $10.01 (89% savings)
With unstable caching (Claude Code pattern):
Assume 50% cache writes, 50% reads:
Writes: 16.5M x $3.75/M = $61.88
Reads: 16.5M x $0.30/M = $4.95
Total: $66.83 (33% savings, but 6.7x more expensive)
The difference between a byte-identical prefix and a dynamically-rewritten one is a 6.7x cost multiplier on the same baseline. This is the most expensive invisible cost in the coding-agent stack.
Configuration Bloat: CLAUDE.md and MCP Server Tax
The 33,000-token baseline assumes a bare configuration: no instruction files, no MCP servers, no user settings. Real-world setups are dramatically heavier.
A production repository's CLAUDE.md or AGENTS.md instruction file - typically 50-100KB of coding standards, architecture notes, and domain context - adds approximately 20,000 tokens to every single request. Five modest MCP servers (filesystem, GitHub, Slack, database, testing) add another 5,000 to 7,000 tokens because every connected MCP server loads its full tool schema into every message. By the time a real working setup sends its first request, it is 75,000 to 85,000 tokens deep before the user has typed a word.
MCP Schema Tax by Server Count
OpenCode has the same MCP problem at a smaller scale - every connected MCP tool's full schema loads on every turn, and the permission system gates whether a tool runs, not whether its definition costs you tokens. An open GitHub issue (#17482) on the OpenCode repository requests dynamic/lazy loading for MCP tool schemas to prevent this exact bloat.
Auditing Your MCP Overhead
# Count tool definitions injected by each MCP server
for server in filesystem github slack; do
echo "=== $server ==="
cat ~/.claude/mcp/$server/schema.json 2>/dev/null | \
python3 -c "import sys,json; d=json.load(sys.stdin); print(f'Tools: {len(d.get(\"tools\",[]))}, Chars: {len(json.dumps(d))}')"
done
# Measure total CLAUDE.md weight
wc -c CLAUDE.md AGENTS.md 2>/dev/null
# Rule of thumb: divide chars by 4.2 for approximate token count
Subagent Fan-Out: When Token Costs Explode
Claude Code's subagent system is powerful and dangerous. Each subagent is its own agent that re-reads its own system prompt and tool schemas on every turn it takes. A fan-out multiplies the number of full baselines in flight.
The Systima team measured this directly: a small task that cost 121,000 tokens done in the main session cost 513,000 tokens when fanned out to two subagents: a 4.2x increase. The parent ingests only each subagent's returned result, not the full transcript, but each subagent still pays its own 33,000-token baseline on every turn.
This scales nonlinearly. A developer reported burning 887,000 tokens per minute during a 2.5-hour Claude Code session with parallel subagents. Another incident documented by Finout produced a $47,000 bill from a single subagent fan-out event. Eight documented spike patterns can multiply Claude Code costs 10-500x, with subagent fan-out being the most dangerous.
Subagent Cost Projection
def estimate_subagent_cost(
base_overhead: int, # tokens per turn (e.g., 33000)
turns_per_agent: int, # average turns per subagent (e.g., 5)
num_subagents: int, # parallel subagents (e.g., 4)
input_price: float, # $/M tokens (e.g., 3.0)
cache_write_ratio: float # fraction of turns that rewrite cache (e.g., 0.5)
):
"""Estimate the token cost of a subagent fan-out task."""
cache_write_price = input_price * 1.25
cache_read_price = input_price * 0.10
per_subagent = base_overhead * turns_per_agent
total_tokens = per_subagent * num_subagents
write_tokens = total_tokens * cache_write_ratio
read_tokens = total_tokens * (1 - cache_write_ratio)
cost = (write_tokens / 1_000_000 * cache_write_price +
read_tokens / 1_000_000 * cache_read_price)
print(f"Subagents: {num_subagents}")
print(f"Total tokens: {total_tokens:,}")
print(f"Estimated cost: ${cost:.2f}")
return cost
# Baseline: 1 agent, no fan-out
estimate_subagent_cost(33000, 5, 1, 3.0, 0.5)
# → Total tokens: 165,000, Cost: $0.35
# Fan-out: 4 parallel subagents
estimate_subagent_cost(33000, 5, 4, 3.0, 0.5)
# → Total tokens: 660,000, Cost: $1.40 (4x increase)
The Multi-Step Paradox: When Higher Overhead Wins
The overhead story has a counterintuitive twist. On multi-step tasks, Claude Code's whole-session total can come out lower than OpenCode's, despite the higher per-turn baseline. This happens because Claude Code batches tool calls into fewer HTTP requests, while OpenCode re-pays its smaller 7,000-token baseline turn after turn.
The Systima team found this advantage held on their first model test (Claude Sonnet 4.5). But when they re-ran the same task on a newer model (Claude Fable 5), the advantage reversed: Claude Code took twice as many requests and cost roughly 298,000 tokens against OpenCode's 133,000. The meter starts higher; how the session unfolds decides who spends more.
A real-world benchmark from a 120-person fintech company illustrates the trade-off. They ran two identical code-review pipelines - one Claude Code, one OpenCode - across 500 pull requests:
Cost Calculations: What This Means for Your API Bill
At published June 2026 rates, the token overhead difference translates directly into dollars. Here is what a single trivial task ("Reply with exactly: OK") costs across harnesses and models:
For a team running 10,000 automated calls per month, the overhead difference between Claude Code and OpenCode means an extra $770/month on Sonnet 4.6 - $9,240 annually. At Opus 4.8 rates, the gap widens to $1,430/month or $17,160/year. These are costs for the baseline alone, before any actual work tokens are counted.
Monthly Cost by Usage Pattern
Practical Strategy: Hybrid Agent Routing
The optimal approach is not "use OpenCode for everything" or "use Claude Code for everything." It is route by step: cheap model for discovery, mid-tier model for normal patches, frontier model for hard failures - combined with the harness that minimizes overhead for each step.
Three-Tier Routing Model
For teams using a multi-provider API platform, this routing becomes trivially configurable. You can set the cheap scout tier to route to DeepSeek V4 Flash for file search and log summarization, the default coder to Claude Sonnet for patch generation, and the escalation tier to Claude Opus for architecture decisions - all through a single API key with per-provider cost tracking.
Implementation: Token-Aware Router
import os
import anthropic
class CodingAgentRouter:
def __init__(self):
self.tiers = {
"scout": {
"model": "deepseek-v4-flash",
"max_tokens": 2000,
"harness": "opencode", # low overhead
},
"coder": {
"model": "claude-sonnet-4-6",
"max_tokens": 8000,
"harness": "opencode",
},
"escalation": {
"model": "claude-opus-4-8",
"max_tokens": 16000,
"harness": "claude-code", # accepts higher overhead
},
}
def classify_task(self, prompt: str) -> str:
"""Route based on task complexity signals."""
escalation_signals = [
"architecture", "redesign", "debug this",
"refactor entire", "security audit"
]
scout_signals = [
"list files", "search for", "summarize",
"what does", "find all"
]
prompt_lower = prompt.lower()
if any(s in prompt_lower for s in escalation_signals):
return "escalation"
if any(s in prompt_lower for s in scout_signals):
return "scout"
return "coder"
def route(self, prompt: str):
tier = self.classify_task(prompt)
config = self.tiers[tier]
print(f"Routing to {tier}: {config['model']} via {config['harness']}")
return config
Cost Control Checklist
- Count tokens for real agent transcripts, not just the final answer
- Keep system instructions stable and cacheable - avoid dynamic scaffolding
- Summarize repository context before each new task instead of re-sending it
- Route cheap steps (file search, log summarization) to cheap models
- Cap output length for routine edits
- Use Batch or Flex API pricing for non-interactive jobs when available
- Track failed build/test loops as a separate cost metric - retries compound
- Audit MCP server schemas quarterly and remove unused tools
- Set hard token budgets per subagent invocation




