Skip to content

workflows: submitStructuredResult stops the worker mid-call before bb_workflow_result returns #8371

Description

@pavelmaksimov

1. Summary

When a structured workflow worker calls bb_workflow_result, submitStructuredResult calls await stopChild(threadId) synchronously inside the tool handler before returning { ok: true } (and similarly on exhausted retries). This cancels the worker's in-flight bb_workflow_result tool call and ends the turn with manual-stop / status=interrupted, even though the workflow accepted the result and succeeded.

2. Versions and environment

  • bb version: 0.50.1 (Linux x64 AppImage), reproduced against main at commit b0ddaad7
  • OS: Linux x86_64, Node v22.23.2
  • Providers observed: acp-devin, acp-omp, acp-opencode

3. Steps to reproduce

  1. Run any workflow script containing an agent(..., { outputSchema: { ... } }) call.
  2. Wait for the worker to call bb_workflow_result with a valid payload matching outputSchema.
  3. Inspect the worker thread's event log (bb thread log <worker-thread-id> --json).

Alternatively, inspect plugins/workflows/src/service.ts at b0ddaad7:

4. Expected vs actual

Actual:
Every structured worker's bb_workflow_result tool call completes with status: "interrupted" and a system/thread/interrupted event with reason: "manual-stop". Across 18 consecutive structured worker calls in live runs (e.g., thr_6ycd59awbb, thr_n6y2wrhbr2, thr_apitb346ja, thr_4p25xabqb8, thr_qe94jspfz9), 18/18 had bb_workflow_result interrupted by manual-stop.

Expected:
bb_workflow_result returns { accepted: true } cleanly so the tool call completes (status: "completed") and the worker finishes its turn normally without a self-inflicted manual-stop interruption. If a worker fails to go idle after receiving the terminal tool response, a bounded fallback timer should stop and archive it.

5. Evidence

  • Code path (b0ddaad7):
    • submitStructuredResult calls await stopChild(threadId) before return { ok: true } in stored === "accepted" and stored === "idempotent", and before return { ok: false, terminal: true, error } when attempts > MAX_REPAIR_ATTEMPTS.
    • Additionally, cleanupWorkers() (https://github.com/get-bb/bb/blob/b0ddaad7/plugins/workflows/src/service.ts#L549-L563) calls archiveRetiredWorker (which invokes bb.sdk.threads.stop) on any retired worker as soon as wakeCall triggers maintenanceTick(), so merely removing await stopChild without guarding cleanupWorkers() still races with the in-flight tool response.
  • Existing harness test at https://github.com/get-bb/bb/blob/b0ddaad7/plugins/workflows/src/server-harness.test.ts#L306-L312 currently asserts threads.stop was called synchronously before callAgentTool("bb_workflow_result", ...) settles.

6. What you ruled out

7. Suggested priority and effort

High priority, small effort: affects 100% of structured agent() calls in workflows, corrupts session/tool-call metrics, and triggers the cancelled-stream path behind #8332.

AGENT GENERATED

Activity

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

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · High priority · Low effort; area plugins, built-in plugin workflows. Filled missing classifications without replacing existing values.
    • Reproduction and root-cause report: REPRODUCED, high confidence; repeated in a second clean checkout of trusted main. Applied confirmed-repro.
    • Root cause: structured-result submission stops its own worker before returning; retired-worker maintenance can also stop/archive it before the reply completes.
    • Verification: regression fails before the fix and passes afterward; all 296 workflow tests, targeted lint/typecheck, and diff checks pass. Live provider-stream events and the separate Node 26 crash were not exercised.
    • Ready fix: PR #8376 defers cleanup until worker settlement or a bounded deadline: 109 changed text lines across 3 files. Not merged.

    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-repropluginsworkflows

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions