Skip to content

refactor(agent-core-v2): remove idle reminder reconciliation - #5235

Merged
sailist merged 1 commit into
mainfrom
loop-421-stack/02-remove-reminder-reconciliation
Nov 23, 2026
Merged

sailist merged 1 commit into
mainfrom
loop-421-stack/02-remove-reminder-reconciliation

Conversation

@sailist

@sailist sailist commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Part 2/7 of the loop stack onto main. Identical diff to #5207, previously reviewed and merged into the loop integration branch. Stacked on #5234; the shown diff contains only this PR's own changes.

Requirement or Bug

Reminder providers already deliver through loop.remind, but plugin reloads and SDK swarm/tower transitions can bypass that timing by reconciling while idle and forcing an immediate flush. Internal task 411 narrows the change to removing that idle path while preserving the central ReminderService and its normal injection lifecycle.

Bug Reproduction Steps

N/A — this is a reminder-lifecycle refactor with intentional timing changes, not a bug reproduction PR.

Root Cause

IAgentReminderService.reconcileWhenIdle acquired loop quiescence, evaluated a selected provider, and called flushReminders() immediately. That created a second delivery path outside the ordinary onWillBeginStep / loop.remind consumption points. This PR removes the alternate path rather than adding another workaround.

Code Changes

  • Keep AgentReminderService, register, and notify; normal provider evaluation and message construction are unchanged.
  • Remove reconcileWhenIdle from the service interface and implementation.
  • Remove its three callers: plugin session-start refresh, SDK swarm transitions, and SDK tower transitions. These reminders now wait for the existing loop injection points.
  • Drive tests through the existing context-injector hook. Cover deferred registration, delayed plugin refresh, WaitFor independence from unrelated tool descriptions, and the real dynamic-tool removal announcement.

No changeset is included, as explicitly requested by the author.

Behavior Changes and Affected Users

Behavior Before After Affected users and compatibility Coverage
Normal register / notify delivery Providers and notifications use loop.remind and are consumed at subsequent step/turn injection points Unchanged All reminder domains; no compatibility impact Reminder service, todo, permission-mode tests
Plugin session-start refresh /reload can inject refreshed session-start guidance immediately while idle Refresh is visible at the next normal step or non-promptOnly turn; no turn is started Plugin reload callers. No legacy immediate-flush escape hatch; the timing change is intentional and needs maintainer approval Plugin service tests assert one message before the next hook and the refreshed second message afterward
SDK swarm/tower transitions Mode transitions can reconcile and flush their reminders before the RPC returns Mode changes take effect immediately, but their reminders arrive at the next normal injection point SDK consumers and products using swarm/tower. No legacy immediate-flush escape hatch; the timing change is intentional and needs maintainer approval SDK swarm/tower tests and reminder-domain tests
Other loop reminder processing flushReminders() and existing loop-owned consumption remain available Unchanged; only the service-level idle reconciliation shortcut is removed Loop and KAP reload paths retain their existing flush behavior Full Linux remote suite; unrelated failures listed below

Verification

  • tsc --noEmit for agent-core-v2: passed
  • tsc --noEmit for node-sdk: passed
  • Full pnpm lint: passed
  • Plugin tests: 11/11 passed
  • Desktop browser registration tests: 7/7 passed
  • Focused reminder, todo, permission-mode, and WaitFor/fork-parity tests: passed
  • Full Linux remote suite: 27,980 tests passed, 7 failed. Twelve additional Desktop suites could not start because Electron was not installed. The seven failures are unrelated existing TUI startup timeouts (4), the local-pages Electron fuse check (1), and remote process-group checks (2). No plugin, fork-parity, or desktop browser-registration failures remained.

Checklist

  • I have read the CONTRIBUTING document.
  • Related context is linked: internal task 411; this is not an external PR.
  • I have added tests that prove the reminder lifecycle works.
  • The behavior-change table above is complete; maintainer approval is still needed for intentionally removing the legacy immediate-flush behavior without an escape hatch.
  • A changeset was intentionally omitted at the author's request, despite the repository's release-artifact changeset convention.
  • No user-documentation update is needed: this changes internal reminder timing without adding or changing a documented workflow.

