Skip to content

fix(agent): stop sub-agent scaffolding leak and false 'failed' status in customer chat - #90

Merged
william-antoline-boon merged 7 commits into
boonfrom
williamantoline/eng-16868-render-boundary-subagent-scaffolding
Jul 30, 2026
Merged

william-antoline-boon merged 7 commits into
boonfrom
williamantoline/eng-16868-render-boundary-subagent-scaffolding

Conversation

@william-antoline-boon

@william-antoline-boon william-antoline-boon commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes an issue where customers chatting with Boon Agent would see raw internal orchestration text and a false failure status when the agent used a sub-agent. During an electrical takeoff (panel-schedule extraction), this exact line leaked into the customer chat:

⚠️ 🧑‍🔧 Sub-agent: label Merlin Labs panel schedule extraction, task You are executing the PANEL SCHEDULE EXTRACTION step of an electrical takeoff… failed

Two distinct defects in that one line:

  1. Internal scaffolding leaked — the sub-agent's label and task prompt ("You are executing the PANEL SCHEDULE EXTRACTION step…") is internal orchestration plumbing that customers must never see.
  2. False "failed" status — the line ended in "failed", but the step actually succeeded: the very next message delivered a complete, cross-validated panel schedule (electrical-validate PASS). The sub-agent errored-then-recovered, yet a terminal "failed" badge still fired.

The affected surface is the customer-facing chat stream (both the live in-progress preview line and the final reply). Reproduced independently on a second thread, so it was systemic, not a one-off.

Why This Change Was Made

Two small, self-contained edits at the render/stream boundary:

  • Scaffolding leak: narrowed sessions_spawn's display detailKeys from the 7-field set (which included the free-form task prompt and label) to just ["taskName"] — the short, contract-slugged handle. The customer now sees which sub-agent ran (e.g. 🧑‍🔧 Sub-agent: panel-schedule-extraction), degrading to a bare 🧑‍🔧 Sub-agent when taskName isn't set. The task prompt, label, and operator-only knobs are never rendered.
  • False "failed": added a sessions_spawn branch to the tool-error warning policy — a spawn that errored but still delivered a real answer this turn is treated as non-terminal (silent), because a recovered spawn's output is identical in quality to a first-try success and the transient retry is backstage plumbing. A genuine failure (spawn errored and no answer was delivered) still surfaces an honest ⚠️ 🧑‍🔧 Sub-agent failed badge. This mirrors the recovery semantics already applied to the exec/bash/process tool class (the deliverable is the answer, not the tool call), and it is deliberately placed after the operator's global messages.suppressToolErrors gate and before the mutating-tool branch, so operator config still wins and the branch is not dead code (sessions_spawn is a mutating tool).

Design decision, verified against source: blanket-suppressing the badge (the simpler option) was rejected because it would hide genuine failures — this repo has no separate structural failure record yet, so honest failures must remain visible. Non-goal: the separate chain-of-thought / self-narration leak (ENG-16599) is out of scope; it needs a model-emitted answer envelope and is tracked separately.

User Impact

Customers no longer see internal sub-agent prompt text or a misleading "failed" status when the agent delegates work to a sub-agent that recovers. They now see a concise, human-readable name for the sub-agent that ran (its taskName) instead of nothing, so the chat stays informative without exposing the prompt. Genuine sub-agent failures still surface honestly, so nothing is hidden. No config or API changes; no action required by operators.

Evidence

Related: ENG-16868

Unit tests (all green):

  • src/agents/tool-display.test.ts — all green. New: a drift-guard asserting sessions_spawn.detailKeys is exactly ["taskName"], a behavior test that a sessions_spawn call renders its taskName but never the label/task prompt, and a degrade test (no taskName → no detail). 5 pre-existing generic display tests (truncation, credential redaction, zero/false-skip) were repointed off sessions_spawn onto memory_search and sessions_history, preserving their original coverage intent.
  • src/agents/embedded-agent-runner/run/payloads.test.ts — 38/38 pass. New: recovered spawn (error + delivered reply) → no warning badge; genuine failure (error + no reply) → honest failed badge.
  • src/agents/embedded-agent-runner/run/payloads.errors.test.ts — 68/68 pass. New: a genuinely-failed sessions_spawn still respects the operator's messages.suppressToolErrors config.
  • src/channels/streaming.test.ts — 7/7 pass (live-preview render path unaffected).

