From 9099ca60076c6ca30c26bce4f4812e2c1880b9f6 Mon Sep 17 00:00:00 2001 From: Shivam Sharma <91240327+shivamhwp@users.noreply.github.com> Date: Sat, 1 Aug 2026 05:58:59 +0530 Subject: [PATCH] fix(orchestration-v2): stop stamping first-attempt workflow agents as retries Live testing showed every workflow agent wearing a "retry 2" badge on its first attempt: the SDK reports attempt 1-based once an agent starts, and the adapter added 1 on top assuming 0-based. Clamp absent or 0 up to 1 instead of incrementing. Found by a computer-use pass against a real workflow run; the replay fixture's hand-authored attempt: 0 normalizes to the same 1 as before. Co-Authored-By: Claude Fable 5 --- .../server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts index 29ecd3c2a3..78d04a6b6c 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts @@ -4274,7 +4274,11 @@ export function makeClaudeAdapterV2( const status = claudeWorkflowAgentStatus(entry); if (status === null) continue; const phaseIndex = nonNegativeRecordField(entry, ["phaseIndex", "phase_index"]); - const attempt = (nonNegativeInteger(recordField(entry, "attempt")) ?? 0) + 1; + // The live SDK reports `attempt` 1-based once an agent starts + // (verified against 2.1.x: first attempts arrive as 1, and a + // +1 here stamped every agent with a spurious "retry 2" + // badge). Clamp 0 — absent or pre-start — up to 1 instead. + const attempt = Math.max(nonNegativeInteger(recordField(entry, "attempt")) ?? 1, 1); const model = recordField(entry, "model"); const lastToolName = firstRecordField(entry, ["lastToolName", "last_tool_name"]); const tokens = nonNegativeRecordField(entry, ["tokens", "total_tokens"]);