Excessive input token usage with Sonnet on AWS Bedrock #7224

Closed
opened 2026-02-16 18:06:30 -05:00 by yindo · 5 comments
Owner

Originally created by @cfoust on GitHub (Jan 22, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

I swapped to opencode recently and realized I was regularly hitting token usage limits on AWS Bedrock. I ran tokscale and discovered that opencode was using millions (!) of input tokens even for short sessions. This does not seem to happen when I use Sonnet and Opus via the Anthropic provider.

Here is an archive of my ~/.local/share/opencode/storage directory containing a single session demonstrating this problem:
storage.tar.gz

In this case I prompted it to describe the opencode codebase to me. It used ~300k input tokens in just a few seconds. I did a basic analysis and it seems that the outputs of tool calls are getting repeatedly included in the context window.

My config:

{
  "model": "amazon-bedrock/anthropic.claude-sonnet-4-5-20250929-v1:0",
  "small_model": "amazon-bedrock/anthropic.claude-3-haiku-20240307-v1:0",
  "provider": {
    "amazon-bedrock": {
      "options": {
        "region": "us-XXXX",
        "endpoint": "https://bedrock-runtime.us-XXXX.amazonaws.com",
        "setCacheKey": true
      }
    }
  }
}

I'd also like to relay my gratitude to all of opencode's contributors! It's an amazing product.

Plugins

N/A, and no MCPs whatsoever

Just vanilla opencode without any other alterations

OpenCode version

1.1.27

Steps to reproduce

  1. Use any Anthropic model on AWS Bedrock. (I have not tested other models.)
  2. See input token usage explode.

Screenshot and/or share link

No response

Operating System

macOS 15.1

Terminal

kitty

Originally created by @cfoust on GitHub (Jan 22, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description I swapped to opencode recently and realized I was regularly hitting token usage limits on AWS Bedrock. I ran [tokscale](https://github.com/junhoyeo/tokscale) and discovered that opencode was using millions (!) of input tokens even for short sessions. This does not seem to happen when I use Sonnet and Opus via the Anthropic provider. Here is an archive of my ~/.local/share/opencode/storage directory containing a single session demonstrating this problem: [storage.tar.gz](https://github.com/user-attachments/files/24801420/storage.tar.gz) In this case I prompted it to describe the opencode codebase to me. It used ~300k input tokens in just a few seconds. I did a basic analysis and it seems that the outputs of tool calls are getting repeatedly included in the context window. My config: ```json { "model": "amazon-bedrock/anthropic.claude-sonnet-4-5-20250929-v1:0", "small_model": "amazon-bedrock/anthropic.claude-3-haiku-20240307-v1:0", "provider": { "amazon-bedrock": { "options": { "region": "us-XXXX", "endpoint": "https://bedrock-runtime.us-XXXX.amazonaws.com", "setCacheKey": true } } } } ``` I'd also like to relay my gratitude to all of opencode's contributors! It's an amazing product. ### Plugins N/A, and no MCPs whatsoever Just vanilla opencode without any other alterations ### OpenCode version 1.1.27 ### Steps to reproduce 1. Use any Anthropic model on AWS Bedrock. (I have not tested other models.) 2. See input token usage explode. ### Screenshot and/or share link _No response_ ### Operating System macOS 15.1 ### Terminal kitty
yindo added the bugperf labels 2026-02-16 18:06:30 -05:00
yindo closed this issue 2026-02-16 18:06:30 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 22, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #8185: Does OpenCode send back all previous reasoning blocks to Claude (or any provider)? - Discusses the same problem of tool outputs/reasoning being repeatedly included in context
  • #5577: DeepSeek V3.2 : reasoning_content not cleared from message history on new turns, causing excess token usage - Similar issue with reasoning content not being cleared, causing millions of excess tokens
  • #254: Ridiculously big usage of input tokens for simple tasks - Another report of excessive input token usage for simple tasks
  • #9803: Claude w/ bedrock custom inference profile - no caching (CLOSED) - Related AWS Bedrock issue with similar symptom (high token usage) due to caching not being properly applied

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 22, 2026): This issue might be a duplicate of existing issues. Please check: - #8185: Does OpenCode send back all previous reasoning blocks to Claude (or any provider)? - Discusses the same problem of tool outputs/reasoning being repeatedly included in context - #5577: DeepSeek V3.2 : reasoning_content not cleared from message history on new turns, causing excess token usage - Similar issue with reasoning content not being cleared, causing millions of excess tokens - #254: Ridiculously big usage of input tokens for simple tasks - Another report of excessive input token usage for simple tasks - #9803: Claude w/ bedrock custom inference profile - no caching (CLOSED) - Related AWS Bedrock issue with similar symptom (high token usage) due to caching not being properly applied Feel free to ignore if none of these address your specific case.
Author
Owner

@thevinchi commented on GitHub (Feb 6, 2026):

This was recently fixed (https://github.com/anomalyco/opencode/pull/11664), and I noticed that input tokens have gone WAY down for all Anthropic models in Bedrock. However, with Opus 4.6 the input token count is quickly in the millions again.

EDIT: added link to PR

@thevinchi commented on GitHub (Feb 6, 2026): This was recently fixed (https://github.com/anomalyco/opencode/pull/11664), and I noticed that input tokens have gone WAY down for all Anthropic models in Bedrock. However, with Opus 4.6 the input token count is quickly in the millions again. EDIT: added link to PR
Author
Owner

@thevinchi commented on GitHub (Feb 6, 2026):

Nevermind, I had not updated opencode to the latest version in the environment where we were testing Opus 4.6. 🤦‍♂️

If you update to the latest version, you should notice WAY lower input token counts.

@thevinchi commented on GitHub (Feb 6, 2026): Nevermind, I had not updated opencode to the latest version in the environment where we were testing Opus 4.6. 🤦‍♂️ If you update to the latest version, you should notice WAY lower input token counts.
Author
Owner

@rekram1-node commented on GitHub (Feb 6, 2026):

should be fixed

@rekram1-node commented on GitHub (Feb 6, 2026): should be fixed
Author
Owner

@cfoust commented on GitHub (Feb 6, 2026):

Thank you guys so much! I really appreciate this

@cfoust commented on GitHub (Feb 6, 2026): Thank you guys so much! I really appreciate this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7224