Generated snapshot kept in sync: the OpenClawKit (iOS/Swift) tool-display.json was regenerated so its sessions_spawn.detailKeys matches ["taskName"] and the tool-display:check guard stays green.

Genuine RED→GREEN verification: each fix was confirmed to fail its test when reverted — the false-badge test fails without the policy branch; the taskName render + leak-seam tests fail with the old detailKeys restored; the suppressToolErrors regression test fails when the branch is mis-ordered before the suppress gate; and the error-reply-suppression test stacks two error lines when the hasUserFacingErrorReply guard is removed.

Design/owner-boundary notes for reviewers:

  • The policy branch is placed after the operator messages.suppressToolErrors gate and before the mutating-tool branch, and it preserves the hasUserFacingErrorReply suppression the mutating branch had — so it is not a one-sided change that drops a sibling condition (no stacked error lines on an already-errored turn).
  • Emptying all of sessions_spawn's display detailKeys (not just label/task) is intentional: the remaining keys (agentId, model, thinking, runTimeoutSeconds, cleanup) are operator-only orchestration with no customer value, and a bare 🧑‍🔧 Sub-agent line is the intended degrade. This is a display default, not config schema — no persisted config, no migration, and the change is strictly less disclosure.
  • The end-to-end leak guard lives at the true seam (inferToolMetaFromArgs, which turns spawn args into the badge's meta string), not at the badge builder — the badge consumes a precomputed meta and never re-reads detailKeys.

CI (Linux, canonical): lint, prod-types, test-types, build-artifacts, actionlint, and the tool-display guard pass on this branch. The agent test shards cover the changed files.

🤖 Generated with Claude Code

@claude

claude Bot commented Jul 30, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

cubic analysis

All reported issues were addressed across 8 files

Linked issue analysis

Linked issue: ENG-16868: [Boon Agent][P2] Render/stream boundary: sub-agent scaffolding + false 'failed' status

Status Acceptance criteria Notes
✅ No label/task scaffolding text (sub-agent prompt) appears in any user-facing line (chat, live preview, TUI). The display config for sessions_spawn was emptied and tests added to assert no detail renders for sessions_spawn; this removes the source of the leak across render paths that consume the same table.
✅ Do not show a ‘⚠️ … failed’ badge when a sessions_spawn errored-but-recovered and a user-facing reply was delivered (recovered → silent). The warning policy now has a sessions_spawn branch that suppresses the badge when a user-facing reply exists, and a unit test asserts a recovered spawn produces only the assistant reply and no warning payload.
✅ Genuine sessions_spawn failures (no reply delivered) still surface an honest ‘⚠️ 🧑‍🔧 Sub-agent failed’ badge (don’t blanket-suppress). The new policy branch shows the warning when no user-facing reply exists; tests verify an honest failure emits an error payload containing 'failed', and operator suppressToolErrors behavior is also respected.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

@william-antoline-boon
william-antoline-boon force-pushed the williamantoline/eng-16868-render-boundary-subagent-scaffolding branch from 9065aa2 to 3acfd30 Compare July 30, 2026 05:04
…sessions_spawn detailKeys (ENG-16868)

The OpenClawKit (iOS/Swift) tool-display.json is a generated snapshot of
TOOL_DISPLAY_CONFIG. Emptying sessions_spawn.detailKeys requires regenerating
it so the check-guards `tool-display:check` gate stays green and the Swift app
renders the same clean Sub-agent line.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved — reviewed the full diff against ENG-16868.

Both defects fixed at the right seam:

  • Scaffolding leak: emptied sessions_spawn detailKeys; verified the badge's meta comes from inferToolMetaFromArgs (the true seam), and the new drift-guard test keeps it empty.
  • False 'failed': the new policy branch is correctly placed after the suppressToolErrors global gate and before the mutating branch. Confirmed sessions_spawn IS in MUTATING_TOOL_NAMES, so without this branch a recovered spawn would hit the mutating branch (which ignores hasUserFacingReply) and emit a false badge — branch is necessary, not dead code. Suppression is !hasUserFacingReply && !hasUserFacingErrorReply, mirroring the mutating branch it replaces (no stacked error lines).

Edge cases all covered with genuine RED→GREEN tests: recovered+reply (silent), genuine failure+no reply (honest 'failed'), error-reply-already-shown, and operator suppressToolErrors still wins. Generated OpenClawKit tool-display.json regenerated so tool-display:check stays green. Strictly less disclosure — no config/API/schema change, no secrets, no migration risk.

Clean, well-scoped, honest-failure-preserving. Ship it.

… (ENG-16868)

Render sessions_spawn's taskName (the short, contract-slugged handle) so the
customer sees WHICH sub-agent ran (e.g. 'Sub-agent: panel-schedule-extraction'),
degrading to a bare 'Sub-agent' when taskName is absent. The free-form task
prompt and label remain excluded — rendering task is what leaked the prompt to
chat. Regenerated the OpenClawKit snapshot to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@william-antoline-boon

Copy link
Copy Markdown
Collaborator Author

Test report

Full report (Slite): https://getboon.slite.com/api/s/Mdg9C_TCHp1NYv/ENG-16868-Test-Report-Sub-agent-scaffolding-leak-false-failed-PR-90

Unit tests — 201 pass, 0 fail (RED→GREEN verified)

node scripts/run-vitest.mjs on the four touched files:

  • tool-display.test.ts — taskName renders; task/label never do; no-taskName degrades to bare; detailKeys drift guard.
  • payloads.test.ts — recovered spawn → silent; genuine failure → honest badge.
  • payloads.errors.test.ts — genuine failure respects messages.suppressToolErrors; no stacked error line when a user-facing error reply already exists.
  • embedded-agent-utils.test.ts — badge-meta leak-seam guard.

Each fix was confirmed to FAIL when reverted (genuine RED→GREEN), so the tests actually guard the behavior.

Real render-function drive (no mocks)

Drove the production resolveToolDisplay / formatToolDetail / inferToolMetaFromArgs with realistic sessions_spawn args:

success, taskName set  : 🧑‍🔧 Sub-agent: panel-schedule-extraction
success, no taskName   : 🧑‍🔧 Sub-agent
failure badge (name)   : ⚠️ 🧑‍🔧 Sub-agent: panel-schedule-extraction failed
failure badge (bare)   : ⚠️ 🧑‍🔧 Sub-agent failed

The full task prompt and label are absent in every case. Adversarial case (prose shoved into taskName) is first-line-only + credential-redacted + truncated to 160 chars, and is rejected at execution before it ever spawns.

CI (canonical Linux)

Run 30523821892 on cfe63a3b10: 106 pass, 0 fail, 0 pending (9 skipped iOS/docs). Green gates include check-lint, check-prod-types, check-test-types, build-artifacts, check-guards (tool-display snapshot), the agent test shards, and cubic.

Known gap — live boon-chat E2E not run

A real customer-chat repro (trigger a sessions_spawn that errors-then-recovers, screenshot the chat) was not performed: the Crabbox binary / full runtime isn't available in this worktree. This leaves channel-specific rendering and the live spawn-error-recover trigger unverified in situ (both reasoned from code + traced through the live handler path, but not observed live). The change is small and reversible; recommend capturing the screenshot on a full checkout / via Crabbox as follow-up or before final sign-off.

@william-antoline-boon
william-antoline-boon merged commit 7344c21 into boon Jul 30, 2026
143 of 144 checks passed
@william-antoline-boon
william-antoline-boon deleted the williamantoline/eng-16868-render-boundary-subagent-scaffolding branch July 30, 2026 11:50
convyusboy added a commit that referenced this pull request Aug 3, 2026
Version-bump release carrying the 5 commits merged onto boon since boon.12:
#90 (ENG-16868), #92 (ENG-16854), #93, #94 (ENG-15788), #95 (ENG-17134).

Bumps gateway + slack + msteams + diagnostics-prometheus to
2026.6.11-boon.13 in lockstep (9 files). CI: 108 pass / 0 fail / 7 skip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant