Skip to content

Plugin hook to defer or suppress intermediate subagent failure notifications #57157

Open

Description

@Neko-Yukari

What

Plugins can wrap the native subagent tool, but they cannot intercept the completion/failure notification the host emits for each subagent invocation. A plugin that retries a failed child (provider retry, model fallback) re-dispatches in the same child session and often succeeds, yet the parent has already received a failure notice for the first attempt. There is no way to defer or suppress intermediate notices.

Current plugin API surface

  • session.get / context / wait / synthetic
  • storage (KV)
  • event.subscribe (read-only; events cannot be mutated or vetoed)
  • tool.transform

For a background dispatch the tool returns an ack immediately, so the later failure happens outside the tool call stack: tool.transform cannot see or absorb it.

Proposal

Any one of these would be enough:

  1. Vetoable notification hook — e.g. ctx.notification.transform(...) or an event-level veto, letting a plugin return { suppress: true } for an intermediate failure.
  2. Session "recovering" flag — plugin marks a child as recovering for N seconds; the host buffers failure notices until the final outcome arrives.
  3. synthetic-style suppression — a documented way to retract or supersede a completion notice already queued for a session.

Why it matters

Retry/fallback is common for flaky providers and quota errors. Without this, users see a failure line even when the task recovered, which makes delegation look unreliable and forces plugins to choose between "no retries" and "noisy parents". The only workaround today is forcing foreground dispatch, which blocks the parent for the whole task.

Happy to submit a PR for whichever direction fits the architecture.

Activity

  1. opencode-agent commented on Oct 19, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed write-up! You're asking for a plugin hook that can defer or suppress the parent's notification when a background subagent fails, so a plugin that retries or falls back to another model can report only the final outcome.

    I checked the current v2 code. The failure notice goes to the parent session as soon as the background job ends (SubagentCompletion.deliver → session.synthetic), and no plugin hook runs before that. event.subscribe can only watch events, and tool.transform only sees the immediate ack, so a plugin can't build this today. The plugin API would need a small addition: for example, a completion/notification transform that runs before delivery and can defer, replace or suppress the notice, or a way to replace a queued notice by its id.

    Maintainers will consider this and which direction fits best. Related issues:

  2. mradwankhalil commented on Nov 10, 2026

    @mradwankhalil
    Contributor

    A small owner-scoped admission API looks workable here. I checked current dev at 57719d7fd4: SubagentCompletion.deliver still calls sessions.synthetic directly, and the plugin session API has no pre-delivery guard.

    Our local prototype binds an opaque owner/attempt token to a native subagent call before dispatch. Before a terminal or hold-ceiling notice enters the parent inbox or wakes it, the registered owner can admit, suppress or defer it. Untagged calls retain current behavior. Suppressing a terminal notice settles its receipt; suppressing an interim ceiling notice does not finish the job. Missing guards defer rather than admit, and registration replays deferred notices.

    One important race: already-bound tokens must survive guard replacement. Deleting them on disposal turns an in-flight managed call into an unguarded one. We reproduced that and fixed it by retaining owner tags until claim/release, with fail-closed capacity limits.

    Independent local checks pass: 21 Core admission tests, the handover regression, and built Core+plugin fallback/cancellation tests. These are on our 2.2.6-based candidate; a full binary restart race is still being tested, not claimed complete.

    Would an owner-token guard/binding API be an acceptable direction for a focused PR against dev, or is there a preferred existing admission boundary to extend? This is separate from the already-active-child recovery bug in #62792.

  3. markerikson commented on Nov 15, 2026

    @markerikson

    Yeah, per #63894 and #63786 , having a child task notify its parent on every turn end is spam that bloats the parent context, especially if you're having an extended conversation or driving additional work in a subtask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions