Skip to content

fix: a failed tool call that a later call retried reads as an attempt, not an error (FIX-1957) - #3272

Merged
jhoffner merged 4 commits into
mainfrom
claude/project-thread-ln2y69
Oct 13, 2026
Merged

jhoffner merged 4 commits into
mainfrom
claude/project-thread-ln2y69

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

The problem

When the coordinator's first openWorkstream fails and its retry succeeds, the Shift Manager conversation still shows "openWorkstream failed" in red, even though the workstream opened. This was the third expectation on FIX-1920, and it was still open after that fix merged.

Separately, main is red: a test from FIX-1920 still uses handOff, which FIX-1872 replaced with dispatchTask just before FIX-1920 merged. This PR carries the one-line test fix, so merging it turns main green.

What this does

  • A run of consecutive tool calls in a conversation now shows as one quiet line ("Used 3 tools") that opens to one row per call. The tool line was built for this, but the feed never turned grouping on, so every call showed as its own line.
  • Within a run, a failed call that a later call of the same tool completed reads "Tried openWorkstream" in muted text, and the run doesn't read as failed. A failure with no successful retry after it still reads as failed, in red.

What's asked of you

Nothing here is yours to decide; this PR is the gate for a bug on the direct route. The visible change is the grouping: a conversation with several tool calls in a row shows one line instead of several.

Parts worth reviewing closely

  • statesInRun in ToolLine.tsx decides what counts as a retry. It compares only the tool name, not the arguments, because the real retry changes the lead. It also only looks within one run of consecutive calls.
  • Conversation.tsx now passes groupToolCalls: true (the finding Codex raised).

Fixes FIX-1957 · related FIX-1920 (#3263), FIX-1872 (#3232) · merges to main.

How to review this

How to review this. This is a bug fix on the direct route: there is no spec and no spec PR, because the hard part was the diagnosis and it happened in code. This PR is the only gate, so unlike a spec-backed change, the approach is in scope — nothing here was signed off upstream.

Most valuable here: the diagnosis chain — does the repro actually reproduce the reported failure, is the named cause the real one, does the fix address that cause rather than the symptom, and does the regression test fail without the fix? Then the second path (the legacy shape, the null boundary, the concurrent case, the cancel path).

In scope to challenge: where the guard was placed, any behaviour change a user could notice, and whether this should have been a spec'd feature instead of a fix.

Engineering calls
  • Cause, part 1: the feed called buildItemRenderStream without groupToolCalls, so its group branch never ran. Every call reached ToolLine on its own and could not see a retry.
  • Cause, part 2: runState took the worst state across the run, and each row used its own raw status.
  • A wait (isSuspensionWait) is not a failure, so it is never marked retried; the waiting path from FIX-1901 is unchanged.
  • Opening a retried row still shows that attempt's error; only its label and colour change.
  • The registry's tool.tsx (and its byte-equal copies) is left alone.
  • No changeset: shift-manager is private.
Everything else

Verification:

  • project-workstreams.test.tsx › "its Stream draws an open the coordinator retried as an attempt, not a failure" drives the coordinator through a failed openWorkstream and its successful retry, then reads the project Stream tab. Without the grouping fix it finds no "Used 3 tools" line; with the fix it finds that line, a row reading "Tried openWorkstream", and no "openWorkstream failed".
  • tool-line.test.tsx covers the component: the retried case, plus the same tool failing again and no retry at all, both of which still read "one failed".
  • project-workstreams.test.tsx › "refuses research under the EM…" times out on main every time (main CI). It passes with dispatchTask { post: true }.
  • CI is green on the current head.

Files: packages/shift-manager/src/components/ToolLine.tsx, packages/shift-manager/src/components/Conversation.tsx, packages/shift-manager/test/tool-line.test.tsx, packages/shift-manager/test/project-workstreams.test.tsx.

🤖 Generated with Claude Code

https://claude.ai/code/session_0122p1f6h3nPzdyVvNN9z94p

…, not an error (FIX-1957)

When a run held a failed openWorkstream followed by a successful one, the
transcript kept the run red ("Used 3 tools, one failed") and the first row
read "openWorkstream failed". A failure that a later call of the same tool
in the run completed now reads "Tried openWorkstream" and doesn't make the
run read as failed. A failure with no successful retry is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122p1f6h3nPzdyVvNN9z94p
@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 13, 2026 11:15pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 13, 2026 11:15pm UTC
flow-state-dev-ui Ignored Ignored Preview Oct 13, 2026 11:15pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 13, 2026

Copy link
Copy Markdown

FIX-1957

@jhoffner jhoffner self-assigned this Oct 13, 2026
@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: bb05b27b-bd11-417a-bf0f-c0ebc9f2643a)

