[FEATURE]: Configurable per-session token budget limit #7946

Closed
opened 2026-02-16 18:08:44 -05:00 by yindo · 3 comments
Owner

Originally created by @husamettinarabaci on GitHub (Jan 29, 2026).

Originally assigned to: @thdxr on GitHub.

Problem

Currently, OpenCode enforces a hard-coded 200,000 token limit per conversation session. When this limit is reached, the session terminates and all context is lost, forcing users to start a new conversation.

For developers running OpenCode locally with their own compute resources and API keys, this restriction feels arbitrary - especially when their providers don't impose similar limits or when they have higher quotas available.

Proposed Solution

Add a configuration option to customize the per-session token budget, allowing users to adjust it based on their needs and resources.

Possible implementation approaches:

  • Config file option (e.g., ~/.opencode/config.json or .opencode/config.json)
  • Environment variable (e.g., OPENCODE_TOKEN_BUDGET)
  • CLI flag (e.g., opencode --token-budget 500000)

Use Case

As a developer working on complex, multi-step tasks that require extended context:

  • I want to maintain conversation continuity for longer sessions
  • Since I'm using my own local resources and API keys, I should be able to configure resource limits
  • Different users have different provider limits and use cases

Why This Belongs in OpenCode

OpenCode's philosophy emphasizes flexibility and user control (provider-agnostic, open source, customizable). Allowing users to configure their own resource limits aligns with this philosophy - especially since the computation happens locally on the user's machine with their own API keys.

This is particularly important for developers as extended context windows are often needed for complex refactoring, architecture decisions, or comprehensive code reviews.

Originally created by @husamettinarabaci on GitHub (Jan 29, 2026). Originally assigned to: @thdxr on GitHub. ## Problem Currently, OpenCode enforces a hard-coded 200,000 token limit per conversation session. When this limit is reached, the session terminates and all context is lost, forcing users to start a new conversation. For developers running OpenCode locally with their own compute resources and API keys, this restriction feels arbitrary - especially when their providers don't impose similar limits or when they have higher quotas available. ## Proposed Solution Add a configuration option to customize the per-session token budget, allowing users to adjust it based on their needs and resources. Possible implementation approaches: - Config file option (e.g., `~/.opencode/config.json` or `.opencode/config.json`) - Environment variable (e.g., `OPENCODE_TOKEN_BUDGET`) - CLI flag (e.g., `opencode --token-budget 500000`) ## Use Case As a developer working on complex, multi-step tasks that require extended context: - I want to maintain conversation continuity for longer sessions - Since I'm using my own local resources and API keys, I should be able to configure resource limits - Different users have different provider limits and use cases ## Why This Belongs in OpenCode OpenCode's philosophy emphasizes flexibility and user control (provider-agnostic, open source, customizable). Allowing users to configure their own resource limits aligns with this philosophy - especially since the computation happens locally on the user's machine with their own API keys. This is particularly important for developers as extended context windows are often needed for complex refactoring, architecture decisions, or comprehensive code reviews.
yindo closed this issue 2026-02-16 18:08:44 -05:00
Author
Owner

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

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

  • #8140: Feature Request: Configurable context limit and auto-compaction threshold
  • #10017: Feature Request: Custom compaction threshold to trigger earlier

Both of these issues request similar functionality for making the token/context limit configurable and allowing users to set custom thresholds for when compaction should trigger.

Feel free to ignore if your specific use case differs from these existing requests.

@github-actions[bot] commented on GitHub (Jan 29, 2026): This issue might be a duplicate of existing issues. Please check: - #8140: Feature Request: Configurable context limit and auto-compaction threshold - #10017: Feature Request: Custom compaction threshold to trigger earlier Both of these issues request similar functionality for making the token/context limit configurable and allowing users to set custom thresholds for when compaction should trigger. Feel free to ignore if your specific use case differs from these existing requests.
Author
Owner

@husamettinarabaci commented on GitHub (Jan 29, 2026):

Thank you for pointing this out! I can see this is indeed a duplicate of the existing issues, particularly #8140.

I'll close this issue and add my support to #8140 instead to avoid fragmentation.

Apologies for the duplicate - I should have searched more thoroughly before opening this.

@husamettinarabaci commented on GitHub (Jan 29, 2026): Thank you for pointing this out! I can see this is indeed a duplicate of the existing issues, particularly #8140. I'll close this issue and add my support to #8140 instead to avoid fragmentation. Apologies for the duplicate - I should have searched more thoroughly before opening this.
Author
Owner

@husamettinarabaci commented on GitHub (Jan 29, 2026):

Closing as duplicate of #8140

@husamettinarabaci commented on GitHub (Jan 29, 2026): Closing as duplicate of #8140
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7946