Skip to content

Child "completed" notice repeats the previous turn's output after an empty turn #6820

Closed

Description

@neoromantic

Summary

A child thread with --parent-notifications auto reports every completed root turn to its parent. When a later turn finishes without any agent output, the parent still gets a "completed" notice, and its excerpt is the text of an earlier turn. The parent sees the same result again as if it were new.

Versions and environment

  • Observed on bb 0.48.0 desktop app (macOS 27.0). The same lookup is present on main at 916d684 (a server regression test of the same path fails on main).
  • Providers: seen with a Codex child; the lookup is provider-independent.

Steps to reproduce

  1. Spawn a child with bb thread spawn --parent-thread <parent> --parent-notifications auto ….
  2. Let the child finish a turn with a final message, e.g. "Done: X".
  3. Send the child a message it answers with no text (an empty final, or a turn that only ends).
  4. Repeat step 3.

Expected vs actual

Expected: one notice "completed: Done: X"; the empty turns send nothing, or at least no old text.
Actual: three notices, each "completed:\n\nDone: X".

Evidence

getChildThreadCompletionOutput calls getLastThreadOutput, which selects the latest non-empty agent message of the whole thread, not of the turn that completed:

function getChildThreadCompletionOutput(
deps: LoggedPendingInteractionWorkSessionDeps,
args: QueueChildThreadTurnNotificationArgs,
): string | null {
if (args.turnStatus !== "completed") {
return null;
}
return getLastThreadOutput(deps.db, args.childThread.id);
}

export function getLatestThreadOutputEventRow(
db: DbConnection,
args: GetLatestThreadOutputEventRowArgs,
): StoredEventRow | null {
return (
db
.select(storedEventRowFields)
.from(events)
.where(
sql`${events.threadId} = ${args.threadId} AND (
(
${events.type} = 'system/manager/user_message'
AND COALESCE(json_extract(${events.data}, '$.text'), '') <> ''
)
OR (
${events.type} = 'item/completed'
AND ${events.itemKind} = 'agentMessage'
AND COALESCE(json_extract(${events.data}, '$.item.text'), '') <> ''
)
)`,
)
.orderBy(desc(events.sequence))
.limit(1)
.get() ?? null
);

Observed in a real thread: turn A ended with a message; turns B and C ended with an empty agent message; the parent received the turn-A text three times (three separate turn completions, not one notice delivered three times).

What you ruled out

  • Not the 2-second batching: the three completions were in separate batches.
  • Not push or thread.idle notifications: this is the parent system message path.
  • The same code path is on main at 916d684.

Suggested priority and effort

Low effort, small fix. Affects parents of auto children: the parent receives the old result again as an extra notice and context. Whether it also causes extra parent turns was not established. No data is lost.

AGENT GENERATED

Activity

  1. added theissue type on Nov 2, 2026
  2. added
    threads
    confirmed-repro
    on Nov 2, 2026
  3. bb-slop-cop commented on Nov 2, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Low · Effort: Low · Area: threads.
    • Report: https://get-bb.github.io/reports/issues/6820.html — REPRODUCED, high root-cause confidence; repeated in two clean trusted-main checkouts. Applied confirmed-repro.
    • Root cause: completion notices selected the latest non-empty output of the entire child thread, allowing an outputless turn to reuse an earlier result.
    • Fix: Keep child completion output within its completed turn #6822 (ready, not merged). Scope output to the completed root turn; retain existing status-only notices and thread-wide output-route behavior.
    • Verification: both regressions fail before and pass after; 714 server tests and 145 database tests pass, as do typechecks, changed-file lint, formatting, and diff checks. Five files; 125 changed text lines. Extra executed parent turns were not established.

    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