fix(ingestion): merge task usage field-wise instead of wholesale replace
A payload carrying only totalTokens (e.g. terminal task_notification) no longer wipes previously known input/output/toolUses breakdowns. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
812aee975a
commit
ffd01045d0
1 file changed
+5
-1
@@ -186,7 +186,11 @@ export function foldTaskAgentEvent(
|
||||
...((lastToolName ?? previous?.lastToolName)
|
||||
? { lastToolName: lastToolName ?? previous?.lastToolName }
|
||||
: {}),
|
||||
...((nextUsage ?? previous?.usage) ? { usage: nextUsage ?? previous?.usage } : {}),
|
||||
// Merge field-wise: a payload carrying only totalTokens (e.g. a terminal
|
||||
// Claude task_notification) must not wipe previously known breakdowns.
|
||||
...(nextUsage || previous?.usage
|
||||
? { usage: { ...previous?.usage, ...nextUsage } as ThreadAgentUsage }
|
||||
: {}),
|
||||
firstStartedAt: previous?.firstStartedAt ?? event.createdAt,
|
||||
lastActivityAt: event.createdAt,
|
||||
...(!reactivated && (explicitEndTime ?? (terminal ? event.createdAt : previous?.endedAt))
|
||||
|
||||
Reference in new issue
Block a user