Remove unnecessary ACP cost estimation fallback#2330
Conversation
The `_estimate_cost_from_tokens()` fallback and related tracking were added when the ACP server appeared to report $0 cost. Investigation revealed the $0 was caused by using an outdated npm package (`claude-code-acp@0.16.2`) that lacked usage tracking entirely. With `claude-agent-acp@0.20.2` (already updated in #2326), the Claude Code SDK correctly computes cost via its internal pricing tables and forwards it through UsageUpdate — making the litellm-based fallback unnecessary. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
API breakage checks (Griffe)Result: Failed Log excerpt (first 1000 characters) |
Agent server REST API breakage checks (OpenAPI)Result: Failed Log excerpt (first 1000 characters) |
all-hands-bot
left a comment
There was a problem hiding this comment.
Linus-Style Engineering Assessment
🟢 Good taste - This is exactly the kind of cleanup that should happen when you fix the root cause of a problem.
Key Insight: The fallback was a band-aid for using an outdated SDK (claude-code-acp@0.16.2). Once the SDK was updated to claude-agent-acp@0.20.2, the band-aid became unnecessary complexity. Removing ~236 lines of code that solve a problem that no longer exists is good engineering.
Verdict: ✅ Worth merging after verification
Important: This touches cost tracking which could affect benchmarks/evals. Before merging, verify the unchecked test plan item - confirm the CI run-examples workflow shows non-zero cost without the fallback. Once verified, this is a clean simplification with no issues.
Coverage Report •
|
||||||||||||||||||||
|
@neubig you were right to question the necessity of the fallback: bumping the acp version was the real fix https://github.com/OpenHands/software-agent-sdk/actions/runs/22732193090 |
all-hands-bot
left a comment
There was a problem hiding this comment.
Clean removal of unnecessary fallback logic. The SDK update (claude-agent-acp@0.20.2) fixed the root cause, making this code obsolete. Removing ~236 lines of workaround code is good engineering.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
_estimate_cost_from_tokens()fallback and_last_estimated_costtracking fromacp_agent.pytest_acp_agent.pyThe fallback was added in #2326 to estimate cost via
litellm.model_costwhen the ACP server reported $0. Investigation revealed the $0 was caused by usingclaude-code-acp@0.16.2which lacked usage tracking entirely. Withclaude-agent-acp@0.20.2(already updated in #2326), the Claude Code SDK correctly computes cost via its internal pricing tables and forwards it throughUsageUpdate— making the fallback unnecessary.Test plan
run-examplesworkflow confirms ACP example still reports non-zero cost without the fallbackAgent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:8cb1c5d-pythonRun
All tags pushed for this build
About Multi-Architecture Support
8cb1c5d-python) is a multi-arch manifest supporting both amd64 and arm648cb1c5d-python-amd64) are also available if needed