Skip to content

Clamping to context window prevents artificial context limits, distinct from maxTokens #6206

Description

@DanielThomas

What happened?

The fix (
09f1059#diff-1a93fd67549d15259de0044dba9e2650cf5e6c41a51de3c4994992c9867ca80b) for #5595 clamps max_tokens to the reported context window.

This prevents plugins from intentionally setting a smaller context window for UI feedback/automatic compact, because it's no longer tracking the maximums supported by the API due to the clamp:

Error: Model stopped because it reached the maximum output token limit. The response may be incomplete.

Steps to reproduce

  • Report a smaller context size than supported by the API in a registered model
  • Note that it clamps to that limit, instead of the maximum limit of the model

Expected behavior

Plugins should be able to set a context window size smaller than is supported by the model to cause UI feedback and compaction at lower thresholds (for instance, I find even 400K tokens into a 1M Anthropic model is pushing it)

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    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