Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix: coalesce replayed tool call records

Steven Enamakel3f1b3f270487
diff --git a/app/src/features/conversations/derived/mapDisplayItems.ts b/app/src/features/conversations/derived/mapDisplayItems.ts
index e3dab1b56f..09a371534c 100644
--- a/app/src/features/conversations/derived/mapDisplayItems.ts
+++ b/app/src/features/conversations/derived/mapDisplayItems.ts
@@ -376,6 +376,25 @@ function uniqueCallId(turn: TurnAccumulator, callId: string, seq: number): strin
* pointer sharing one `seq`, so the tool row orders consistently among the
* turn's narration / thinking. */
function pushToolCall(turn: TurnAccumulator, item: DerivedToolCall): void {
+ // The derived transcript can retain both the initial and terminal record for
+ // one call. They describe one UI step, not two calls: merge the later record
+ // into the existing row instead of manufacturing a `#seq` duplicate.
+ if (item.callId) {
+ const existing = turn.entries.find(entry => entry.id === item.callId);
+ const status = timelineStatusFromDerived(item.status);
+ // A replayed in-flight record is represented as `cancelled` by the
+ // settled mapper; a later terminal record for that same call supersedes
+ // it. Repeated completed IDs remain distinct calls (and stay disambiguated
+ // below), preserving parallel/retry history.
+ if (existing && (existing.status === 'cancelled' || status === 'cancelled')) {
+ existing.status = status === 'cancelled' ? existing.status : status;
+ existing.argsBuffer = stringifyArgs(item.args) ?? existing.argsBuffer;
+ existing.result = item.result ?? existing.result;
+ const failure = toFailureExplanation(item.failure, item.result);
+ if (failure) existing.failure = failure;
+ return;
+ }
+ }
const seq = turn.seq++;
const callId = uniqueCallId(turn, item.callId, seq);
const entry: ToolTimelineEntry = {