Skip to content

context overstated #447

Closed
Closed

Description

@dmt4

I just noticed this, significant overstatement of the context used, way over the actual supported by the model instance:

Image

Despite it, the model does behave well, has sensible, coherent output.

Also note how the max length is reported as 200k when the /v1/models does provide some info to say it is 256k:

curl http://[::1]:8078/v1/models
{"models":[{"name":"unsloth/gemma-4-31B-it-UD-Q8_K_XL","model":"unsloth/gemma-4-31B-it-UD-Q8_K_XL","modified_at":"","size":"","digest":"","type":"model","description":"","tags":[""],"capabilities":["completion","multimodal"],"parameters":"","details":{"parent_model":"","format":"gguf","family":"","families":[""],"parameter_size":"","quantization_level":""}}],"object":"list","data":[{"id":"unsloth/gemma-4-31B-it-UD-Q8_K_XL","aliases":["unsloth/gemma-4-31B-it-UD-Q8_K_XL"],"tags":[],"object":"model","created":1783253170,"owned_by":"llamacpp","meta":{"vocab_type":2,"n_vocab":262144,"n_ctx":262144,"n_ctx_train":262144,"n_embd":5376,"n_params":30697345596,"size":35004205296,"ftype":"Q8_0"}}]}

The provider was added with:

jcode provider add local --base-url http://[::1]:8078/v1 --no-api-key -m "unsloth/gemma-4-31B-it-UD-Q8_K_XL" --set-default

commit: 7d5e840

Activity

  1. added
    bug
    priority: medium
    triage: fixed-pending-release
    autonomous: likely
    on Jul 6, 2026
  2. 1jehuang commented on Jul 6, 2026

    @1jehuang
    Owner

    Triage: two separate things in this report.

    Max window misreported as 200K (fixed). llama.cpp's /v1/models reports the serving context only inside meta (n_ctx / n_ctx_train), which jcode's catalog parser did not read, so your 256K model fell back to the generic 200K default. Fixed on master in 60c1901: the parser now falls back to meta.n_ctx (then n_ctx_train), with a test using your exact /v1/models response shape. After the next release your model should report 262,144.

    Note you can also pin it explicitly today via a named provider profile:

    [[providers.local.models]]
    id = "unsloth/gemma-4-31B-it-UD-Q8_K_XL"
    context_window = 262144

    Usage overstatement (needs more info). The screenshot shows usage well above the real window while output stays coherent. That figure comes from provider-reported stream usage; if llama.cpp is doing its own context shifting/truncation, cumulative token counts can exceed the window. If this persists after the release with the corrected window, could you share what usage the server returns on a long turn (e.g. prompt_tokens) so we can tell whether it's a server-side cumulative count vs a jcode aggregation bug?

    Will close the window-detection part automatically on the next release.

  3. 1jehuang commented on Jul 7, 2026

    @1jehuang
    Owner

    Released in v0.37.0. Run jcode update to get it.

  4. removed
    triage: fixed-pending-release
    on Jul 7, 2026
  5. akohlsmith commented on Jul 28, 2026

    @akohlsmith

    This does not appear to work.

    [[providers.rapidmlx.models]]
    id = "mlx-community/phi-4-4bit"
    context_window = 16384
    
    $ jcode --provider-profile rapidmlx --model mlx-community/phi-4-4bit run 'hello'
    
    Error: OpenAI-compatible chat request failed
      endpoint: http://192.168.78.78:8000/v1/chat/completions
      model: mlx-community/phi-4-4bit
      auth: JCODE_PROVIDER_MY_API_API_KEY
      status: 400 Bad Request
      response: {"error":{"message":"This model's maximum context length is 16384 tokens. However, you requested 33535 tokens (767 prompt + 32768 completion). Please reduce the length of the messages or completion.","type":"invalid_request_error","code":"context_length_exceeded","param":"messages"}}
    Hint: check network connectivity, DNS/TLS, that the base URL includes the API version (usually /v1), and that the model exists on the provider.
    

    The rapid-mlx server at 192.168.78.78:8000 shows it's returning a 400 Bad Request

    I used jcode provider add rapidmlx --base-url http://192.168.78.78:8000/v1 --model mlx-community/phi-4-4bit --no-api-key --set-default --context-window 16384 to create the config.toml entry.

    I'm sure I'm holding this wrong, but I'm not sure how.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: likelybugpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions