Skip to content

OpenRouter models: 32k tokens a call, and a call cut off at its limit is told to the model and retried - #382

Merged
hkonsti merged 2 commits into
mainfrom
glm-output-budget
Nov 21, 2026
Merged

hkonsti merged 2 commits into
mainfrom
glm-output-budget

Conversation

@hkonsti

@hkonsti hkonsti commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

A turn on the proxy harness (OpenRouter) gave the model 4,000 output tokens per call. That's too little for agentic work: about 300 lines of code, and for GLM its thinking came out of the same budget. Also, if the model was cut off at the limit, the turn quietly dropped the unfinished answer and any tool calls in it, and the person saw the stock "I had nothing to say to that." Thread cmwqu03k7002sqx01wxxavvcl hit this: 5,712 tokens in, exactly 4,000 out, no text and no calls. Over the last 14 days, all 8 GLM turns that hit the cap ended this way, and none of the 12 steps that hit the cap on either model had a tool call left.

  • 32,000 output tokens per call for both OpenRouter models. proxy-harness.ts has a budget per model: Claude Sonnet 5.5 gets 32,000, and so does GLM 5.3, with reasoning.max_tokens 16,000 sent to OpenRouter (TurnRequest.reasoningTokens) so at least half is left for the answer. Room that goes unused costs nothing. The summarizing call uses the same budget.
  • Timeout per call raised from 120 s to 600 s, because a 32k answer takes minutes. The worker renews the job's lease every 30 s, so a long call keeps its job.
  • A cut-off call is reported to the model as an error it can act on. askForTurn reads finish_reason and sets ModelTurn.cutOff when it is length. The harness then asks the model again in the same turn (up to 2 more times). It passes back any text the model had written, plus a note: its last answer was cut off and dropped, none of its calls ran, and it should think less or write a large file in parts. The tool calls of a cut-off answer are dropped, since the last one may be incomplete. The turn's outputTokens counts every call; its inputTokens is the last call's, since compaction reads it as the size of the log.
  • If every try is cut off, the person is told "I kept running out of room: GLM 5.3 stops at 32,000 tokens an answer, and I was cut off 3 times before I could finish. Say something to try again, or switch this thread to another model." That comes after any text the model wrote, instead of the stock line.

Tests: proxy-harness, open-router, inference and worker tests pass (76). tsc --noEmit passes for the api.

…e model ran out of room where it was cut off before it said anything, rather than that it had nothing to say
… ask a model cut off at its limit again, told so, before telling the person it ran out of room
@hkonsti hkonsti changed the title GLM: a bigger output budget with thinking capped, and say when a turn ran out of room OpenRouter models: 32k tokens a call, and a call cut off at its limit is told to the model and retried Nov 21, 2026
@hkonsti
hkonsti merged commit 5b38f1e into main Nov 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant