GH-2409: fix(executor): OpenCode response parsing decodes wrong fields — silent empty Output#2412
Merged
alekspetrov merged 1 commit intomainfrom Apr 26, 2026
Merged
GH-2409: fix(executor): OpenCode response parsing decodes wrong fields — silent empty Output#2412alekspetrov merged 1 commit intomainfrom
alekspetrov merged 1 commit intomainfrom
Conversation
…2409) OpenCode's POST /session/:id/message returns application/json with {info: AssistantMessage, parts: Part[]}, not {success,output,error}. The previous decoder pulled three nonexistent fields, then defaulted Success=true on empty Error — surfacing a successful run with empty Output and breaking downstream commit / PR creation silently. Map the real shape: concatenate text parts into Output, surface tool/step parts as BackendEvents through opts.EventHandler, and pull token usage / model / sessionID from info. Synthesize a final EventTypeResult so consumers see a terminal event matching the SSE path.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automated PR created by Pilot for task GH-2409.
Closes #2409
Changes
GitHub Issue #2409: fix(executor): OpenCode response parsing decodes wrong fields — silent empty Output
Summary
After PR #2408 lands, the schema rejection at first send is gone, but
OpenCodeBackend.sendMessagethen mis-parses the success response. Pilot will seeSuccess: truewith emptyOutput, leading to no commit / empty PR / silent failure downstream.Evidence (verified against OpenCode v1.4.6 source)
packages/opencode/src/server/instance/session.ts:854-895:So the success response is:
Content-Type: application/json(nottext/event-stream— theAccept: text/event-streamheader sent by Pilot is ignored){info: MessageV2.Assistant, parts: MessageV2.Part[]}Pilot's current parse path (
internal/executor/backend_opencode.go:243-256):None of
success/output/errorexist on OpenCode v1.4.6's response. All three decode to zero values →result.Output = \"\"→ finalSuccess = true(because Error is empty).Impact
runningrather thanfailureafter PR fix(executor): support modern opencode message schema #2408 → the HTTP call succeeds but Pilot extracts no useful content.Output, no commit, autopilot sees nothing to push.Fix (sketch)
Map the actual response shape:
Then concatenate text parts into
result.Output, surface tool-use parts asBackendEvents viaopts.EventHandler(mimicking the streaming path), and pull token usage frominfo.Alternative: switch to
POST /session/:sessionID/prompt_async(returns 204 immediately) and consume the SSE event stream from/eventfor per-token deltas. That endpoint actually streams; the current synchronous/messageendpoint never does despite the misleadingdescription: \"...streaming the AI response\".Repro (post #2408)
References