GeezerVison is showing github.com — Sub-agent Task silently returns empty result when the final response stream fails (e.g. 503) — no error, no retry, completed work lost · Issue #40527 · anomalyco/opencode
Sub-agent Task silently returns empty result when the final response stream fails (e.g. 503) — no error, no retry, completed work lost #40527DescriptionDescription
When a sub-agent (Task) finishes all its tool work but its final response stream then
fails — e.g. server [503] The request queue is full — the parent Task call returns an
empty result. No error is surfaced and no retry happens; the sub-agent's completed work
is silently discarded.
Reproduced on two explore sub-agents in one parent session (opencode 1.18.13). Both
completed 64 and 52 tool calls (data mining against a 151 MB DB), then hit [503] on
their last message (msg_fce23bb9..., msg_fce2648...). Both returned an empty
<task_result> to the parent. The work was only recoverable by re-extracting the
sub-agents' persisted tool outputs directly from opencode.db.
This is the known 503/free-tier overload family (#40254, #38051, #39276). The client-side
part I'm reporting is that a Task whose final stream dies should surface the stream error
to the parent (and/or retry), not return a success-looking empty result.
Plugins
@cortexkit/opencode-magic-context (context management); GitHub MCP; atomic-updater MCP
OpenCode version
1.18.13
Steps to reproduce
- Start a Task (subagent) with a long multi-tool mining workload (many sqlite3/bash calls).
- Hit a provider overload window so the final response stream fails with
[503] ....
- Observe: sub-agent completes all tool calls, final stream errors, sub-agent result is empty.
- Parent receives empty result; no error shown; no retry; the mined data appears lost.
Screenshot and/or share link
No response
Operating System
Linux (Qubes OS 4.2.4) - Under Fedora (FC37) Standalone VM
Terminal
OpenCode TUI (CLI) - under Konsole Activitygithub-actions commented on Aug 4, 2026 This issue might be a duplicate of (or closely related to) existing issues. Please check:
Your issue adds a specific and well-documented angle: the final-stream failure path returns an empty success result rather than propagating the error to the parent. That distinction may warrant keeping this open alongside the others, but reviewing those issues first may be useful. InCerryGit commented on Aug 6, 2026 I can reproduce the same state-propagation issue with a provider timeout on OpenCode 1.18.14.
The child session records:
UnknownError: The operation timed out.
However, the parent Task tool returns:
<task id="[redacted]" state="completed">
<task_result></task_result>
</task>
As a result, the orchestrator treats the task as successfully completed, does not retry it, and may create a fresh child session without the previous context. In this reproduction, the failing provider request timed out after exactly 240000 ms.
Expected behavior: propagate the child error as state="error" with <task_error>, while preserving the child session ID and enough error metadata for an explicit retry/resume.
All session, message, call, filesystem, provider endpoint, project, and business identifiers have been omitted or redacted. octal-illumination commented on Aug 22, 2026 Adding corroborating evidence from the same incident window I reported (opencode 1.18.13, same parent session, same free-tier model) — including a third failure shape, a four-parallel-Tasks natural experiment, and a note on ecosystem impact. All data below re-verified from opencode.db and the server log before posting.
1. Both agents cited in this report, re-verified from opencode.db + server log
| Agent |
Session |
DB tool calls (type=tool parts) |
step-finishes |
Final assistant message |
A (msg_fce23bb9…) |
ses_031eaedbbffeEjxvDpqGp0yMtk |
83 across 66 messages |
63 |
finish=None, tokens all zero |
B (msg_fce26482…) |
ses_031eb06bfffeejbxJuDWh4fV3p |
68 across 54 messages |
51 |
finish=None, tokens all zero |
Server log lines for both final-stream failures:
[2026-08-04T18:58:11.794Z] level=ERROR … session.id=ses_031eaedbbffeEjxvDpqGp0yMtk
messageID=msg_fce23bb910017v72P1qA1lFM0E error="Streaming resp[onse failed …]"
[2026-08-04T19:00:54.477Z] level=ERROR … session.id=ses_031eb06bfffeejbxJuDWh4fV3p
messageID=msg_fce2648200013LmnkcXvUN98qY error="Streaming response failed: [503] …"
(Note: my part-count method yields 83/68 vs the 64/52 in my original report — likely synthetic/partial-part accounting differences; the lost-work conclusion is unaffected.)
2. Correction and expansion: it wasn't two agents — the parent dispatched four parallel Tasks, three of them emptied
Reconstructing the dispatch from opencode.db: the parent fired four explore Tasks in a single assistant message (msg_fce149fc4002…, tool=task ×4). My original report cited two of them; here is the full picture:
| Child session |
Assignment |
Outcome |
ses_031eb06bfffe… |
mine qubes-mtp-android sessions |
EMPTY [503] on final stream |
ses_031eaedbbffe… |
mine content from magic-context db |
EMPTY [503] on final stream |
ses_031ead306ffe… |
mine compartments + events |
EMPTY — no logged error at all; finish="unknown" after 795 output tokens |
ses_031eab693ffe… |
mine memories + memory_verifications |
✅ SUCCESS — 11,221-character <task_result> delivered |
The fourth sibling is the decisive control: identical prompt shape, identical dispatch batch — and the wrapper demonstrably carries non-empty results when the child produces them. Emptiness is a per-child failure outcome, not a wrapper or dispatch artifact.
3. Third failure shape: abnormal stream end with NO logged error
Child ses_031ead306ffe… never produced an explicit stream error at all:
- 40 stream requests, 18:42:05Z → 18:55:53Z; zero ERROR/WARN lines for this session
- final assistant message:
finish="unknown", output truncated at 795 tokens, prompt ~100,890/200,000
- parent received the identical silent wrapper:
<task id="…" state="completed"><task_result></task_result></task>
(finish=None in agents A/B means the stream died at the transport layer before any finish reason existed; this child instead recorded OpenCode's literal fallback value "unknown" — both mean no provider-declared completion.)
So empty-success wrapping isn't limited to caught exceptions ([503], timeouts): an abnormally terminated stream that delivers no finish_reason at all produces the same silent loss.
4. Consolidated failure shapes hitting this bug
- Explicit provider error on final stream ([503]/5xx family — this report; cf. 502
provider_unavailable errors from OpenRouter are not retried, causing subagent/session aborts #22448)
- Provider timeout after N ms (@InCerryGit's reproduction —
UnknownError after 240000 ms)
- Abnormal stream end with no delivered
finish_reason, and no logged error (this evidence)
5. Suggested propagation rule
Treat a child Task as errored unless it terminated cleanly — propagate state="error" + <task_error> when any of:
- the child recorded a stream/provider error, or
- the child's terminal state is not attributable to a normal completion (
finish_reason absent/unknown), or
- the child's final assistant message has zero text parts while tool calls succeeded.
Preserving the child session id + error metadata (as @InCerryGit also proposed) makes explicit retry/resume straightforward. Related, as the triage bot noted: #32132, #22448.
6. Ecosystem impact note
cortexkit/magic-context#270 is the plugin-side twin of this incident (same evening, same parent); its maintainers shipped a defensive warning for exactly this silent-empty wrapper in v0.39 (extracted from their PR #337) because the host propagates these as success. A host-level fix would let that workaround retire — one more reason this report matters. thdxr commented on Oct 11, 2026 Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|