Skip to content

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

Closed as not planned
Closed as not planned

Description

@husamettinarabaci

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.

Activity

  1. github-actions commented on Jan 29, 2026

    @github-actions
    Contributor

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

    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.

  2. husamettinarabaci commented on Jan 29, 2026

    @husamettinarabaci
    Author

    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.

  3. husamettinarabaci commented on Jan 29, 2026

    @husamettinarabaci
    Author

    Closing as duplicate of #8140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions