Skip to content

fix(agent): suppress stale tool-error surface on sessions_yield handoff (ENG-19495) - #203

Merged
william-antoline-boon merged 4 commits into
boonfrom
william-antoline-boon/eng-19495-stale-tool-error-on-sessions-yield
Sep 8, 2026
Merged

william-antoline-boon merged 4 commits into
boonfrom
william-antoline-boon/eng-19495-stale-tool-error-on-sessions-yield

Conversation

@william-antoline-boon

@william-antoline-boon william-antoline-boon commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

What

A turn that ends via sessions_yield to a spawned subagent produces no reply this dispatch (the subagent answers later). buildEmbeddedRunPayloads' tool-failure fallback treated that as "no reply → surface the last tool error", turning an incidental earlier failure into a false "I couldn't complete one of the steps for this turn" + Retry message.

Live incident: Bass Concrete, thread 2445 — the agent had actually succeeded and delivered a correct concrete-scope PDF diff ~4 min later; the customer saw a hard failure + Retry buttons during the wait and retried twice. (ENG-19495, P1)

Fix

Gate the tool-failure fallback (via resolveToolErrorWarningPolicy's existing turn-wide suppression) on yieldHandoff = yieldDetected && hasAcceptedSessionSpawn(...), wired from the single run.ts call site.

  • Narrow by design: only a yield with a spawned continuation suppresses. A plain yield-to-wait, or a genuine dead-end, still surfaces its error exactly as today.
  • Fails open: === true on both flags — an absent/unknown flag surfaces the error (never hides a real failure).
  • All channels (Slack/Teams/Boon Web) — run.ts is the single funnel. The errorText (provider/timeout/402) path and every other caller are untouched.

Scope

Part 1 of a 3-part design (full spec on the ticket). Part 1 is the reliability fix — it removes the false "couldn't complete a step" message. On Boon Web a milder, non-wedging no_visible_payload row remains; Parts 2 & 3 (true silence) are deferred.

Tests

payloads.errors.test.ts: AC1 reproduction (yield+spawn+stale error → no payload; RED→GREEN) + two AC2 narrow-gate guards (yield-without-spawn and spawn-without-yield both still surface). AC3 (provider/timeout error path) covered by pre-existing tests. Deterministic green (154/154 ×3); tsgo + oxlint clean.

🤖 Generated with Claude Code


Summary by cubic

Stops buildEmbeddedRunPayloads from surfacing a stale tool error on turns that end via sessions_yield to a spawned subagent (ENG-19495). Previously the tool-failure fallback turned an incidental earlier failure into a false "couldn't complete one of the steps" message, even though the subagent delivered the real answer minutes later (Bass Concrete thread 2445).

Bug Fixes

  • Gates the fallback on yieldDetected && hasAcceptedSessionSpawn, so only a yield with a spawned continuation suppresses the error.
  • Plain yields-to-wait and genuine dead-ends still surface their errors as before.
  • Fails open: an absent or unknown flag never hides a real failure.
  • Applies to all channels since run.ts is the single funnel; the provider/timeout/402 error path is untouched.
  • Adds regression tests for the stale-error repro and both narrow-gate guards.

Written for commit b4c8484. Summary will update on new commits.

Review in cubic

…off (ENG-19495)

A turn that ends via sessions_yield to a spawned subagent produces no reply this dispatch (the subagent answers later). buildEmbeddedRunPayloads' tool-failure fallback treated that as 'no reply -> surface the last tool error', turning an incidental earlier failure into a false 'couldn't complete a step' message on a working turn. Gate the fallback on yieldDetected && hasAcceptedSessionSpawn — narrow: a plain yield-to-wait or a genuine dead-end still surfaces its error unchanged. Part 1 of 3; all channels.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@william-antoline-boon
william-antoline-boon requested a review from a team September 7, 2026 16:44
@claude

claude Bot commented Sep 7, 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.

All reported issues were addressed across 3 files

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

Fix all with cubic | Re-trigger cubic

@william-antoline-boon

Copy link
Copy Markdown
Collaborator Author

Accepted tradeoff (R2) — reviewer-flagged, owner-signed-off

On a yield-with-spawn turn (both yieldDetected and hasAcceptedSessionSpawn true), an unrecovered tool failure is suppressed from the customer-facing surfaces — both the reply message and the "Verification" chip (audit_trace), since the trace attaches to the same terminal reply payload this gate removes.

This is deliberate and narrow:

  • It only applies to yield-with-spawn (a plain yield-to-wait or a genuine dead-end still surfaces its error).
  • The alternative — surfacing "I couldn't complete one of the steps" + Retry on every yield-handoff — is exactly the bug being fixed (reliably wrong on working turns).
  • Common case is incidental failures (the incident's failed internal message status-update); dropping those is desirable.

Observability is preserved — the drop is only customer-facing, not engineering-facing. This PR does not touch the telemetry path: failed tool calls are still captured by the fleet sentry-monitor plugin via the after_tool_call hook (upstream of reply-packaging) — a genuine tool error → Sentry exception with tool/error/run-correlation tags; a validation/invalid-input rejection (the incident's case) → Sentry warning (non-paging). Plus the run trajectory + host logs. So even the rare worst case (a silent pre-yield deliverable failure) leaves a Sentry trail for on-call.

The durable fix for the rare genuine case (if a frequency query later shows it matters) is defer-and-re-surface via the continuation, not un-gating — tracked as future work; not in Part 1 scope.

…/eng-19495-stale-tool-error-on-sessions-yield
- resolveToolErrorWarningPolicy: 'These two' overrides -> 'These' (yieldHandoff makes it three).

- AC1 test: make the runAborted=false comment precise (yield forces false + strips its synthetic aborted turn) so it can't misread as 'yields are never aborted'.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…/eng-19495-stale-tool-error-on-sessions-yield

@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. Narrow gate (yieldDetected && hasAcceptedSessionSpawn) at the right layer — resolveToolErrorWarningPolicy turn-wide override, so the digest builder inherits it via showWarning=false (no divergence risk). Fails open on === true. AC1 repro + both narrow-gate guards (yield-without-spawn, spawn-without-yield) landed and stay RED without the fix. Ran the test file locally: 154/154 green. run.ts funnel = all channels; errorText path untouched. Comment/copy nits from cubic addressed in 11bcebb. Ship it. 🧙

@william-antoline-boon william-antoline-boon changed the title fix(agent): suppress stale tool-error surface on sessions_yield handoff (ENG-19495 Part 1) fix(agent): suppress stale tool-error surface on sessions_yield handoff (ENG-19495) Sep 8, 2026
@william-antoline-boon
william-antoline-boon merged commit c881a6a into boon Sep 8, 2026
148 checks passed
@william-antoline-boon
william-antoline-boon deleted the william-antoline-boon/eng-19495-stale-tool-error-on-sessions-yield branch September 8, 2026 03:50
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.

3 participants