Skip to content

feat(tools): scope operation journal identity by turn - #6

Draft
luoye520ww wants to merge 6 commits into
developfrom
feat/tool-operation-journal-turn-scoped
Draft

feat(tools): scope operation journal identity by turn#6
luoye520ww wants to merge 6 commits into
developfrom
feat/tool-operation-journal-turn-scoped

Conversation

@luoye520ww

@luoye520ww luoye520ww commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Replacement implementation for the rejected KunAgent#692 operation-journal direction.

Problem

The previous rejected design keyed operations by threadId + callId. Compatibility model paths can produce fallback call ids such as call_1 across multiple turns in the same thread, causing unsafe result reuse.

Changes implemented

  • Add kun/src/reliability/operation-journal.ts with a turn-scoped identity:
    • threadId
    • turnId
    • callId
    • toolName
    • argsHash
  • Add stable argument hashing with sorted object keys.
  • Integrate the journal into LocalToolHost after approval/pre-hook/read/sandbox checks and before tool execution.
  • Reuse only exact completed identities.
  • Mark failed executions as failed and aborted executions as unknown.
  • Add regression tests for:
    • same thread + different turn + fallback call_1 not colliding;
    • same exact identity reusing completed result;
    • same call id with different args not reusing.
  • Removed the non-code .kun/review-plans file from this PR scope.

Important review blocker

The current LocalToolHost diff appears to include an unintended behavior regression around user_input / request_user_input and create_plan default tool construction. Before this can go upstream, restore the develop-branch structured GUI user-input behavior and createCreatePlanTool integration while preserving the operation journal changes.

Validation to run locally

npm --prefix kun run typecheck
npm --prefix kun test
npm run typecheck
npm test

I could not run local commands from this environment, so this remains draft until CI/local validation passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant