Skip to content

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

@husamettinarabaci

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions