[GH-ISSUE #545] Error: 400: {"type":"invalid_request_error","message":"prompt (38963 tokens) + max tokens (226281) exceeds the context (262144); requests are never truncated"} #259

Closed
opened 2026-11-04 01:41:24 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @avarakin on GitHub (Oct 2, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/545

Getting stuck with this error even after compacting. Increasing context does not help. I am using Pi.dev 1.0 harness. This issue does not happen with qwen 3.8 27b. Machine has 16g VRAM and 64g RAM.

Originally created by @avarakin on GitHub (Oct 2, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/545 Getting stuck with this error even after compacting. Increasing context does not help. I am using Pi.dev 1.0 harness. This issue does not happen with qwen 3.8 27b. Machine has 16g VRAM and 64g RAM.
Author
Owner

@Niko1221 commented on GitHub (Oct 3, 2026):

Thanks. Pi asked for 226,281 output tokens on a 38,963-token prompt. Together that is about 3K over the 262,144-token context, and the server refuses such a request instead of cutting anything. Pi bases the output size on its context setting, so a larger context doesn't help. Two ways around it:

  • add "fit_max_tokens": true to the model's strata-<model>.json in the Strata folder and restart. The server then shortens max_tokens to the room that's left;
  • or give the model a smaller max output in Pi's model settings (e.g. 32768).

From 0.1.38 the error message itself says this and gives the largest max_tokens that fits.

<!-- gh-comment-id:5964029432 --> @Niko1221 commented on GitHub (Oct 3, 2026): Thanks. Pi asked for 226,281 output tokens on a 38,963-token prompt. Together that is about 3K over the 262,144-token context, and the server refuses such a request instead of cutting anything. Pi bases the output size on its context setting, so a larger context doesn't help. Two ways around it: - add `"fit_max_tokens": true` to the model's `strata-<model>.json` in the Strata folder and restart. The server then shortens `max_tokens` to the room that's left; - or give the model a smaller max output in Pi's model settings (e.g. 32768). From 0.1.38 the error message itself says this and gives the largest `max_tokens` that fits.
Author
Owner

@avarakin commented on GitHub (Oct 3, 2026):

I added the parameter but still not able to open problematic session. I am able to open it with another qwen model and llama.cpp

<!-- gh-comment-id:5964466820 --> @avarakin commented on GitHub (Oct 3, 2026): I added the parameter but still not able to open problematic session. I am able to open it with another qwen model and llama.cpp
Author
Owner

@avarakin commented on GitHub (Oct 3, 2026):

one more thing: looks like it happens after compaction. I manually requested pi to compact, compact was successful, but after that i started getting this error and was not able to re-open session

<!-- gh-comment-id:5964495291 --> @avarakin commented on GitHub (Oct 3, 2026): one more thing: looks like it happens after compaction. I manually requested pi to compact, compact was successful, but after that i started getting this error and was not able to re-open session
Author
Owner

@avarakin commented on GitHub (Oct 3, 2026):

Never mind, it worked. I applied the change incorrectly.

<!-- gh-comment-id:5965108801 --> @avarakin commented on GitHub (Oct 3, 2026): Never mind, it worked. I applied the change incorrectly.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#259
No description provided.