Skip to content

refactor: route v2 context changes through context ops#1359

Open
kermanx wants to merge 7 commits into
kimi-code-v2from
xtr/context-ops-wire
Open

refactor: route v2 context changes through context ops#1359
kermanx wants to merge 7 commits into
kimi-code-v2from
xtr/context-ops-wire

Conversation

@kermanx

@kermanx kermanx commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. This PR addresses the v2 context mutation wire format and replay ownership cleanup.

Problem

The v2 agent currently mixes direct context memory mutation with wire record replay concerns. Context updates such as append, remove, clear, compact, and undo need a single operation surface so live execution, replay, migration, and blob offload all stay aligned.

What changed

  • Added an agent-scoped contextOps domain that owns context append/remove/clear/replace operation registration.
  • Routed prompt, loop, task, goal, reminder, and compaction context writes through IAgentContextOpsService instead of direct context splices.
  • Updated v1.5 wire migration and persistence handling so context.append uses flat message args while still tolerating the older nested append shape during restore/offload paths.
  • Updated replay/removal helpers, operation owner bootstrap, domain dependency checks, and the DI scope diagram for the new context operations domain.
  • Adjusted focused tests and stubs around context operations, wire migration, persistence, and replay behavior.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove 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:

  • git diff --check
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm -C packages/agent-core-v2 exec vitest run test/wireRecord/migration/v1.5.test.ts test/wireRecord/persistence.test.ts

Notes:

  • No changeset was added per request.

@changeset-bot

changeset-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0d0bb73

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

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

Copy link
Copy Markdown

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: 2135b7d58d

ℹ️ 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 +42 to +44
// The wire map accepts any `context.${string}` type, so unknown operation
// types can't be caught at compile time — fail the restore loudly instead
// of silently dropping an unclaimed context record.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Move inline rationale into the file header

packages/agent-core-v2/AGENTS.md requires comments in this tree to live only in the top-of-file /** */ block and says to "never beside functions, methods, or statements"; this newly added inline rationale comment violates that convention, as do similar new inline comments elsewhere in the commit. Please fold this rationale into the file header or remove it so the source stays consistent with the documented rule.

Useful? React with 👍 / 👎.

@kermanx kermanx force-pushed the xtr/context-ops-wire branch from 1d55671 to 7d44096 Compare July 4, 2026 08:21
kermanx added 3 commits July 4, 2026 16:29
…ps-wire

# Conflicts:
#	packages/agent-core-v2/src/agent/contextMemory/messageId.ts
#	packages/agent-core-v2/src/agent/goal/goalService.ts
…ps-wire

# Conflicts:
#	packages/agent-core-v2/src/agent/contextMemory/contextMemory.ts
#	packages/agent-core-v2/src/agent/goal/goalService.ts
#	packages/agent-core-v2/src/agent/prompt/promptService.ts
#	packages/agent-core-v2/src/agent/systemReminder/systemReminder.ts
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