Copy link
Copy Markdown
Collaborator Author

Second look + architecture pass

Verdict: the approach is right and proportionate. No blocking findings. Placing the fix in the derivation (statesInRun) rather than in the label/render layer is correct: the group summary and the row labels now share one source of truth. I traced CallDetails too — it still uses the raw stateOf, so a "Tried X" row still shows its error text when opened. The information is demoted, not hidden.

Is there a better approach?

Not a materially better one. Alternatives considered and rejected:

  • Fix at the source (engine marks superseded failures): bigger surface, persisted-shape change (BP-030), and the retry relationship is a presentation concern. Not worth it for this.
  • Compare arguments too: the PR is right that the real retry changes the lead, so args differ by design.

Findings (all non-blocking, for the implementing agent to weigh)

  1. Name-only matching can mask a distinct real failure. openWorkstream fails for project A, then succeeds for project B in the same run → A reads "Tried openWorkstream" and the run reads done. That's the accepted tradeoff in the PR description, and the row still opens to the error, so I'd leave it. Worth one line in the statesInRun doc comment saying the heuristic is deliberately name-only and can over-forgive.
  2. Test shape (BP-003 / "tests verify intent"). The new it bundles three scenarios and the second and third negatives assert the same label. Consider splitting into (a) retried → "Tried" + run done, (b) same tool failing again stays failed, (c) failure followed only by a different tool stays failed. Also add a blank line before the new it (it abuts the previous block). Optionally assert that opening the "Tried openWorkstream" row still shows the original error, which pins the "demoted, not hidden" behavior.
  3. Tiny simplification (optional). items.slice(i + 1).some(...) allocates per failed call. A single reverse pass collecting a Set of names that have a completed call after the cursor does the same in O(n) and reads as "has anything later completed this tool". Only worth it if touching the function again; run sizes are tiny.

Architecture (improve-codebase-architecture lens)

  • Duplicate runState: flow-state/tool.tsx has the same-shaped runState, kept byte-equal to the registry copy by design. The PR correctly leaves it alone. There is no deepening opportunity inside this PR: extracting a shared helper would break the byte-equal constraint, and the registry copy has no retry bug report behind it. If the registry renderer is ever shown to real users with multi-call runs, that is the moment to port statesInRun upstream into the registry source, and the Shift Manager copy then goes back to being byte-equal. Not now.
  • Nothing else in the diff invites a refactor; the change is already surgical.

No changes required to merge from my side.


Generated by Claude Code

… term (FIX-1957)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122p1f6h3nPzdyVvNN9z94p
@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: b6c5c05d-0b23-482b-a67f-bcbe5b0215f2)

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Simplify review (FIX-1957)

Verdict: The change is appropriately small for the product ask. I do not think the approach over-shot into unnecessary abstraction—a derived retried presentation state plus statesInRun is clearer than threading ad-hoc flags through callLabel and runState separately.

What works

  • Layering: Retry forgiveness stays in Shift Manager’s quiet-line presenter, not the engine or item model. That matches how grouping already works (buildItemRenderStream consecutive tool_output only) and avoids schema work unless you later need retry lineage in model context.
  • Factoring: stateOf stays “raw item”; statesInRun adds run context; runState(CallState[]) stays a dumb aggregate. Good separation for tests.
  • Tests: The new case pins the happy path and two negatives (no success, double failure). tool-line.test.tsx passes in isolation.

Alternatives considered (not blockers)

