AI 에이전트는 돈을 어떻게 쓰나? Agentic Coding 작업에서 Token 소비 분석 및 예측
How Do AI Agents Spend Your Money? Analyzing and Predicting Token Consumption in Agentic Coding Tasks
TL;DR Highlight
코딩 AI 에이전트는 일반 채팅보다 토큰을 1200배 이상 쓰며, 더 많이 써도 성능이 오르지 않는다.
Who Should Read
AI 코딩 에이전트(Cursor, Devin, OpenHands 등)를 팀에 도입하거나 비용을 관리해야 하는 개발자 및 엔지니어링 매니저. 에이전트 API 비용이 예상보다 폭발적으로 나와서 당황한 경험이 있는 사람.
Core Mechanics
- Agentic coding(에이전트가 자율적으로 코드 수정하는 작업)은 단순 코드 추론 대비 3500배, 코드 채팅 대비 1200배 많은 토큰을 소비한다. 비용을 올리는 주범은 output이 아닌 input 토큰이다.
- 같은 작업을 반복 실행하면 토큰 사용량이 최대 30배 차이 난다. 즉, 비용이 예측 불가할 정도로 들쭉날쭉하다.
- 토큰을 많이 쓴다고 성공률이 높아지지 않는다. 오히려 정확도는 중간 비용 구간에서 가장 높고, 비용이 최대인 구간에서는 정체되거나 떨어진다.
- 비싼 실패 실행을 분석하면 같은 파일을 반복 조회·수정하는 패턴이 두드러진다. 이게 비용만 올리고 진전은 없는 '비효율적 탐색'의 원인이다.
- 모델별 토큰 효율 차이가 크다. Kimi-K2와 Claude Sonnet-4.5는 GPT-5보다 평균 150만 토큰 이상 더 쓴다. 이 차이는 작업 난이도 때문이 아니라 모델 고유 행동 패턴 때문이다.
- 전문가가 매긴 작업 난이도(예: '15분 이내')는 실제 토큰 소비량의 약한 예측 변수에 불과하다 (Kendall τb = 0.32). '쉬운' 작업도 에이전트한테는 엄청 비쌀 수 있다.
- 모델이 실행 전에 자기 토큰 사용량을 예측하게 했더니, 상관관계가 최대 0.39로 낮고 일관되게 실제보다 과소 추정했다. 특히 input 토큰 예측이 더 어렵다.
Evidence
- Agentic coding 평균 토큰: 4,167,850 토큰 / 평균 비용 $1.857. Code Reasoning은 1,190 토큰 / $0.016, Code Chat은 3,390 토큰 / $0.023으로 각각 3500배, 1200배 차이.
- 같은 문제에서 가장 비싼 실행이 가장 싼 실행보다 평균 2배 비싸고, 최대 30배까지 차이 난다. 가장 비싼 문제는 가장 싼 문제보다 약 700만 토큰 더 소비한다.
- 모델 자가 예측 Pearson 상관계수는 최고 0.39(Claude Sonnet-4.5 output 토큰)이며, 모든 모델이 실제 사용량을 체계적으로 과소 추정했다.
- GPT-5와 GPT-5.2는 공통 성공 작업에서 Kimi-K2 대비 150만 토큰 이상 적게 사용했고, 이 효율 차이는 공통 실패 작업에서도 동일하게 유지됐다.
How to Apply
- 에이전트 비용이 예산을 초과할 것 같을 때, 실제 실행 전에 같은 에이전트를 '토큰 추정 모드'로 먼저 실행해 대략적인 비용 신호를 얻을 수 있다. 논문 Appendix C의 프롬프트를 그대로 사용해 작업을 단계별로 분해하고 JSON 형식으로 추정값을 받으면 된다.
- 동일한 코딩 작업에 여러 모델을 쓸 수 있다면, Kimi-K2나 Claude Sonnet-4.5 대신 GPT-5나 GPT-5.2를 선택하는 것만으로 작업당 평균 150만 토큰 이상을 절약할 수 있다. 특히 대량 작업 처리 파이프라인에서 효과적이다.
- 에이전트가 실패하는 실행에서 같은 파일을 반복 view/modify하는 패턴이 비용 폭발의 신호다. 에이전트 로그에서 동일 파일 반복 접근 횟수를 모니터링해 임계치 초과 시 조기 종료하는 budget-aware 정책을 추가하면 낭비를 줄일 수 있다.
Code Example
# 논문 Appendix C 기반 - 실행 전 토큰 비용 추정 프롬프트
# OpenHands 에이전트를 토큰 추정 모드로 사용하는 시스템 프롬프트 핵심 부분
SYSTEM_PROMPT = """
You are a TOKEN ESTIMATION agent, not a problem-solving agent.
Your ONLY goal is to estimate token costs, NOT to fix bugs.
Estimation Workflow:
1. Exploration: Explore relevant files and understand the task context.
2. Analysis: Consider solution approaches and estimate token costs per phase.
3. Testing: Run existing tests to understand complexity (do NOT modify files).
4. Output: Produce a JSON estimate and call finish.
Required JSON output format:
{
"predicted_input_tokens": <integer>,
"predicted_output_tokens": <integer>,
"predicted_total_tokens": <integer>,
"confidence": <float 0-1>,
"breakdown_by_phase": {
"repo_cloning": {"input_tokens": ..., "output_tokens": ...},
"initial_reading": {"input_tokens": ..., "output_tokens": ...},
"test_setup": {"input_tokens": ..., "output_tokens": ...},
"debugging": {"input_tokens": ..., "output_tokens": ...},
"coding_iterations": {"input_tokens": ..., "output_tokens": ...},
"verification": {"input_tokens": ..., "output_tokens": ...},
"review_cleanup": {"input_tokens": ..., "output_tokens": ...}
}
}
CRITICAL: Never write actual code fixes. Never modify source files.
"""
USER_PROMPT = """
I've uploaded a python repository at /workspace/{repo_name}.
You are a TOKEN ESTIMATION agent.
Estimate the token cost to fix the following issue:
<issue description>
{issue_text}
</issue description>
"""
# 실제 적용 예시 (OpenAI API 사용)
import openai
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-4o", # 또는 다른 모델
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": USER_PROMPT.format(
repo_name="my-project",
issue_text="Fix a bug where X fails when Y happens"
)}
]
)
print(response.choices[0].message.content)Terminology
관련 논문
adamsreview: Claude Code용 멀티 에이전트 PR 코드 리뷰 파이프라인
Claude Code에서 최대 7개의 병렬 서브 에이전트가 각각 다른 관점으로 PR을 리뷰하고, 자동 수정까지 해주는 오픈소스 플러그인이다. 기존 /review나 CodeRabbit보다 실제 버그를 더 많이 잡는다고 주장하지만 커뮤니티에서는 복잡도와 실효성에 대한 회의론도 나왔다.
Claude를 User Space IP Stack으로 써서 Ping에 응답시키면 얼마나 빠를까?
Claude Code에게 IP 패킷을 직접 파싱하고 ICMP echo reply를 구성하도록 시켜서 실제로 ping에 응답하게 만든 실험으로, 'Markdown이 곧 코드이고 LLM이 프로세서'라는 아이디어를 네트워크 스택 수준까지 밀어붙인 재미있는 사례다.
AI Agent를 위한 Git: re_gent
AI 코딩 에이전트(Claude Code 등)가 수행한 모든 툴 호출을 자동으로 추적하고, 어떤 프롬프트가 어느 코드 줄을 작성했는지 blame까지 가능한 버전 관리 도구다.
Agent-Native CLI를 위한 설계 원칙 10가지
AI 에이전트가 CLI 도구를 더 잘 사용할 수 있도록 설계하는 원칙들을 정리한 글로, 에이전트가 CLI를 도구로 활용하는 빈도가 높아지면서 이 설계 방식이 실용적으로 중요해지고 있다.
Agent-harness-kit: MCP 기반 멀티 에이전트 워크플로우 오케스트레이션 프레임워크
여러 AI 에이전트가 서로 역할을 나눠 협업할 수 있도록 조율하는 scaffolding 도구로, Vite처럼 설정 없이 빠르게 멀티 에이전트 파이프라인을 구성할 수 있다.
Tilde.run – AI Agent를 위한 트랜잭션 기반 버전 관리 파일시스템 샌드박스
AI 에이전트가 실제 프로덕션 데이터를 건드려도 롤백할 수 있는 격리된 샌드박스 환경을 제공하는 도구로, GitHub/S3/Google Drive를 하나의 버전 관리 파일시스템으로 묶어준다.
Related Resources
Original Abstract (Expand)
The wide adoption of AI agents in complex human workflows is driving rapid growth in LLM token consumption. When agents are deployed on tasks that require a significant amount of tokens, three questions naturally arise: (1) Where do AI agents spend the tokens? (2) Which models are more token-efficient? and (3) Can agents predict their token usage before task execution? In this paper, we present the first systematic study of token consumption patterns in agentic coding tasks. We analyze trajectories from eight frontier LLMs on SWE-bench Verified and evaluate models' ability to predict their own token costs before task execution. We find that: (1) agentic tasks are uniquely expensive, consuming 1000x more tokens than code reasoning and code chat, with input tokens rather than output tokens driving the overall cost; (2) token usage is highly variable and inherently stochastic: runs on the same task can differ by up to 30x in total tokens, and higher token usage does not translate into higher accuracy; instead, accuracy often peaks at intermediate cost and saturates at higher costs; (3) models vary substantially in token efficiency: on the same tasks, Kimi-K2 and Claude-Sonnet-4.5, on average, consume over 1.5 million more tokens than GPT-5; (4) task difficulty rated by human experts only weakly aligns with actual token costs, revealing a fundamental gap between human-perceived complexity and the computational effort agents actually expend; and (5) frontier models fail to accurately predict their own token usage (with weak-to-moderate correlations, up to 0.39) and systematically underestimate real token costs. Our study offers new insights into the economics of AI agents and can inspire future research in this direction.