Repository navigation
fix(usage): pair in-memory call-log copies with persisted rows after #13481 - #18
Merged
Merged
Conversation
…#13481 PR #17 (upstream #13481) keyed persisted call_logs rows on the chatCore traceId instead of the pending-request id, but the list endpoint still deduped the finalized in-memory detail against persisted rows by id only. The two id spaces are disjoint (`${now}-${uuid6}` vs a 6-char trace id), so every request emitted a duplicate row sharing its correlationId: the log UI showed a bogus "· 2 attempts" badge, and a genuine 2-attempt retry showed "4 attempts". The same split made the detail modal lose the in-memory request/response payloads for persisted rows when detailed logging is off. Carry the chatCore traceId onto the pending detail as `callLogId` so the in-memory copy shares the persisted row's id space, and match in-memory copies on `callLogId` with a correlation-key fallback (correlationId + model + provider, deliberately excluding connectionId because the in-memory copy keeps the starting account while the persisted row keeps the post-rotation one). Only in-memory copies are ever skipped, so persisted rows sharing a correlationId — real retries — all survive. The persisted write (`id: traceId`) is unchanged.
claw-io
force-pushed
the
fix/call-log-inmemory-dedupe
branch
from
October 4, 2026 21:58
836c973 to
956787f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After #17 (importing upstream #13481), the request log shows a phantom
· 2 attemptsbadge and a duplicate child row on every request, and a genuine 2-attempt retry reads4 attempts.Root cause
#13481 made persisted
call_logsrows use thechatCoretraceId as theirid(per-attempt rows) instead of the pending-request id. But/api/usage/call-logsstill deduped the finalized in-memory detail against persisted rows byidalone. The two id spaces are disjoint —${now}-${uuid6}vs a 6-char trace id — so an in-memory copy could never match its own persisted row. Every request was rendered twice.The same split made the detail modal lose its in-memory request/response payloads for persisted rows.
Fix
chatCoretraceId onto the pending detail ascallLogId, so the in-memory copy shares the persisted row's id space.callLogId, with a correlation-key fallback (correlationId+ model + provider).connectionIdis deliberately excluded: the in-memory copy keeps the starting account while the persisted row keeps the post-rotation one.correlationId— real retries — all survive./api/logs/[id]resolves a persisted row back to its in-memory detail by the same key.The persisted write (
id: traceId) is unchanged.Verification
New unit suite
tests/unit/call-logs-inmemory-dedupe.test.ts— 9/9 pass, covering: same-correlation drop with differing ids,connectionIdrotation in the fallback,callLogId-carrying copy, real retries (both persisted rows kept), not-yet-persisted retry, null-correlation rows, in-flight rows, and thetrackPendingRequest/findCompletedDetailForCallLoghelpers.npm run typecheck:core— exit 0.Live A/B against the same endpoint and window (phantom group = >1 row sharing a
correlationIdwith disjoint ids):Post-fix detail modal still returns live
requestBody/responseBody; retry semantics unchanged.Notes
Reported and fixed downstream of #17; affects any tree carrying #13481.