-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
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
- Use any Anthropic model on AWS Bedrock. (I have not tested other models.)
- See input token usage explode.
Screenshot and/or share link
No response
Operating System
macOS 15.1
Terminal
kitty