GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): subagents report to their parent every time they finish by kitlangton · Pull Request #61833 · anomalyco/opencode

Conversation

@kitlangton

@kitlangton kitlangton commented Nov 4, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

A subagent now tells its parent every time it finishes, including when someone prompts it again later, and waits for its own background work first.
Today only the subagent tool reports back, once, when the job it started ends. If you open a child session and type into it, or the parent re-prompts it, the parent never hears about the result.

This is the first of three stacked PRs:

  1. This one: core reports, the notify option, and holding a report until the child's background work is done.
  2. feat(core): run subagents in the background by default #62035: subagents run in the background by default (stacked on this one).
  3. feat(session): spawn subagent sessions and wait for their answer #62036: a spawn API and session.wait that returns the child's answer (stacked on feat(core): run subagents in the background by default #62035).

❌ Before

  1. The parent starts a subagent job.
  2. The job ends and the tool sends the parent one <subagent …> message.
  3. ❌ Anyone prompts the child again later: the parent gets nothing.
  4. ❌ A child that goes idle while its own background shell is still running reports too early, before the real result exists.

✅ After

  1. Any busy period of a child ends (succeeded, failed or cancelled).
  2. If the child still has background shells or subagents running, the report waits until they finish, then goes out once with the final state.
  3. Core sends the parent the same <subagent …> message, once for that busy period. A foreground call still gets the result inline, with no duplicate. notify: false on the child sends nothing, including after a restart.
- subagent tool: job finished -> notify parent (once, only for tool-started runs)
+ session core: child settled -> background work done? -> parent exists && notify != false && no one is blocking on it -> notify parent once for this busy period

📊 Proof

Case Before After
Child re-prompted after its job ended ❌ no report ✅ one report
Re-prompt overlaps the old job n/a ✅ one report per busy period
Child idle with a background shell running ❌ reports early ✅ reports after the shell exits
Silent child (notify: false) after a restart n/a ✅ stays silent
Server restarts mid-report n/a ✅ one report, not two
Server restarts while a report is held for background work n/a ✅ still reported once the work ends
Child re-prompted right after it reported n/a ✅ its own second report
Foreground call, child leaves a dev server running ✅ returns ✅ still returns; only a backgrounded job holds its report

159 tests pass across the seven touched test files.

🗄️ Migration: adds three nullable columns to session_v2 (held_report_id, held_report_at, held_report_answer) and a partial index, so a held report survives a restart. Additive only.

👀 Read: packages/core/src/session/execution/subagent-report.ts. The job observer, restart recovery and the settle path can all try to report the same busy period; each period is tied to its job's start generation, and they share one notification ID, so the first one wins. Held reports are stored on the child's row (session/store.ts), and execution/restart.ts recovers them through the same settle path a normal launch uses. The hold-until-background-done logic is in subagent-job.ts; it applies only once a job is backgrounded, so a foreground call still returns when the child stops. That file also handles releasing the nearest waiting ancestor through a chain of silent children. The rest is routine.

From a team design discussion · no user reports · prior art in #60360, #60618 and #57132 · reviewed before push

Checks run
  • bun test test/subagent-lifetime.test.ts test/subagent-report.test.ts test/session-store.test.ts test/job.test.ts test/session-execution.test.ts test/tool-subagent.test.ts test/database-migration.test.ts (packages/core): 159 pass
  • bun typecheck (packages/core): no type errors

Added by the opencode bot (AI-generated).

Fixes #48826

Related: #36349

Public API: adds optional notify input to the subagent tool and a subagent.notify session metadata key (backwards compatible)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kitlangton added 7 commits November 4, 2026 14:07
@kitlangton
feat(core): thread a subagent notify preference and job foreground vi…
6cb8aba
…sibility
@kitlangton
Flow: land sub-core-report.1 (split)
b6d7c82
@kitlangton
feat(core): report a settled subagent child to its parent from core
e5eb2f3
A child Session with a parent now sends one `<subagent ...>` synthetic to its
parent when its coordinator busy period settles, without the subagent tool
observing it.

- `SubagentReport` snapshots job state (blocked, get, recovery, remembered
  period) inside `settled` before the terminal publish, then maps the outcome
  to completed/error/cancelled and admits through a local inbox adapter that
  mirrors `Session.synthetic` (steer delivery, wake only a live, non-reverting
  parent). `execution.ts` gains `SessionInbox.node`; `Session.Service` stays out
  of the execution layer.
- Reports are keyed to the job's notification ID when a backgrounded live job
  owns the period, so the SubagentJob observer and restart recovery reconcile
  the same admission instead of adding a second message. A jobless period gets
  a fresh ID; a period whose job finished or was cancelled mid-flight stays
  silent because its observer already reported it.
- Suppressed for shutdown interruption (restart owns it), a missing child or
  parent, a silent child, a foreground block, a running job without a
  notification ID, and a period that finished without an assistant message.
- `SubagentCompletion.deliver` now takes a structural synthetic adapter, so the
  settle report does not need `Session.Service`. The report never calls
  `completeBackground`: the durable marker must outlive admission.
- `Job.Interface` gains a `recovery` reader; `Job.Info` deliberately keeps it
  out so snapshots cannot leak it.

The replay test in `tool-subagent.test.ts` now asserts the marker exists at
admission instead of being `completed`, because settlement admits while the job
is still running; it replays a completed row to model the crash it covers.
@kitlangton
test(core): cover the foreground subagent staying silent at settlement
d92f542
@kitlangton
Flow: land sub-core-report.2 (split)
a3d8aa1
@kitlangton
fix(core): stop restart from reporting a resumed subagent twice
9e51de2
@kitlangton
Flow: land sub-core-report.3 (split)
4fde589
@github-actions github-actions Bot added the contributor label Nov 4, 2026
kitlangton added 22 commits November 4, 2026 20:39
@kitlangton
fix(core): hold a subagent's report until its background work finishes
bd18108
@kitlangton
fix(core): retain pending notices and failed subagent outcomes
298f89c
@kitlangton
docs(core): clarify subagent settlement lifecycle
d009fc0
@kitlangton
fix(core): release a held subagent report when background work finish…
7e8c169
…es silently
@kitlangton
test(core): cover held subagent reports released after background work
5cea753
@kitlangton
docs(core): tidy held report comment
89e86ec
@kitlangton
fix(core): hold subagent report until child background work finishes
d6f276d
@kitlangton
fix(core): mark a held subagent report before querying pending work
3607880
@kitlangton
fix(core): release the nearest held ancestor through a silent subagen…
1b09066
…t chain
@kitlangton
test(core): cover silent subagent restart replay
b35b8d5
Restart recovery already clears a silent child's durable marker without
delivering a report. Pin that invariant: a suspended silent child resumed
after a restart never reports or wakes its parent, and replaying a silent
child's finished durable row admits nothing while still clearing the marker.
@kitlangton
test(core): pin silent subagent resume-exhaustion replay
5696f8e
A silent child whose resume budget is exhausted must clear its durable
marker without reporting an error to the parent.
@kitlangton
fix(core): tie subagent report ownership to the busy period's job gen…
3a385d6
…eration
@kitlangton
fix(core): bound a subagent report to its own busy period
749bb0f
Each busy period records where it began, on the clock that stamps event times, plus the child's newest answer at that moment. Settlement only reports an answer that completed during the period, excluding the starting answer by ID for millisecond ties and falling back to the timestamp alone when a committed revert deleted that row.
@kitlangton
feat(core): durable held subagent report storage
d181372
@kitlangton
fix(core): persist held subagent report ownership
8846c1a
@kitlangton
test(core): cover interruption during held report delivery
2be3290
@kitlangton
fix(core): recover durable held subagent reports after restart
23eb65c
@kitlangton
fix(core): preserve held report ownership for live foreground jobs
e406fd6
@kitlangton
fix(core): share recovered subagent settlement lifecycle
b910054
@kitlangton
test(core): reproduce dropped immediate subagent re-prompt reports
11d91d4
@kitlangton
fix(core): give subsequent subagent reports distinct identities
611fb8a
@kitlangton
Merge dev into pool-subagents
a1558e9
This was referenced Nov 5, 2026
feat(core): run subagents in the background by default #62035
Closed
feat(session): spawn subagent sessions and wait for their answer #62036
Open
@kitlangton
kitlangton marked this pull request as ready for review November 5, 2026 09:35
opencodejr[bot]
opencodejr Bot reviewed Nov 5, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach holds up: reporting from the settle hook in core, sharing the notification ID per busy period with the job observer and restart recovery, and keeping held reports on the session row. I read the diff and ran the 8 touched core test files (194 pass) and typecheck:tsc (clean). I did not run OpenCode end to end.

Public API: adds an optional notify input to the subagent tool (default true). It also writes a new subagent.notify key into child session metadata, which inherits to that child's own children. And it adds three nullable columns plus a partial index to session_v2 (additive migration). A user prompting a child session directly now also wakes the parent with a <subagent …> notice. All of this is backwards compatible: existing callers and sessions keep reporting by default.

Concern: a foreground subagent call now blocks until the child's background work finishes (see inline comment).

Fixes #48826
Related: #36349

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/session/subagent-job.ts Outdated
yield* terminal(event.value)
continue
}
if (!pending && !active) return

@opencodejr opencodejr Bot Nov 5, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run is now settle, so a foreground subagent call (jobs.block in the tool) only returns once SessionBackground.unsettled is false. Before, it returned when the child's busy period ended. If a child leaves a long-running background shell going (a dev server, a --watch), the parent's tool call now hangs until someone cancels or backgrounds it. Holding the report for that work makes sense, but for a foreground caller it might be better to return the inline result when the child goes idle and let the later settle report the final state. Or is waiting forever here intended?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kitlangton
fix(core): return foreground subagent answers without waiting for bac…
4d5cb17
…kground work
opencodejr[bot]
opencodejr Bot reviewed Nov 5, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit fixes the foreground hang: settle only waits for background work once the job has been moved to the background (via jobs.isBackgrounded), so a foreground call returns when the child stops. The two added tests cover both paths and are clear. I ran the touched core tests (196 pass) and typecheck:tsc (no errors). The public API impact is unchanged from my previous review. I have no new concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Nov 6, 2026
feat(core): agent tunnel messaging between sessions #62237
Closed
subagent: completion event fires at first idle, no event at real finish #62296
Closed
This was referenced Nov 7, 2026
[FEATURE]: expose subagent execution identity and timing to clients #62588
Open
[Feature] Show reused subagents at their latest invocation openchamber/openchamber#6358
Open
@jlongster jlongster mentioned this pull request Nov 10, 2026
feat(core): report subagent results to the parent every time a child goes idle #63209
Merged
@jlongster jlongster closed this Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] V2: subagent with pending background work (shell commands or subagents, background: true) marked completed early — results never collected

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@kitlangton @jlongster
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.