메뉴
HN
Hacker News 16일 전

클로드 코드의 과도한 토큰 소모, 오픈코드와 비교한 비용 분석

IMP
8/10
핵심 요약

동일한 모델과 환경에서 테스트한 결과, 클로드 코드는 프롬프트를 읽기 전에도 약 33,000개의 토큰을 소모하여 오픈코드(약 7,000개)보다 훨씬 비효율적인 것으로 나타났습니다. 클로드 코드는 세션 중 캐시를 비효율적으로 재작성하여 비용이 크게 증가하며, 하위 에이전트를 사용할 때마다 부트스트랩 비용이 추가되어 전체 토큰 사용량이 급증합니다. 다만 다단계 작업에서는 요청을 일괄 처리하는 방식 덕분에 총 토큰 사용량이 더 낮을 수 있습니다.

번역된 본문

우리는 클로드 코드(Claude Code)와 오픈코드(OpenCode)를 동일한 모델, 동일한 머신, 동일한 작업 환경에서 실행하고, 주고받는 모든 데이터를 분석했습니다. 클로드 코드의 리소스 소모가 훨씬 심각합니다. 두 시스템에 한 줄짜리 응답을 요청했을 때, 클로드 코드는 실제 프롬프트가 처리되기도 전에 시스템 프롬프트, 도구 스키마, 그리고 내부 프레임워크(scaffolding)를 위해 약 33,000개의 토큰을 사용했습니다. 반면 오픈코드는 약 7,000개만 사용했습니다.

클로드 코드는 캐시 측면에서도 매우 비효율적입니다. 우리가 캡처한 모든 실행에서 오픈코드의 요청 접두사(prefix)는 바이트 단위로 완전히 동일했습니다. 이 시스템은 세션당 한 번만 캐시에 데이터를 기록한 뒤, 이후에는 몇 푼 안 되는 비용으로 이를 읽어옵니다. 반면 클로드 코드는 세션 도중에도 수만 개의 프롬프트 캐시 토큰을 반복적으로 재작성(re-write)했으며, 동일한 작업에서 최대 54배나 많은 캐시 토큰을 생성했습니다. 캐시 기록(write)은 당연히 더 높은 비용이 청구되므로, 클로드 코드 사용 시 사용량 대시보드가 급격히 증가하는 원인이 됩니다.

설정(config) 역시 프롬프트를 부풀립니다. 실제 프로덕션 환경의 저장소에 있는 72KB 크기의 지시 파일(AGENTS.md 또는 CLAUDE.md)은 모든 단일 요청에 평균 20,000개의 토큰을 추가합니다. 5개의 소규모 MCP 서버를 연동하면 여기에 추가로 5,0007,000개의 토큰이 더해집니다. 즉, 실제 작업 환경이 첫 번째 요청을 보낼 시점이면, 사용자가 단 한 글자도 입력하기 전에 이미 75,00085,000개의 토큰이 소모된 상태가 됩니다.

하위 에이전트(Subagents)를 사용하면 비용이 더욱 증가합니다. 직접 수행할 때 121,000개의 토큰이면 되는 소규모 작업이 두 개의 하위 에이전트로 분산되면 513,000개의 토큰 비용이 발생합니다. 모든 하위 에이전트는 각자의 초기화(bootstrap) 비용을 가지며, 부모 에이전트가 이 결과물을 다시 소비해야 하기 때문입니다.

물론 클로드 코드에게 유리한 결과도 하나 발견했습니다. 다단계 작업에서는 클로드 코드의 전체 작업 총토큰량이 오픈코드보다 더 낮게 나왔습니다. 오픈코드가 매 차례마다 작은 기본 비용을 반복해서 지불하는 반면, 클로드 코드는 도구 호출을 더 적은 수의 요청으로 묶어(batch) 처리하기 때문입니다. 즉, 시작점의 미터기는 더 높지만, 세션이 어떻게 진행되느냐에 따라 최종 비용이 결정됩니다.

이 글의 나머지 부분에서는 우리가 API 경계에서 이 모든 것을 어떻게 측정했는지, 토큰이 어디로 가는지, 그리고 프롬프트 캐싱이 실제로 비용을 얼마나 절약해주는지 보여줍니다.

왜 이런 측정을 해야 할까요? 토큰 오버헤드는 곧 비용, 지연 시간, 그리고 컨텍스트 예산(context budget)입니다. 프레임워크가 차지하는 토큰은 코드 처리에 사용할 수 없는 작업 컨텍스트 낭비를 의미하며, 이 기본값은 매 차례마다 재전송되거나 캐시에서 다시 읽어옵니다. 특히 유럽연합(EU) AI법 제12조에서 시스템의 동작을 기록하고 이해할 것을 요구하는 프로덕션 환경에서 에이전트 AI를 운영한다면, '내 에이전트가 실제로 무엇을 전송하는가'라는 질문은 단순한 추측이 아닌 데이터로 답해야 하는 문제입니다.

우리의 측정 방법은 다음과 같습니다. 우리는 각 시스템과 모델 엔드포인트 사이에 로깅 프록시(logging proxy)를 배치했습니다. 시스템(Claude Code / OpenCode) → 로깅 프록시(요청 페이로드 및 응답 사용량 캡처) → 모델 엔드포인트 이 프록시는 요청마다 두 가지를 기록합니다. 첫 번째는 시스템 블록, 도구 스키마, 메시지 등 에이전트가 실제로 방출하는 정확한 JSON 페이로드입니다. 두 번째는 API가 반환한 사용량 블록으로, 입력 토큰, 캐시 기록, 캐시 읽기, 출력 토큰을 포함합니다.

우리는 다음 조건에서 테스트를 진행했습니다. • 시스템: Claude Code 2.1.207 및 OpenCode 1.17.18, 둘 다 동일한 모델(claude-sonnet-4-5)로 고정. • 기본 환경 격리: MCP 서버, 사용자 설정, 메모리가 없는 새 구성 디렉터리. 지시 파일이 없는 빈 워크스페이스. 권한은 우회. • 배가(multiplier) 환경: 여기에 변수를 하나씩 추가하며 테스트. • 작업: T1("정확히 'OK'라고 응답하라")은 고정 오버헤드를 분리하고, T2는 파일 요약, T3는 FizzBuzz 작성-실행-테스트-수정 루프입니다. • 도구 제거 변형: Claude Code는 --tools "", OpenCode는 tools 비활성화 옵션을 주어 시스템 프롬프트와 도구 스키마의 토큰 무게를 분리해 측정했습니다.

수치를 공유하기 전 한 가지 정정 사항이 있습니다. 우리의 트래픽은 요청을 자체 래퍼로 감싸는 로컬 LLM 게이트웨이를 통과합니다. 순수 교정 요청을 통해 이를 측정한 결과 약 6,200 토큰의 고정 비용이 발생했으며, 이 값은 아래 모든 측정치에서 공제되었습니다. 페이로드 수치는 캡처된 요청에서 직접 추출한 것입니다.

