Skip to content

Unable to use Devstral Small: error due to max tokens #926

Closed
anomalyco/models.dev
#49

Description

@KTibow

Some models (Devstral Small on Chutes, Mercury Coder, many more near the bottom of this list) have context lengths of 32k tokens. Since opencode always sets max tokens to 32k and sends more tokens as context, errors result:

Image

This is likely due to an incorrect context length in models.dev. opencode should adapt its request to use a shorter max tokens (in case the data is incorrect) and/or switch to using data from the models endpoint (always use correct data).

Activity

  1. changed the title [-]Automatically adapt max tokens[/-] [+]Unable to use Devstral Small: error due to max tokens[/+] on Jul 12, 2025
  2. self-assigned this
    on Jul 14, 2025
  3. thdxr commented on Jul 14, 2025

    @thdxr
    Member

    can you set output tokens number to be 16K or something smaller?

  4. KTibow commented on Jul 14, 2025

    @KTibow
    Author

    That would theoretically fix it, but ideally anomalyco/models.dev#49 would be merged and then something like this would be added:

    - const outputLimit = Math.min(model.info.limit.output, OUTPUT_TOKEN_MAX) || OUTPUT_TOKEN_MAX
    + let outputLimit = OUTPUT_TOKEN_MAX;
    + if (model.info.limit.output && model.info.limit.output < outputLimit) outputLimit = model.info.limit.output;
    + const tokens = previous && previous.tokens && (previous.tokens.input + previous.tokens.cache.read + previous.tokens.cache.write + previous.tokens.output);
    + const tokensRemaining = model.info.limit.input - tokens;
    + if (tokensRemaining && tokensRemaining < outputLimit) outputLimit = tokensRemaining;
  5. added a commit that references this issue on Apr 7, 2026
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