Repository navigation
fix(agent): stop sub-agent scaffolding leak and false 'failed' status in customer chat - #90
Conversation
|
I'll analyze this and get back to you. |
There was a problem hiding this comment.
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 ‘ |
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 ‘ |
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
…n, keep honest failures (ENG-16868) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ighten review findings (ENG-16868)
…fix test vehicles + leak-seam guard (ENG-16868)
…ge stacking (ENG-16868)
9065aa2 to
3acfd30
Compare
…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]>
There was a problem hiding this comment.
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]>
Test reportFull 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)
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 The full CI (canonical Linux)Run Known gap — live boon-chat E2E not runA real customer-chat repro (trigger a |

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:
Two distinct defects in that one line:
labelandtaskprompt ("You are executing the PANEL SCHEDULE EXTRACTION step…") is internal orchestration plumbing that customers must never see.electrical-validatePASS). 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:
sessions_spawn's displaydetailKeysfrom the 7-field set (which included the free-formtaskprompt andlabel) 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-agentwhentaskNameisn't set. Thetaskprompt,label, and operator-only knobs are never rendered.sessions_spawnbranch 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 failedbadge. This mirrors the recovery semantics already applied to theexec/bash/processtool class (the deliverable is the answer, not the tool call), and it is deliberately placed after the operator's globalmessages.suppressToolErrorsgate and before the mutating-tool branch, so operator config still wins and the branch is not dead code (sessions_spawnis 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 assertingsessions_spawn.detailKeysis exactly["taskName"], a behavior test that asessions_spawncall renders itstaskNamebut never thelabel/taskprompt, and a degrade test (notaskName→ no detail). 5 pre-existing generic display tests (truncation, credential redaction, zero/false-skip) were repointed offsessions_spawnontomemory_searchandsessions_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) → honestfailedbadge.src/agents/embedded-agent-runner/run/payloads.errors.test.ts— 68/68 pass. New: a genuinely-failedsessions_spawnstill respects the operator'smessages.suppressToolErrorsconfig.src/channels/streaming.test.ts— 7/7 pass (live-preview render path unaffected).Generated snapshot kept in sync: the OpenClawKit (iOS/Swift)
tool-display.jsonwas regenerated so itssessions_spawn.detailKeysmatches["taskName"]and thetool-display:checkguard 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
taskNamerender + leak-seam tests fail with the olddetailKeysrestored; thesuppressToolErrorsregression test fails when the branch is mis-ordered before the suppress gate; and the error-reply-suppression test stacks two error lines when thehasUserFacingErrorReplyguard is removed.Design/owner-boundary notes for reviewers:
messages.suppressToolErrorsgate and before the mutating-tool branch, and it preserves thehasUserFacingErrorReplysuppression 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).sessions_spawn's displaydetailKeys(not justlabel/task) is intentional: the remaining keys (agentId,model,thinking,runTimeoutSeconds,cleanup) are operator-only orchestration with no customer value, and a bare🧑🔧 Sub-agentline is the intended degrade. This is a display default, not config schema — no persisted config, no migration, and the change is strictly less disclosure.inferToolMetaFromArgs, which turns spawn args into the badge'smetastring), not at the badge builder — the badge consumes a precomputedmetaand never re-readsdetailKeys.CI (Linux, canonical): lint, prod-types, test-types, build-artifacts, actionlint, and the
tool-displayguard pass on this branch. The agent test shards cover the changed files.🤖 Generated with Claude Code