GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||
GeezerVison is showing github.com — fix(ai): keep an unencodable tool result from killing the session by HX-Wrdzgzs · Pull Request #60604 · anomalyco/opencode Conversation
|
| Arm | Build | Outcome |
|---|---|---|
| A | desktop 2.2.3 + plugin 1.9.5 (stock) | Failed to drain Session, SchemaError: Expected a JSON-serializable value, 4.18 s after process spawn |
| B | desktop 2.2.5 + plugin with the shape fix | the stuck production session resumes and the turn completes: idle_outcome=succeeded |
Arm A, verbatim from the log (ses_e7278d6dbffeKZzMxPMByoGqy9):
timestamp=2026-10-30T15:56:44.495Z level=INFO message="spawning process" ...
timestamp=2026-10-30T15:56:48.676Z level=ERROR message="Failed to drain Session"
cause="SchemaError: Expected a JSON-serializable value
at OpenAIChat.fromRequest
at LLM.compile
at SessionStep.attempt
at SessionRunner.runStep
at SessionRunner.drain"
Arm B: the affected session (ses_e72dcf6ceffdGeH4rfE7YGdhMa) had been left idle_outcome='failed' at 128 messages. After replacing only the plugin's pruning file, the same session resumed on 2.2.5 and finished at 133 messages with idle_outcome='succeeded'; it then kept running to 232 messages, with zero Failed to drain in the monitoring window.
Why the stock 2.2.5 build does not reproduce it on its own: the pruning layer only rewrites results once context passes 70%. Our 2.2.5 runs stayed below the threshold (prune_checked=313 / below=313 / pct=68%, and checked=33 / pct=35%), so no malformed part was ever written. On 2.2.3 the same plugin pruned 2,363 parts / 1.68 M tokens in one session. The trigger is "pruning fires", not the 2.2.3 → 2.2.5 difference.
The same plugin also wrote tool-call.input as a bare string; the fixed build keeps both envelopes (result: {type, value} and input: {…}), which is what toolResultText and the protocol adapters expect.
The bun run test / bun run typecheck numbers quoted above were taken on the original two-commit branch. This branch has since been rebased onto a66964e and extended with two commits from @Te-River's construct-side work, and bun is not available in my environment. At the current head, verification is tsc --noEmit -p packages/ai/tsconfig.json → exit 0, plus a static check that every existing assertion touching toolResultText / toResultValue still holds. The full suite needs CI.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Your two changes match where I landed on a fork branch, so I won't duplicate them. Three pieces from that branch are not here (
Happy to split these into a PR against your branch if that is easier than cherry-picking. I cannot open one from my account — this repository caps the number of open pull requests it will accept from it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Protocol lowering called encodeJson on json tool results without a guard, so
`{ type: "json", value: undefined }` — what ToolOutput.toResultValue produces
when a tool returned undefined and produced no content parts — threw
`Expected a JSON-serializable value`. That throw is a defect: nothing reaches
the wire, and it unwinds through SessionStep.attempt into SessionRunner.drain,
so every later turn on that session fails the same way.
- toolResultText now sends json results through Schema.encodeUnknownOption and
falls back to String(value), the same guard schema/messages.ts already applies
to text results. Values that are JSON still encode exactly as before.
- LLM.compile converts a non-interrupt cause into a typed AIError through
streamError, so a lowering bug fails one step instead of the whole session.
Interrupts are re-raised untouched and an AIError already in the cause is
returned as-is.
28d420c to
8332a7b
Compare
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
SchemaError: Expected a JSON-serializable value while compiling an OpenAI Responses request fatally kills the session
There was an error while loading. Please reload this page.