#qwen context fix

1 messages ยท Page 1 of 1 (latest)

lethal flume
#

I found the exact issue hiding in your logs. You successfully switched to Qwen, disabled the hooks, and cleared the background processes, but you are now hitting a Context Overflow Error from OpenRouter.

Here is the smoking gun from your log at 13:31:18:

400 This endpoint's maximum context length is 262000 tokens. However, you requested about 278905 tokens (7935 of text input, 8970 of tool input, 262000 in the output).

Why is this happening?
By default, OpenClaw is "greedy." It sees that Qwen3 Coder has a massive ~262k context window, so it tells OpenRouter, "Hey, reserve 262,000 tokens specifically for my output answer."

However, OpenRouter does the math: Input (~16k) + Requested Output (262k) = 278k. Since 278k is larger than the 262k total limit, OpenRouter instantly rejects the API call, and OpenClaw hangs trying to process an incomplete response.

The Fix: Cap the Output Tokens
We need to tell OpenClaw to only request a sensible amount of output tokens (like 8,192) so there is plenty of room left in the context window for your input files and tool schemas.

Run this command to patch your model configuration:

worldly swallowBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> โœ… Mark Solution

ember dawnBOT
# lethal flume I found the exact issue hiding in your logs. You successfully switched to Qwen, ...

Small correction after checking current docs/source: the knob to cap requested output is maxTokens, usually as per-model agent params. contextTokens caps the effective context budget/reporting, but it is not the output-token cap.

Try this, replacing the model key with the exact one shown by openclaw models / openclaw status if yours differs:

openclaw config set agents.defaults.models '{"openrouter/qwen/qwen3-coder":{"params":{"maxTokens":8192}}}' --strict-json --merge
openclaw gateway restart

If the active model is already listed under agents.defaults.models, this merge should preserve the entry and add the output cap. I would avoid trying to lower models.providers.*.models[].maxTokens as the first fix, because provider catalog merge logic can preserve the larger built-in/catalog value. Agent params are the cleaner override for this case.

Docs refs:
https://docs.openclaw.ai/cli/config
https://docs.openclaw.ai/gateway/configuration
https://docs.openclaw.ai/concepts/model-providers

If it still errors, please share openclaw --version plus the safe output of: