Skip to content

fix(reload): re-inject plugin session-start reminder after /reload#1086

Merged
wbxl2000 merged 4 commits into
mainfrom
plugin-reload
Jun 25, 2026
Merged

fix(reload): re-inject plugin session-start reminder after /reload#1086
wbxl2000 merged 4 commits into
mainfrom
plugin-reload

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — this came from user feedback that /reload cannot refresh plugin session-start reminders.

Problem

/reload reloaded plugins and resumed the session, but the assistant kept seeing the stale <plugin_session_start> reminder from before the reload. As a result, newly installed, enabled, or edited plugin skills only took effect in a fresh session, which defeats part of the purpose of /reload for plugin development.

What changed

  • After the session is reloaded and resumed, append a fresh <plugin_session_start> reminder to the main agent reflecting the currently enabled plugins, then flush records so it is persisted and visible on the wire. The reminder notes that it supersedes any earlier one, since the previous reminder remains in history.
  • Gate this on a new forcePluginSessionStartReminder flag that only the explicit /reload command sets, so /config and /experiments (which reuse the reload RPC) do not spam the transcript.
  • Extract the plugin session-start rendering into a shared helper reused by the turn-loop injector and the reload path, so the two cannot drift apart.
  • Add integration tests for forced reload (appends updated content), reload without the flag (no append), and reload with no session start (no append), plus unit tests for the shared helper.

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.

Reload reloaded plugins and resumed the session, but the model kept seeing the stale plugin session-start reminder from before the reload, so plugin skill changes only took effect in a fresh session.

Append a fresh plugin_session_start reminder to the main agent after reload, gated on a new forcePluginSessionStartReminder flag that only the explicit /reload command sets, so config and experiment toggles that reuse the reload RPC do not spam the transcript.
@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 002270a

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

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code 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

@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

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

commit: 002270a

@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: 08d82c68e4

ℹ️ 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".

registry: mainAgent.skills?.registry,
log: mainAgent.log,
});
if (reminder === undefined) return;

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 Supersede removed plugin session-start reminders

When /reload is used after a plugin with a prior plugin_session_start has been disabled/removed, or its session-start skill no longer resolves, renderPluginSessionStartReminder returns undefined and this early return appends nothing. The old reminder remains in the agent context, and the injector also dedups on any existing plugin_session_start, so the next turn still sees stale plugin instructions instead of the currently enabled empty set. In the forced reload path, append a superseding “no current plugin session starts” reminder when an earlier one exists, or remove/neutralize the old reminder.

Useful? React with 👍 / 👎.

Comment on lines +455 to +459
const result = await this.resumeSession({ sessionId: summary.id });
if (input.forcePluginSessionStartReminder === true) {
await this.sessions.get(summary.id)?.appendPluginSessionStartReminder();
}
return result;

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 Return the post-append reload state

With forcePluginSessionStartReminder: true, the ResumeSessionResult is built before the fresh reminder is appended, so SDK callers receive a summary whose agents.main.context/replay is missing the reminder, and Session.reloadSession() stores that stale value in resumeState. Any caller that inspects getResumeState() or the returned summary immediately after a forced reload will see pre-reload plugin instructions until a later resume; append before constructing the result, or recompute the result after appending.

Useful? React with 👍 / 👎.

…inder

Append the plugin session-start reminder before constructing ResumeSessionResult so SDK callers reading getResumeState() see the refreshed plugin context instead of a pre-reload snapshot.

When a plugin with a prior plugin_session_start reminder is disabled or removed, append a neutralizing reminder so the model does not keep following stale plugin instructions.
@wbxl2000

Copy link
Copy Markdown
Collaborator Author
image

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

@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: 7685f9b5e7

ℹ️ 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 +585 to +589
return mainAgent.context.history.some(
(message) =>
message.origin?.kind === 'injection' &&
message.origin.variant === 'plugin_session_start',
);

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 Neutralize compacted plugin reminders

When the earlier plugin reminder has already been full-compacted, ContextMemory.applyCompaction replaces it with a compaction_summary message, so this origin-only scan no longer detects that stale plugin instructions may still be present in the model context. In that compacted-session case, removing/disabling the plugin and running /reload takes the else return path instead of appending the neutralizing reminder, so the stale summarized plugin guidance can continue to apply.

Useful? React with 👍 / 👎.

A full compaction folds the discrete plugin_session_start reminder into a compaction_summary, so the origin-only scan no longer detects it. Also treat a compaction_summary in history as a signal to neutralize, so disabling or removing a plugin after compaction still emits a superseding 'no active plugin session starts' reminder.
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

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

ℹ️ 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 +169 to +171
export interface ReloadSessionOptions {
readonly forcePluginSessionStartReminder?: boolean;
}

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 Thread reload options through KimiHarness

SDK callers that use the harness-level reload path still cannot opt into the forced plugin reminder: KimiHarness.reloadSession remains typed as ResumeSessionInput and calls active.reloadSession() / this.rpc.reloadSession({ sessionId: id }) without forwarding this option. In that path, edited or newly enabled plugin session-start skills still reload without the fresh reminder this change is adding, unless the caller already holds a Session and bypasses the harness.

Useful? React with 👍 / 👎.

…Session

KimiHarness.reloadSession is a public SDK entry point; forward forcePluginSessionStartReminder to both the active-session and RPC reload paths so SDK callers using the harness can opt into the refreshed plugin reminder too.
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 002270a005

ℹ️ 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".

@wbxl2000 wbxl2000 merged commit fe667d7 into main Jun 25, 2026
8 checks passed
@wbxl2000 wbxl2000 deleted the plugin-reload branch June 25, 2026 15:16
@github-actions github-actions Bot mentioned this pull request Jun 25, 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.

1 participant