원문 보기
원문 보기 (영어)
We put Claude Code and OpenCode on the same model, the same machine, and the same tasks, then examined everything sent and received. Claude Code is far hungrier: When we asked both harnesses for a one-line reply, Claude Code used roughly 33,000 tokens of system prompt, tool schemas, and injected scaffolding before the prompt even arrived. OpenCode used about 7,000. Claude Code is far more cache inefficient: OpenCode&#x27;s request prefix was byte-identical in every run we captured; it paid to cache its payload once per session and read it back for pennies. Claude Code on the other hand re-wrote tens of thousands of prompt-cache tokens mid-session, run after run, and on the same task wrote up to 54x more cache tokens than OpenCode . Cache writes of course are billed at a premium, which accounted for the usage dashboard climbing when using Claude Code. Config further bloats the prompt: A production repository&#x27;s 72KB instruction (AGENTS.md or CLAUDE.md) file adds another (avg) 20,000 tokens to every single request. Five modest MCP servers add 5,000 to 7,000 more. 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. Subagents add to the cost: A small task that cost 121,000 tokens done directly cost 513,000 tokens when fanned out to two subagents , because every subagent has its own bootstrap cost, and the parent then consumes its transcript. We found one result in favour of Claude Code: On a multi-step task Claude Code&#x27;s whole-task total came out lower than OpenCode&#x27;s, because it batches tool calls into fewer requests while OpenCode re-pays its smaller baseline turn after turn. The meter starts higher; how the session unfolds decides who spends more. The rest of this post shows how we measured all of this at the API boundary, where the tokens go, and what prompt caching does and does not save you. Why measure this at all Token overhead is cost, latency, and context budget. Every token of harness payload is a token of working context you cannot spend on code, and the baseline is re-sent, or re-read from cache, on every single turn. If you operate agentic AI in production, particularly under the EU AI Act where Article 12 expects you to log and understand your system&#x27;s behaviour, "what does my agent actually send" is a question you should be able to answer with data rather than folklore. Method We spliced a logging proxy between each harness and the model endpoint. harness (Claude Code / OpenCode) → logging proxy (captures request payloads + response usage) → model endpoint The proxy records two things per request. The first is the exact JSON payload the harness emitted, meaning the system blocks, tool schemas, and messages. The second is the usage block the API returned, covering input tokens, cache writes, cache reads, and output tokens. The payload capture is ground truth for what the harness sends. The usage block is ground truth for what was metered. We tested under these conditions. Harnesses. Claude Code 2.1.207 and OpenCode 1.17.18, both pinned to claude-sonnet-4-5 , July 2026. Baseline isolation. Fresh config directories with no MCP servers, no user settings, and no memory; an empty workspace with no instruction files; permissions bypassed. Multiplier lanes then add one variable at a time. Tasks. T1 says "Reply with exactly: OK" and isolates fixed overhead (three runs per harness). T2 reads a seeded file and summarises it. T3 is a write-run-test-fix loop against FizzBuzz plus a checker script. Zero-tools variant. Claude Code with --tools "" and OpenCode with "tools": {"*": false} , separating system prompt from tool schema weight. One honesty note before the numbers. Our traffic passes through a local LLM gateway that wraps requests in its own envelope, a constant we measured at roughly 6,200 tokens with bare calibration requests and subtracted from every metered figure below. Payload-level figures come from the captured request bodies, which the gateway cannot affect, and are exact. Character-to-token conversion for component estimates uses each harness&#x27;s own measured ratio of 4.1 to 4.4 characters per token, derived from cold-cache anchors where the metered write equals the full payload, rather than a generic heuristic. Part I. The floor The fixed overhead of saying OK The task was 22 characters. Here is what each harness sent with it on its first request. Component Claude Code OpenCode System prompt 27,344 chars, 3 blocks 9,324 chars, 1 block Tool schemas 27 tools, 99,778 chars 10 tools, 20,856 chars First-message scaffolding 7,997 chars of <system-reminder> blocks none The actual prompt 22 chars 22 chars First-turn payload (calibrated) ~32,800 tokens ~6,900 tokens OpenCode&#x27;s request is close to minimal. There is one system block that opens with "You are OpenCode, the best coding agent on the planet", ten classic coding tools, and your prompt as the only user content. Claude Code&#x27;s request is a platform bootstrap. The 27 tools include the coding core plus an entire background-agent and orchestration suite, from CronCreate and Monitor to the Task family, worktree management, and push notifications. Before your prompt, its first user message carries three injected reminder blocks; a catalogue of agent types for delegation, a catalogue of available skills, and user context. Tool schemas are the dominant term for both. Roughly 24,000 of Claude Code&#x27;s ~33,000 tokens are tool definitions, versus roughly 4,800 of OpenCode&#x27;s ~6,900. Zero tools, pure harness Stripping the tools isolates the system prompt itself. Claude Code&#x27;s weighs in at 26,891 chars, about 6.5k tokens. OpenCode&#x27;s is 8,811 chars, about 2.0k tokens. Both harnesses trim their prompt slightly when tools are disabled. Even with no tools at all, Claude Code&#x27;s instruction set is over three times the size of OpenCode&#x27;s; the residual is behavioural doctrine, meaning tone rules, safety guidance, task-management instructions, and environment description. A one-tool task T2 asked each harness to read a file and summarise it. Both produced correct summaries. Claude Code took 6 HTTP requests and roughly 199,000 cumulative metered input tokens. OpenCode took 4 requests and roughly 41,000, plus one Haiku side call for session titling. Most of those tokens are cache reads billed at a tenth of the input price. Three things scale with payload regardless; the first-turn cache write, the per-turn read, and context-window consumption, which no cache discount reduces. A 33k-token baseline means every turn starts a sixth of the way into a 200k window before any code enters the conversation. A multi-step task, where the gap closes T3, the write-run-test-fix loop, inverted the expectation set by the baselines. Metric Claude Code OpenCode Model requests 3 9 (+1 title call) Tool-calling style parallel batch in one round trip one tool call per turn Cumulative metered input ~121,000 tokens ~132,000 tokens Claude Code batched the entire job, two file writes and two script executions, into a single parallel tool round trip. OpenCode made exactly one tool call per turn and took nine. Because the baseline is re-sent on every request, request count multiplies baseline. OpenCode paid its ~7k baseline nine times, Claude Code paid its ~33k three times, and the totals converged. Whole-task input roughly equals baseline times request count, plus conversation growth. A large-baseline harness that batches aggressively and a small-baseline harness that serialises can land in the same place. Two structural details emerged from the payloads. Claude Code injects an additional <system-reminder> block as the conversation progresses, three on the first turn and four by the first tool round trip, so its scaffolding grows with turn count. OpenCode&#x27;s per-turn marginal payload, roughly 400 to 2,200 chars per turn, is pure conversation content. Part II. The multipliers The floor explains a sess