fix(server): persist late Claude tool results after turn finalize #7192
Closedmaslinedwin(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/7192/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 2374Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2332,4 +2357,7 @@23322357 payload: result ?? { status },23332358 },23342359 });2335- context.inFlightTools.delete(index);2360+ rememberFinalizedToolAwaitingResult(context.finalizedToolsAwaitingResult, {2361+ tool,2362+ turnId: turnState.turnId,2363+ });apps/server/src/provider/Layers/ClaudeAdapter.ts line 2306Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2303,4 +2328,3 @@23032328 return;23042329 }230523302306- for (const [index, tool] of context.inFlightTools.entries()) {
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 2852Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2807,0 +2833,21 @@2833+ ...(eventTurnId ? { turnId: eventTurnId } : {}),2834+ itemId: asRuntimeItemId(tool.itemId),2835+ payload: {2836+ itemType: tool.itemType,2837+ status: itemStatus,2838+ title: tool.title,2839+ ...(tool.detail ? { detail: tool.detail } : {}),2840+ ...(tool.agentId ? { agentId: tool.agentId } : {}),2841+ ...(tool.parentToolUseId ? { parentToolUseId: tool.parentToolUseId } : {}),2842+ data: toolData,2843+ },2844+ providerRefs: nativeProviderRefs(context, {2845+ providerItemId: tool.itemId,2846+ }),2847+ raw: {2848+ source: "claude.sdk.message",2849+ method: "claude/user",2850+ payload: message,2851+ },2852+ });2853+ }
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -1014,4 +1014,5 @@10141014 return false;10151015 }10161016 if (previous.activityKind === "tool.completed") {1017- return false;1017+ // Same toolCallId after complete is a late result amendment, not a new call.1018+ return previous.toolCallId !== undefined && previous.toolCallId === next.toolCallId;
- @@ -993,3 +994,14 @@993994 });994995 continue;995996 }997+ // Late tool_result after completeTurn force-completes every in-flight998+ // tool is not adjacent to its row. Merge by toolCallId, not adjacency.999+ const toolCallId =1000+ entry.activityKind === "tool.updated" || entry.activityKind === "tool.completed"1001+ ? entry.toolCallId1002+ : undefined;1003+ if (toolCallId !== undefined) {1004+ const existingIndex = toolRowIndex.get(toolCallId);1005+ if (existingIndex !== undefined) {1006+ collapsed[existingIndex] = mergeDerivedWorkLogEntries(collapsed[existingIndex]!, entry);1007+ continue;
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
7cdc2096-ed25-4de8-a55b-41a5374492f4You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share