Skip to content

Revise before turn fails with canonical_args_hash_conflict after the model paged a tool result #5329

Closed

Description

@MasamiYui

What happened

Image

"Revise before turn" (editing an earlier message) fails with the toast "Action failed — The task action failed. Try again later." Retrying does not help. The main-process log shows:

Error occurred in handler for 'sessions:reviseBeforeTurn': RuntimeHostOperationError:
Session conversation copy could not be committed:
Conversation copy RuntimeEvent ledger is corrupt: canonical_args_hash_conflict
  at SqliteRuntimeStore.importConversationCopyRuntimeEvents (@maka/storage/dist/sqlite-runtime-store.js:250)
  at cloneConversationRuntimeLedger (@maka/runtime/dist/conversation-copy.js:471)
  at #copyAdmitted (@maka/runtime-host/dist/server/session-revision-coordinator.js:395)

The source Session's ledger is not corrupt: running scanToolLedger over its stored runtime_events reports zero issues, and every tool_dispatch.canonicalArgsHash matches its function_call.args.

Root cause

cloneConversationRuntimeLedger rewrites the arguments of a Read (and ArchiveRead) call when the path points at a tool result — maka://runtime/tool-results/<runtimeEventId> or its maka://read/<base64> continuation form — because the embedded RuntimeEvent id belongs to the source Session and must name the copied event instead. The paired tool_dispatch event, however, is copied verbatim and still carries the hash of the source bytes. importConversationCopyRuntimeEvents re-scans the copied ledger, recomputes the hash from the rewritten args, and rejects the copy with canonical_args_hash_conflict.

The existing copy tests only had Read calls without a tool_dispatch event, so the scanner never had anything to compare.

How to reproduce

  1. In a Session, run a tool whose output is large enough to be truncated (e.g. Bash printing ~10 KB), so the result ends with a next continuation address.
  2. Let the model follow it, i.e. call Read with path: maka://read/… that decodes to maka://runtime/tool-results/toolop_…_response.
  3. Send at least one more turn.
  4. Edit / "revise" that later turn (anything after the paging Read).

Expected: a new revision Session is created.
Actual: "Action failed" toast; canonical_args_hash_conflict in the log on every retry.

It looks intermittent only because all of the following must hold: the model paged a tool result, and the revised turn is after that call so the copy slice includes it. Sessions that only page files (maka://read/<base64 file path>) are unaffected — those args are rewritten to identical bytes.

Environment

  • Maka: 0.2.0-dev.31.20260913 (nightly, packaged)
  • OS: macOS darwin 25.6.0 (arm64)
  • Surface: Desktop → Runtime Host
  • Electron 43.4.1 / Node 24.18.1

Fix

After rewriting a Read/ArchiveRead call's args in cloneConversationRuntimeLedger, recompute canonicalArgsHash on the dispatch event paired with it (same invocationId + providerToolCallId, matching how scanToolLedger pairs them). Only do so when the source dispatch matched its source call, so a genuinely corrupt source ledger is still refused. tool_operations / tool_journal_events are rebuilt from events on import, so no separate table fix is needed.

Test: a copy fixture with Bash → Read of the Bash result, each with its tool_dispatch. Fails with the exact production error before the fix, passes after.

Activity

  1. added
    bug
    on Sep 17, 2026
  2. ggbdpq commented on Sep 17, 2026

    @ggbdpq
    Contributor

    take

  3. added a commit that references this issue on Sep 23, 2026
    2002f64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions