Repository navigation
Description
What happened
Copying a conversation (branch, side conversation, or revise/edit-and-resend) leaves the nested identity of any model_call_attempt_recorded AgentRun event at the source session/run, which silently drops the copied session's spend and breaks Daily Review.
cloneAgentRunEvent in packages/runtime/src/conversation-copy.ts has typed rewriters for provider_request_captured, provider_request_attempt_recorded, and history_compact_checkpoint_recorded, but no branch for model_call_attempt_recorded. That event falls through to the tail return, which rewrites only the envelope (id / sessionId / runId) and leaves data untouched. The nested ModelCallAttempt payload therefore keeps the source sessionId / runId / attemptId (the payload identity that, per packages/core/src/model-call-attempt.ts, must agree with the envelope).
Consequences:
- The model-call projection guard at
packages/storage/src/model-call-ledger.ts:293(attempt.sessionId !== run.session_id || attempt.runId !== run.run_id) throws, and the record is counted as unreadable (usage_model_call_projection_checkpoints.unreadable_events). - Daily Review reads canonical usage through
readCompleteCanonicalUsage(packages/runtime-host/src/server/canonical-usage-reader.ts), which throwsCanonicalUsageProjectionIncompleteErrorwhenunreadableRecords > 0. Generation then fails withprojection_incomplete— "Daily Review is waiting for canonical Usage repair". Because Daily Review queries the global (no-sessionId) range, a single broken copied session poisons the whole day's review. attemptIdis the ledger's global primary key. Rewriting onlysessionId/runId(making the guard pass) without also rewritingattemptIdwould let the copy overwrite the source session's accounting row — soattemptIdmust be rewritten too.
Note: the Session Inspector ("Trace") does not surface this. Its unreadable counter (packages/runtime-host/src/server/execution-inspect-coordinator.ts) only counts events whose decodeModelCallAttempt throws; the copied payload is a valid ModelCallAttempt with the wrong identity, so decode succeeds and the inspector shows no problem.
How to reproduce
- In a session with a configured LLM connection, send a message and get a reply (this writes a
model_call_attempt_recordedevent; an empty session will not reproduce). - Copy that turn — Branch (turn footer), Side chat (
/side, workbar tool, or ⌘K "Open side chat"), or Edit & resend (pencil on a sent user message). - Open Daily Review (Module Hub → Automations → Daily Review, or ⌘K "Open · Daily Review") and generate it.
- Generation fails with
projection_incomplete/ "Daily Review is waiting for canonical Usage repair".
- Generation fails with
- Or verify directly in SQLite after the copy + one usage read:
The copied session's run shows
SELECT session_id, run_id, unreadable_events FROM usage_model_call_projection_checkpoints WHERE unreadable_events > 0;
unreadable_events > 0.
Environment
- Maka commit:
main@ 902d785 (also present on currentmain) - OS: macOS 15.7.3 (Darwin 24.6.0)
- Surface: Desktop / Runtime Host (the desktop copy path runs through
packages/runtime-host/src/server/session-revision-coordinator.ts:503→cloneConversationRuntimeLedger) - Running from source (Node via repo toolchain)
Logs, screenshots, or additional context
Reproducible and persistent: once a run's projection checkpoint advances past the unreadable record, the bad unreadable_events does not self-heal, so Daily Review keeps failing until the projection is repaired.
A fix (add a model_call_attempt_recorded rewriter that maps the payload sessionId/runId to the target, attemptId to the fresh envelope id, and the owned traceId/logicalCallId/captureArtifactId through the copy's identity maps) plus a regression test is ready and will be linked as a PR.
Activity