Approach Why you might skip it here
Engine metadata (supersedesItemId / workforce-style RETRY_OF) Authoritative but heavy; tool items do not carry retry lineage today.
Shared helper in @flow-state-dev/ui / registry tool.tsx Worth it if kitchen-sink and registry consumers should show the same “Tried …” semantics; Shift Manager intentionally diverges on copy and layout.
Skip retried enum; pass superseded booleans More parameters at call sites; the union keeps QuietLine + labels aligned.

Limitations to keep in mind (product, not bugs)

  1. Grouping boundary: Only calls in the same consecutive tool group participate. A failed openWorkstream and a later successful one separated by a non–tool_output item will still read as failed at the group level.
  2. Name-only match: Documented in statesInRun; a later success with the same tool name but different intent/args still forgives the earlier failure. If that is too loose for some tools, metadata or args-aware matching would be the next step—not more UI heuristics.

Optional polish (if you touch this again)

  • Precompute const base = items.map(stateOf) once inside statesInRun to avoid repeated stateOf in the inner some and drop slice allocations (irrelevant at n≈2–5, matters only for very long consecutive runs).
  • Split the multi-scenario it into separate tests for easier failure diagnosis.
  • Trim redundant restatement of the retry rule in the file header if statesInRun’s docblock is the canonical explanation.

No changes requested for merge from a simplify lens.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Snob — already tight. No POC.

Read packages/shift-manager/src/components/ToolLine.tsx and packages/shift-manager/test/tool-line.test.tsx at e5a1590, and flow-state/tool.tsx's runState (different item type; this PR leaves that copy alone, which is already recorded).

statesInRun is the one walk the group line and the rows share. Inlining it into ToolLineGroup moves those lines. A reverse Set of completed names is more code for the same labels. Mapping a retry to completed and special-casing the label needs a second argument, so the retried state is the smaller way to get "Tried {name}" and muted text. runState taking those states is what keeps the walk at one.

The header sentence is the words ("Tried openWorkstream", the run not failed), next to the waiting sentence. The statesInRun note is the name-only rule. The test's two "one failed" renders are the two misses (the same tool fails again, a different tool completes). Splitting them adds lines.

A rewrite would not shrink the contract.

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

…oordinator does now (FIX-1957)

main went red when FIX-1920's new test (still calling handOff) merged after
FIX-1872 replaced handOff with dispatchTask post. Same one-line change
FIX-1872 made to askFor in this file.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122p1f6h3nPzdyVvNN9z94p

Copy link
Copy Markdown
Collaborator Author

Test (1/3) failed on project-workstreams.test.tsx › "refuses research under the EM…". That failure is not from this PR; main has been red with it since #3263 merged (main CI run).

The two merges conflict in meaning. #3232 (FIX-1872) replaced the coordinator's handOff with dispatchTask { post: true } and updated askFor in this file. Then #3263 (FIX-1920) added a new test that still scripts handOff, so the ask never reaches the lead's session.

I pushed the same one-line change into this PR (89afaed): the test now uses dispatchTask { post: true, assignee, target }. That file passes locally (13/13). If main gets the fix first, the change will no-op.


Generated by Claude Code

@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 15177b5f-0f4d-4c5c-a762-cb9605575a79)

jhoffner pushed a commit that referenced this pull request Oct 13, 2026
…orkstream test

The coordinator's post is now a dispatchTask row (FIX-1872), so the scripted
script must post with dispatchTask, not handOff. Same one-line change as #3272;
it no-ops once main carries it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AbWGaPRHHDktemkzFXph5b
@jhoffner

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T23:09:42.514481Z 89afaed Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89afaed546

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…pen reads as an attempt (FIX-1957)

Conversation drew every tool call as its own line: it never passed
groupToolCalls, so its group branch never ran and ToolLineGroup never saw
the retry that followed a failed call. The new test drives the coordinator
through a failed then retried openWorkstream and reads the project Stream:
on the previous head it finds no 'Used 3 tools' line.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122p1f6h3nPzdyVvNN9z94p
@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 63ba2e46-5fce-4360-82a4-56ebaa71c2fd)

@jhoffner
jhoffner merged commit 7c9cc1b into main Oct 13, 2026
20 of 22 checks passed
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.

2 participants