Skip to content

feat: flatten tool call records#25

Merged
kermanx merged 10 commits into
mainfrom
codex/flatten-toolcall-wire-migration
May 25, 2026
Merged

feat: flatten tool call records#25
kermanx merged 10 commits into
mainfrom
codex/flatten-toolcall-wire-migration

Conversation

@kermanx
Copy link
Copy Markdown
Collaborator

@kermanx kermanx commented May 25, 2026

Related Issue

N/A

Description

  • Flatten ToolCall records by moving tool names and arguments to the top level across the provider and agent record paths.
  • Bump the agent wire protocol to 1.1 and migrate legacy 1.0 records during replay while keeping --output-format stream-json output compatible.
  • Expose the record migration subpath for visual replay and update replay/rendering tests for the flattened shape.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Validation

  • pnpm --filter @moonshot-ai/migration-legacy test
  • pnpm --filter @moonshot-ai/kimi-code test -- test/cli/run-prompt.test.ts
  • pnpm exec changeset status --since origin/main

@kermanx
Copy link
Copy Markdown
Collaborator Author

kermanx commented May 25, 2026

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5bdefcebf6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .changeset/flatten-toolcall.md
Comment thread apps/vis/server/src/lib/wire-replay.ts
Comment thread packages/agent-core/src/agent/records/migration/v1.1.ts Outdated
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 25, 2026

🦋 Changeset detected

Latest commit: 7c8a2a6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@moonshot-ai/kosong Minor
@moonshot-ai/agent-core Minor
@moonshot-ai/kimi-code Minor
@moonshot-ai/migration-legacy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kermanx kermanx requested a review from wbxl2000 May 25, 2026 12:01
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af0755c3cb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agent-core/src/agent/records/migration/v1.1.ts
Comment thread packages/migration-legacy/src/sessions/translator.ts Outdated
Comment thread apps/vis/server/src/lib/wire-replay.ts
Comment thread packages/migration-legacy/src/sessions/translator.ts Outdated
Comment thread apps/kimi-code/src/cli/run-prompt.ts Outdated
Comment thread packages/agent-core/src/agent/records/migration/v1.1.ts Outdated
@kermanx
Copy link
Copy Markdown
Collaborator Author

kermanx commented May 25, 2026

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41e2f348f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +57 to +60
if (isLegacyToolCall(v)) {
value[key] = migrateToolCall(v);
} else {
migrate(v);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restrict v1.0 tool-call migration to known record fields

The migration currently rewrites any object matching { type: 'function', id: string, function: object } anywhere in a record tree, so replaying a v1.0 session can silently mutate unrelated user payloads (for example context.append_loop_event.event.args when a tool argument happens to use those keys). Because replay then rewrites the log to v1.1, this becomes permanent data corruption; the transform should be scoped to known tool-call containers (e.g. message.toolCalls) instead of recursive global replacement.

Useful? React with 👍 / 👎.

Comment thread apps/vis/server/src/lib/wire-replay.ts
@kermanx
Copy link
Copy Markdown
Collaborator Author

kermanx commented May 25, 2026

@codex

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@kermanx kermanx merged commit c4dd1c7 into main May 25, 2026
4 checks passed
@kermanx kermanx deleted the codex/flatten-toolcall-wire-migration branch May 25, 2026 15:02
@github-actions github-actions Bot mentioned this pull request May 26, 2026
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.

2 participants