LM Studio, Qwen 3 Coder, MacOS: ERROR: The number of tokens to keep from the initial prompt is greater than the context length. #1498

Closed
opened 2026-02-16 17:31:16 -05:00 by yindo · 2 comments
Owner

Originally created by @RokitDan on GitHub (Aug 26, 2025).

When trying to run /init inside of my vue project, local instance of Qwen 3 running via LM Studio does not respond. Running opencode run "Hi" --print-logs in terminal returns:

ERROR 2025-08-26T18:34:58 +5ms service=default name=TypeError message="The number of tokens to keep from the initial prompt is greater than the context length. Try to load the model with a larger context length, or provide a shorter input" is not an Object. (evaluating '"name" in input') fatal

Here is my opencode.json:

Image

Here is token settings for Qwen3 in LM Studio

Image
Originally created by @RokitDan on GitHub (Aug 26, 2025). When trying to run /init inside of my vue project, local instance of Qwen 3 running via LM Studio does not respond. Running opencode run "Hi" --print-logs in terminal returns: ERROR 2025-08-26T18:34:58 +5ms service=default name=TypeError message="The number of tokens to keep from the initial prompt is greater than the context length. Try to load the model with a larger context length, or provide a shorter input" is not an Object. (evaluating '"name" in input') fatal Here is my opencode.json: <img width="517" height="346" alt="Image" src="https://github.com/user-attachments/assets/cb126479-c6d1-42b6-8cf8-29f51bfec5ad" /> Here is token settings for Qwen3 in LM Studio <img width="459" height="458" alt="Image" src="https://github.com/user-attachments/assets/f5ddee93-123e-4354-a559-8ce3de8c5628" />
yindo closed this issue 2026-02-16 17:31:16 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 26, 2025):

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

  • #1551: Similar context length error with Qwen 3 Coder 480b model - "Please reduce the length of the messages or completion. Current length is 69553 while limit is 65536"
  • #423: LM Studio token counting issues - "Context usage count is always 0 for some local openai-compatible providers"
  • #1212: Context window limit exceeded with automatic truncation suggestions
  • #1735: Issues with max_tokens being set too high for custom providers like LM Studio

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Aug 26, 2025): This issue might be a duplicate of existing issues. Please check: - #1551: Similar context length error with Qwen 3 Coder 480b model - "Please reduce the length of the messages or completion. Current length is 69553 while limit is 65536" - #423: LM Studio token counting issues - "Context usage count is always 0 for some local openai-compatible providers" - #1212: Context window limit exceeded with automatic truncation suggestions - #1735: Issues with max_tokens being set too high for custom providers like LM Studio Feel free to ignore if none of these address your specific case.
Author
Owner

@RokitDan commented on GitHub (Aug 26, 2025):

From looking at another issue, it seems that context limits need to be added to opencode.json and the context in LM Studio needs to be greater than or equal to the context limit in opencode.json

Image Image
@RokitDan commented on GitHub (Aug 26, 2025): From looking at another issue, it seems that context limits need to be added to opencode.json and the context in LM Studio needs to be greater than or equal to the context limit in opencode.json <img width="563" height="466" alt="Image" src="https://github.com/user-attachments/assets/c4b699c5-2298-4d0c-be76-33c76dbd768d" /> <img width="445" height="554" alt="Image" src="https://github.com/user-attachments/assets/f8e8b7df-7496-42d5-adcb-826a7f59bd0f" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1498