Skip to content

Studio: an OpenCode wake-up names its own subagent and a failed subagent ends failed (#779) - #791

Merged
danielrispler merged 4 commits into
mainfrom
issue-779-studio-an-opencode-wake
Nov 28, 2026
Merged

danielrispler merged 4 commits into
mainfrom
issue-779-studio-an-opencode-wake

Conversation

@danielrispler

@danielrispler danielrispler commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Closes #779.

Summary

The OpenCode plugin now reads OpenCode's inbox, so a wake-up says whose results its turn took, and a subagent ends with the status its result reports.

 plugin: session.execution.started (no prompt) = wake-up
-  send at once                         # core names it by the latest event: often the wrong child
+  hold it until the turn's first step  # OpenCode delivers results before that step
+  session.inbox.delivered → add {subagent_session_id, state} to its `reported`
+  a result delivered later in the turn → its own `session.inbox.delivered` line
+  shell / image / video / Code Mode job results → not sent
 core: OpenCode line
+  reported → Happened::TasksReported   # the existing path: error → failed, cancelled → interrupted
 turn_start(wake-up)
-  Sender::WakeUp(woken_by())           # latest-event guess
+  told (wake-up + reported + not late) → Sender::WakeUp(first reported)
+    turn label: "worker B returned" | "workers A and B returned" | "background job returned"
+  late wake-up → leaves the running turn's label and row name
+  no `reported` (logs from before this) → woken_by(), as today
  • Turn.results_of is saved but left out of the pane's JSON. The saved-state FORMAT goes 9 → 10, so the first launch replays the whole log once.
  • Claude's and agy's wake-up labels are unchanged. The wake_ups.rs test now pins Claude's.
  • Docs: the OpenCode section of docs/studio/plugin.md is rewritten, and the open-race sentence is gone. The research note docs/studio/research/opencode-background-results.md is committed and cited. The Wake-up entry in docs/studio/CONTEXT.md now covers OpenCode. system-map.json didn't need a change (system-map check ok).

Tests: none removed. wake_ups.rs's a_wake_up_from_a_task_with_no_subagent_names_it_by_its_short_id became a table, with one row for one task and one for two tasks.

Evidence

  • Before: opencode::a_wake_up_names_the_subagents_whose_results_its_turn_took_and_each_ends_with_its_status, 8 rows. On main:
    • B's result names A, because A has the latest event.
    • A child whose result says error ends completed.
  • After: all 8 rows pass:
    B alone                        → "worker B returned"; A, B completed
    A error + B cancelled          → "workers A and B returned"; A failed, B interrupted
    A joins the running wake-up    → "workers B and A returned"
    shell job only                 → "background job returned"
    log from before #779           → "worker A returned" (fallback, unchanged)
    result into Daniel's turn      → his prompt kept; child ends interrupted
    result after child's own end   → child still ends failed
    late wake-up                   → turn label and row name stay "worker B returned"
    
  • ui/tests/opencode-plugin.test.mjs (new) loads the rendered plugin with a fake OpenCode and a fake hook. It checks the held wake-up and its reported list, the later inbox.delivered line and the shell filter.
  • npm run check passes on the branch merged with main: 1959 Rust tests, plus 835 Node tests with 834 passed, 0 failed and 1 skipped.
  • Merged main in to pick up Studio: an OpenCode session shows its context size (#719) #787 (Studio: an OpenCode session shows its context size #719, OpenCode context size), which touches the same files. The resolution: a top-level turn's end goes through the recorder's r.send, so it goes out after its held wake-up, and it carries context_tokens. The .step.ended branch sits beside the new .step.started flush. plugin.md keeps both sections, and the fixture list includes context.jsonl.
  • The three server tests that went red on main on 2026-11-28 (a dated fixture aging out of the 30-day prune) are fixed by Studio: the server tests give the log's prune a fixed clock (#792) #793 (Studio: the server tests' recorded log ages out of the prune 30 days after its last line #792).

Outside review

  • Model: gemini-4-neon-medium.
  • cost: 4.3 min, 234015 tokens; Gemini quota left: weekly 54% to 53%, 5h 100% to 96%
  • Fixed: a late OpenCode wake-up fell through to Sender::WakeUp(woken_by()) and overwrote the row's "worker … returned" on the running turn (core/src/studio/take.rs).
    • I confirmed it with a new row-name assertion in the table test: the late row went red (Some("worker A returned") against Some("worker B returned")), then green.
    • The correctness pass had already fixed the turn-label half of this bug. It had not caught the row-name half.

Merge Danger

Door: two-way. Saved state moves to FORMAT 10, and both builds reject the other's file by its header and replay from the log. The plugin's new fields and lines are ignored by an older core.

Blast Radius: OpenCode sessions only. That covers wake-up labels, the row's returned text, and subagents ending failed or interrupted. No real run has shown an error or cancelled result yet; those states come from OpenCode's source and tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CVqACdVnKiSXskgVojtEiA

danielrispler and others added 3 commits November 28, 2026 04:33
…, and a failed one ends failed (#779)

The plugin reads OpenCode's inbox: a subagent's result (`session.inbox.enqueued`,
`metadata.source` "subagent") delivered into a turn (`session.inbox.delivered`).
It holds a wake-up until its turn's first step and sends it with the results the
turn took (`reported`); a result delivered later goes on a line of its own.
Shell and other jobs' results are not sent.

The core reads `reported` as `TasksReported`: each child ends with its result's
status (`error` failed, `cancelled` interrupted), over its status-less run end,
and a wake-up names every child it took, "workers A and B returned", or
"background job returned" for none. A result in a turn Daniel prompted leaves
his prompt. A log from before has no `reported` and replays as before.

Research: docs/studio/research/opencode-background-results.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CVqACdVnKiSXskgVojtEiA
A wake-up the hook took late no longer renames the running wake-up's turn; its
children still end with their results' status. The plugin keeps only results
that name their child. plugin.md says a child that reports again after later
work ends again with its new status, and CONTEXT.md's Wake-up covers OpenCode's.
Turn.woken_by is renamed results_of, apart from Session::woken_by.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CVqACdVnKiSXskgVojtEiA
)

The outside review found that a wake-up the hook took late still set the
row's "worker … returned" from the latest-event fallback. The table test now
checks the row's name too; the late row went red, then green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CVqACdVnKiSXskgVojtEiA
Resolves #719's OpenCode context size (#787) with #779's held wake-up: a
top-level turn's end goes through the recorder's send, after its held
wake-up, and carries context_tokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CVqACdVnKiSXskgVojtEiA
@danielrispler
danielrispler merged commit fe10e6f into main Nov 28, 2026
13 checks passed
@danielrispler
danielrispler deleted the issue-779-studio-an-opencode-wake branch November 28, 2026 11:08
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.

Studio: an OpenCode wake-up names its own subagent and a failed subagent ends failed

1 participant