[Bug] Mid-session model switch fails: `input[87]` missing required field `summary` (HTTP 400, non-retryable)
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
[Bug] Mid-session model switch to third-party model fails: input[87] missing required field summary (HTTP 400, non-retryable)
Summary
Switching models mid-session (GLM -> third-party model via an OpenAI-compatible proxy) makes every subsequent request fail with:
Upstream request failed: [invalid_request_error] `input[87]` missing required field `summary`
The failure happens at request time (iteration 0, before any generation) with HTTP 400 retryable: false, so retrying with the same payload fails identically. Starting a fresh session directly on the target model works fine, so the model/upstream itself is healthy — the problem is the request payload ZCode builds from cross-model conversation history.
Environment
- ZCode Desktop 3.11.2 (build 3.11.2.6792), macOS Apple Silicon
- Source model:
builtin:zai-coding-plan/GLM-5.3-Flash - Target model: custom provider
opencode-go, modelopencode-go/muse-spark-1.3-contributor, via local OpenAI-compatible proxyhttp://127.0.0.1:10100/v1(SSE transport)
Reproduction
- Start a session on GLM-5.3-Flash and hold a long conversation (in my case ~48 messages / ~196 parts, including tool calls and a few model switches back and forth).
- Switch model mid-session to the third-party model.
- Send any message -> immediate error banner:
TerminalStreamChunkError: Upstream request failed: [invalid_request_error] input[87] missing required field summary, stack pointing athandleStreamErrorEvent/runStreamTextinresources/glm/zcode.cjs. - Retrying fails the same way; only a fresh session on the target model works.
Evidence (from ~/.zcode/cli/log/zcode-2026-09-17.jsonl)
session.model.updatedat2026-09-17T03:35:29Z:GLM-5.3-Flash -> opencode-go/opencode-go/muse-spark-1.3-contributor- First failure at
2026-09-17T03:37:25Z(turnNumber: 4, iteration: 0— fails on the first request of the turn, i.e. payload validation, not generation):model.request.failed:reason: invalid_request, retryable: false, statusCode: 400, statusMessage: Upstream request failed: [invalid_request_error] input[87] missing required field summaryturn.failedwithAiSdkModelAdapterError/ProviderBusinessError,responseStatus: 400, providerKind: openai-compatible
- Second identical failure at
2026-09-17T03:38:30Zon the next attempt (requestIdsfe2cfbc0-…anda9132c71-…).
Analysis (my read, for triage)
summary is a field on reasoning-type items in the Responses API shape. After a mid-session switch, ZCode replays the full history — including the previous model's reasoning blocks — into input[]. Item 87 (a reasoning block from the GLM side, which carries no summary in the form the new target expects) fails the target's strict validation. Because it is a 400 non-retryable error, the retry loop correctly gives up — but the user is left with a permanently broken session and no in-app recovery path.
Suggested fix
When building the Responses input[] after a model switch (or whenever history contains reasoning items from a different model family), sanitize cross-model history: drop reasoning items that lack the target-required summary field, or convert them to plain text/context items the target accepts — same class of fix as the existing attachment handling on model switch (#188). Alternatively, warn before switching when the history contains incompatible blocks, or offer one-click "compact & switch".
Workaround (for other users hitting this)
Do not switch to the new model mid-session — start a new task/session directly on the target model. If you must switch, compact/summarize or rewind first to drop raw reasoning blocks.
Logs
Relevant log lines and request IDs above; happy to provide the full excerpt or a diagnostic archive on request.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with resources/glm/zcode.cjs, especially the request path around runStreamText and error handling in handleStreamErrorEvent. Reproduce the mid-session model switch using the provided history and logs, then trace how reasoning items enter the Responses input; done means the target model accepts the request after switching without breaking existing history behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100