Skip to content

Excessive input token usage with Sonnet on AWS Bedrock #10066

@cfoust

Description

@cfoust

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingperfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions