goose icon indicating copy to clipboard operation
goose copied to clipboard

Feature Request: Make Anthropic max_tokens configurable

Open Surendhar-N-D opened this issue 1 month ago • 2 comments

Feature Request: Make Anthropic max_tokens configurable

Summary

Currently, the default max_tokens value for Anthropic in Goose is hardcoded to 8192.
However, Anthropic models now support up to 64k tokens, and there is no environment variable or configuration option to adjust this limit.

Request

Please add support for configuring the max_tokens value via an environment variable or configuration file, so users can take full advantage of the higher token limits supported by the Anthropic API.

Proposed Solution

  • Introduce an environment variable (e.g., ANTHROPIC_MAX_TOKENS) or configuration setting to override the default.

Rationale

  • Enables users to leverage larger contexts for complex workloads.
  • Improves compatibility with the full capabilities of Anthropic’s API.
  • Increases flexibility without breaking existing functionality.

Environment

  • Goose version: 1.12
  • API: Anthropic
  • Current behavior: max_tokens fixed at 8192
  • Expected behavior: Configurable up to 64k

Additional Context

Anthropic documentation reference: https://docs.claude.com/en/docs/about-claude/models/overview

Surendhar-N-D avatar Oct 29 '25 05:10 Surendhar-N-D

You can use a custom provider for this; just base it on the anthropic engine and you should be good to go

DOsinga avatar Oct 29 '25 13:10 DOsinga

You can use a custom provider for this; just base it on the anthropic engine and you should be good to go

Thanks for the suggestion! I tried implementing it using a custom provider based on the Anthropic engine, but it looks like the default max_tokens value (8192) is still being applied. I also looked into the code even when using a custom provider for the Anthropic engine, an instance of AnthropicProvider is still being created internally, where the default value is set to 8192

Surendhar-N-D avatar Oct 30 '25 10:10 Surendhar-N-D