Skip to content

Parent thread notices do not say who initiated a child thread's turn #4424

Open

Description

@hxy91819

Summary

When a user messages a child thread directly (for example bb thread tell <child> "go ahead and delete the old files"), the completion notice delivered to the parent thread is byte-identical to the notice for a turn the parent itself initiated. The parent agent cannot tell the user overrode the child's mandate, so it may misread the child's new behavior as exceeding its delegated authority and send conflicting stop or corrective instructions. The server already persists who initiated each turn on client/turn/requested (source, initiator, senderThreadId, input) — the parent-notification path simply never reads it.

Versions and environment

  • bb: from source at origin/main 4354b88ce14457fbdf1fc1a8e0db2dd4b5ef90f3
  • OS: Linux 6.8.0-139-generic
  • Node: v24.15.0
  • Provider: not provider-specific; the notice is assembled server-side in apps/server/src/services/threads/child-thread-notifications.ts
  • Reproduction method: faithful repro at the exact code path — the rendering layer has no author input and unit tests on main assert the verbatim notice text (see Evidence). A reference fix (linked below) was additionally verified end-to-end on a source dev instance on the pre-port branch: a parent-spawned child, a direct user thread tell to the child, a parent thread tell, and two children completing within the batch window produced the expected notices.

Steps to reproduce

  1. From inside the parent thread (where BB_THREAD_ID is set), spawn a child:

    bb thread spawn --project <project-id> --parent-self \
      --prompt "Clean up old files. Do not delete anything without my approval."

    Note the child thread id printed, e.g. thr_child.

  2. As the user — in a shell without BB_THREAD_ID — tell the child directly, changing its mandate:

    bb thread tell thr_child "Go ahead and delete the old files."
  3. After the child's turn completes, read the parent's event log:

    bb thread log <parent-thread-id>

Expected vs actual

Actual notice delivered to the parent on main (4354b88ce), verbatim from the rendering path and its pinned test assertions — identical whether the parent or the user initiated the turn:

[bb system]

@thread:thr_child completed:

Deleted the old files.

Expected notice for a turn containing direct user input (as implemented in the linked reference commit):

[bb system]

@thread:thr_child completed:

This turn included input from the user directly in this thread; you did not initiate that input.

User message:
Go ahead and delete the old files.

Deleted the old files.

The user's direct instructions to this thread take precedence over your earlier instructions. Review the thread before sending corrective, stop, or reassignment instructions.

Batch notices have the same gap: on main a direct-user-input turn renders identically to any other - @thread:thr_x completed. line; the reference implementation marks it (turn included direct user input) with an indented quote and a batch-level precedence instruction.

Evidence

On main the notification pipeline has no turn-author concept:

  • ChildThreadTurnNotificationBatchItem carries only thread/output/status fields — no author:
    export interface ChildThreadTurnNotificationBatchItem {
  • queueChildThreadTurnNotificationBestEffort is called with no provenance argument from every completion/interruption path:
    export async function queueChildThreadTurnNotificationBestEffort(
  • Yet the needed data is already persisted: turnRequestEventDataSchema records source ("spawn"/"tell"), initiator, and senderThreadId per request:
    export const turnRequestEventDataSchema = z.object({
    direction: z.literal("outbound"),
    requestId: clientTurnRequestIdSchema,
    // Retry provenance, written only when a `turn.failed` gate's retry row
    // dispatches. Both fields are present together or not at all: absence means
    // "this is an original dispatch", which is the overwhelmingly common case.
    // (Supersedes the pre-plugin `continuationOfRequestId` key, which the removed
    // core rate-limit recovery wrote and nothing ever read.)
    /** The original request this attempt re-submits, unchanged across attempts. */
    retryOfRequestId: clientTurnRequestIdSchema.optional(),
    /** Which attempt this is: 2 is the first retry of the original request. */
    retryAttempt: z.number().int().min(2).optional(),
    source: z.enum(["spawn", "tell"]),
    initiator: threadTurnInitiatorSchema,
    senderThreadId: z.string().nullable(),

Reference implementation on a fork, based on origin/main 4354b88ce — adopt as you see fit:

What you ruled out

  • Searched get-bb/bb open and closed issues (child thread, parent notification author, turn initiator); no duplicate found.
  • Not the scope of A child interrupted by a host daemon disconnect never notifies its parent #3956 or Notify parents when delegated child work ends unexpectedly #4356: those cover notifying parents when child work ends unexpectedly (daemon disconnect, abnormal termination). This bug concerns who initiated a turn that is notified normally — including normal completions.
  • Reproduced on main at 4354b88ce via the exact code path: the batch renderer's item type has no author field, so its output cannot vary with the turn's initiator — pinned by main's own test assertions quoting the notice verbatim. The reference fix was verified end-to-end on a source dev instance against the pre-port branch (a parent-spawned child, a direct user thread tell to the child, a parent thread tell, and two children completing within the batch window produced the expected notices). The notice texts above are verbatim test-asserted strings, not paraphrases.

Suggested priority and effort

Affects every parent→child delegation where the user also talks to the child directly; the parent may issue stop/corrective orders that contradict the user's live instructions. No data is lost, and the workaround is to have the parent review the child (bb thread log) before acting — which the agent guidance cannot currently enforce because the notice gives it no signal to do so. Effort is moderate: one targeted db query, author classification in the existing notification module, an optional field on childThreadOutcomeSchema, and template/docs updates — a complete, tested implementation is linked above.

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

Investigation report: the linked fork commit and its tests are the full write-up; the BB threads that produced it ran on the reporter's machine and are not publicly linkable.

AGENT GENERATED

Activity

  1. added theissue type on Sep 30, 2026
  2. added
    threads
    confirmed-repro
    on Sep 30, 2026
  3. SawyerHood commented on Sep 30, 2026

    @SawyerHood
    Collaborator

    Verified notice/persistence report: https://get-bb.github.io/reports/issues/4424.html

    REPRODUCED in two clean checkouts: distinct persisted user, parent-agent, other-agent and system initiators produce equivalent queued parent notices; mixed versus parent-only batches also match. A changed-output control changes the notice. Actual SQLite evidence and the complete test are included. No agents were started; live interpretation, immediate delivery, retry and multi-input behavior remain untested.

  4. hxy91819 commented on Oct 3, 2026

    @hxy91819
    Author

    Following up with an implementation that resolves the initiator from the stored events, in case it is useful alongside the verified report above.

    Branch feature/child-turn-author on hxy91819/bb, rebased on desktop-v0.45.0 (129f6217): hxy91819/bb@desktop-v0.45.0...hxy91819:bb:feature/child-turn-author — core commit hxy91819@567a7f686

    Approach:

    • The client/turn/requested events already record who authored each accepted input; the notification path never consulted them. A targeted @bb/db query joins a turn's turn/input/accepted rows to their client/turn/requested rows in acceptance order.
    • Each request is classified as direct user (tell + user initiator + no sender thread), parent (spawn source or the parent's senderThreadId), or other agent. Legacy rows with missing fields still parse.
    • The author travels on the parent-notification follow-up as an explicit field. Single notices prepend a sentence saying the parent did not initiate that input; paths without a turn (provider exit, command, provisioning, queued-send failures) pass null and render unchanged. Host-side interruptions resolve the interrupted turn's author too.
    • Tests cover the DB join, the classifier, and the rendered notice variants.

    Running this on a fork since late September: parents stopped sending corrective or stop instructions after a user widened a child's authorization mid-turn. Diff is 17 files, +901/−12, mostly tests.

    AGENT GENERATED

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

    confirmed-reprothreads

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions