Skip to content

fix(errors): intermediate status for non-terminal tool failures, not "⚠️ … failed" (ENG-15627 G4) - #52

Closed
monac24 wants to merge 1 commit into
boonfrom
eng-15627-intermediate-status
Closed

monac24 wants to merge 1 commit into
boonfrom
eng-15627-intermediate-status

Conversation

@monac24

@monac24 monac24 commented Jul 16, 2026 •

Copy link
Copy Markdown

Related: ENG-15627 (G4 — operation-outcome vs session-state, intermediate status)

What Problem This Solves

Fixes an issue where a user sees "⚠️ ✉️ Message failed" (or "⚠️ 🛠️ Exec failed") while the agent is actually still working and the turn succeeded. When a tool errors after the assistant has already produced a reply and prior tools completed, core correctly classifies it as non-terminal — but the visible banner still read as a hard, terminal failure. This is the "message failed while the agent is still working in the background" report: the runtime announced a mechanical outcome with no knowledge that work continued.

Why This Change Was Made

buildEmbeddedRunPayloads set nonTerminalToolErrorWarning: true on the payload metadata (so downstream consumers already treated it as non-failed) yet still rendered ⚠️ <tool> failed as the text. The metadata and the copy disagreed.

  • Compute the non-terminal decision once (hasUserFacingAssistantReply && middlewareError) and use it to drive both the visible text and the metadata flag.
  • For the non-terminal case, render an intermediate status naming what completed: ↻ ✉️ Message didn't complete — continued (2 steps completed) (step count from the completed toolMetas; omitted when zero). No ⚠️, no "failed".
  • Terminal failures are unchanged: no user-facing reply, or a non-middleware mutating failure, still emits the existing ⚠️ <tool> failed banner.

User Impact

A transient tool hiccup during a turn that otherwise succeeds now reads as a progress step ("continued (N steps completed)") instead of a false "failed". Genuine, terminal tool failures still surface clearly. Group/channel and verbose behavior are otherwise unchanged.

Evidence

  • TDD: RED (non-terminal case rendered ⚠️ ✉️ Message failed) → GREEN.
  • Updated the pre-existing "marks middleware tool-error warnings after assistant output as non-terminal" test to assert the corrected intermediate-status copy (it previously asserted the over-eager Exec failed).
  • Full agents-embedded-agent shard green (1536), cron shard green (1174, the nonTerminalToolErrorWarning consumer), payloads suites green (91). oxlint clean.

🤖 Generated with Claude Code


Summary by cubic

Stop showing a terminal "⚠️ … failed" banner when a tool error is non-terminal and the assistant already replied. Instead, show an intermediate status that work continued, aligning with ENG-15627 (G4).

  • Bug Fixes
    • Compute the non-terminal decision once (has user-facing reply + middleware error) and use it for both banner text and payload metadata.
    • For non-terminal errors, render "↻ didn't complete — continued (N steps completed)" and omit the count when zero; no "⚠️" or "failed".
    • Terminal failures are unchanged and still show "⚠️ failed"; tests updated to assert the new intermediate copy and metadata.

Written for commit 263b115. Summary will update on new commits.

Review in cubic

…s, not "⚠️ … failed" (ENG-15627 G4)

When a tool errored but the turn kept going — the assistant already produced a
reply and prior tools completed — buildEmbeddedRunPayloads still emitted a
terminal "⚠️ ✉️ Message failed" banner, even though core marked it
nonTerminalToolErrorWarning=true. That is the over-eager lie: it reads as a hard
failure while work actually continued (the "message failed while the agent is
still working" report).

Reframe the non-terminal case as a progress step that names what completed:
"↻ ✉️ Message didn't complete — continued (2 steps completed)". No ⚠️, no
"failed". The non-terminal decision is computed once and drives both the visible
text and the payload metadata (previously the metadata said non-terminal while
the text said failed). Terminal failures (no reply, or non-middleware mutating
failures) keep the existing "⚠️ <tool> failed" banner unchanged.

Reports the operation outcome as an intermediate status instead of a false
terminal error — the G4 half of the ENG-15627 error-conveying guardrails.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@claude

claude Bot commented Jul 16, 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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/agents/embedded-agent-runner/run/payloads.ts">

<violation number="1" location="src/agents/embedded-agent-runner/run/payloads.ts:593">
P2: The status can claim async work is “completed” even when it is still running, because this counts every tool meta. Count only completed entries (exclude `asyncStarted`) so the progress copy matches the actual tool state.</violation>
</file>

Linked issue analysis

Linked issue: ENG-15627: [P0][Arguijo] boon-agent shows raw "LLM request failed." on token-allocation exhaustion instead of a clear top-up message

Status Acceptance criteria Notes
✅ Compute the non-terminal decision once and use it for both the visible banner text and the payload metadata (nonTerminalToolErrorWarning). The diff introduces an isNonTerminalWarning variable computed from hasUserFacingAssistantReply + shouldMarkNonTerminalToolErrorWarning and uses it to set both warningText and nonTerminalToolErrorWarning in the reply item.
✅ For non-terminal tool failures, render an intermediate status (e.g. "↻ didn't complete — continued (N steps completed)") and do not show the terminal '⚠️' or the word 'failed'; omit the steps count when zero. A new helper buildNonTerminalToolStatusText produces the intermediate copy and the tests assert the warning text does not contain 'failed' or '⚠️' and contains the 'continued' phrasing and step count.
✅ Terminal failures remain unchanged (still render '⚠️ failed' with details when appropriate). The code preserves the previous terminal branch that builds the '⚠️ failed' text; the non-terminal branch is explicitly gated, so terminal behavior is unchanged by this PR.
✅ Unit tests updated to reflect the new intermediate-status copy and CI shards are green. Tests in payloads.errors.test.ts and payloads.test.ts were updated to assert the new copy and metadata; the PR description reports full shard green runs and updated tests transitioning from RED→GREEN for the non-terminal case.

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

Fix all with cubic | Re-trigger cubic

const warningText = isNonTerminalWarning
? buildNonTerminalToolStatusText({
toolSummary,
completedToolCount: params.toolMetas.length,

@cubic-dev-ai cubic-dev-ai Bot Jul 16, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The status can claim async work is “completed” even when it is still running, because this counts every tool meta. Count only completed entries (exclude asyncStarted) so the progress copy matches the actual tool state.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agents/embedded-agent-runner/run/payloads.ts, line 593:

<comment>The status can claim async work is “completed” even when it is still running, because this counts every tool meta. Count only completed entries (exclude `asyncStarted`) so the progress copy matches the actual tool state.</comment>

<file context>
@@ -555,11 +578,21 @@ export function buildEmbeddedRunPayloads(params: {
+      const warningText = isNonTerminalWarning
+        ? buildNonTerminalToolStatusText({
+            toolSummary,
+            completedToolCount: params.toolMetas.length,
+          })
+        : `⚠️ ${toolSummary} failed${errorSuffix}`;
</file context>
Fix with cubic

@monac24

monac24 commented Jul 16, 2026

Copy link
Copy Markdown
Author

Superseded by #53 — consolidated with the §5b kill/remove fix into one reviewable unit. #53 also incorporates the follow-up that drops the leaked internal tool name from the non-terminal status copy.

@monac24 monac24 closed this Jul 16, 2026
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