Keep register and notify on the normal loop.remind path.
Defer plugin, swarm, and tower reminders to the next step or turn.
Update tests to drive the existing context-injector hook.
@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f3e6531

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 commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T04:04:34.773034Z f3e6531 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@f3e6531
npx https://pkg.pr.new/@moonshot-ai/kimi-code@f3e6531

commit: f3e6531

@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: 7f1e472c8e

ℹ️ 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 253 to 255
readonly _serviceBrand: undefined;
register<D = unknown>(variant: string, provider: ContextInjectionProvider<D>): ReminderRegistration;
notify(content: string, notification: ReminderNotification): void;

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 Add the required library changeset

This commit changes source code in both @moonshot-ai/agent-core-v2 and @moonshot-ai/kimi-code-sdk, but it adds no .changeset entry. Without the required technical changeset, the release workflow will neither record nor version these library changes; add a patch changeset covering both affected packages.

AGENTS.md reference: AGENTS.md:L169-L170

Useful? React with 👍 / 👎.

Comment on lines 115 to 117
if (this.scopeContext.agentId !== MAIN_AGENT_ID) return;
this.refreshPending = true;
await this.skillCatalog.ready;

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 Persist the deferred plugin refresh

When a plugin-enabled session is reloaded and then closed or the server restarts before another agent step begins, this now records the refresh only in the non-replayable pluginSessionStartRefreshPendingKey. On resume that flag resets to false while the durable pluginSessionStartSnapshotKey still contains the old guidance, so resolveDesiredSessionStart keeps returning the stale snapshot on future prompts; the removed idle reconciliation previously rendered and persisted the refreshed snapshot before returning. Persist the pending refresh or materialize it before reload completes.

AGENTS.md reference: AGENTS.md:L111-L113

Useful? React with 👍 / 👎.

@7Sageer 7Sageer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

插件 refresh 与快照恢复的边界还需要核对;release-note 的处理如已有团队约定,可按原任务保留。

@@ -115,7 +115,6 @@ export class AgentPluginService extends Service implements IAgentPluginService {
if (this.scopeContext.agentId !== MAIN_AGENT_ID) return;
this.refreshPending = true;
await this.skillCatalog.ready;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P1] refreshPending 与 pluginSessionStartSnapshotKey 的 replay 属性不同。/reload 后若在下一 step 前退出或重启,pending 标志会丢失,而持久化快照仍是旧内容,后续 provider 会继续使用旧 session-start 提示。原先 idle reconcile 会在 reload 返回前物化新快照。请让刷新请求跨重入保留,或让下一 step 能检测插件版本并刷新,同时补「刷新后立即关闭再恢复」的测试。

7Sageer
7Sageer previously approved these changes Nov 23, 2026
Base automatically changed from loop-421-stack/01-retry-tool-call-args to main November 23, 2026 03:58
@sailist
sailist dismissed 7Sageer’s stale review November 23, 2026 03:58

The base branch was changed.

@sailist
sailist force-pushed the loop-421-stack/02-remove-reminder-reconciliation branch from 7f1e472 to f3e6531 Compare November 23, 2026 04:02
@sailist
sailist requested a review from 7Sageer November 23, 2026 04:03
@sailist
sailist merged commit 701bb53 into main Nov 23, 2026
25 checks passed
@sailist
sailist deleted the loop-421-stack/02-remove-reminder-reconciliation branch November 23, 2026 04:43
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 25, 2026
…reconciling when idle

Remove reconcileWhenIdle from the reminder service and the plugin
session-start call; the SDK's swarm/tower (and the fork's hello-world)
calls are gone and the tests drive a step hook instead (MoonshotAI#5235). Also carry
argsRaw in the registered-user-tools snapshot missed by the MoonshotAI#5268 update.
Ledger: 5320/5304 not-applicable (root e2e harness), 5078 equivalent
(testkit already ported).
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