fix(reload): re-inject plugin session-start reminder after /reload#1086
Conversation
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 detectedLatest commit: 002270a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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 👍 / 👎.
| const result = await this.resumeSession({ sessionId: summary.id }); | ||
| if (input.forcePluginSessionStartReminder === true) { | ||
| await this.sessions.get(summary.id)?.appendPluginSessionStartReminder(); | ||
| } | ||
| return result; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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".
| return mainAgent.context.history.some( | ||
| (message) => | ||
| message.origin?.kind === 'injection' && | ||
| message.origin.variant === 'plugin_session_start', | ||
| ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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".
| export interface ReloadSessionOptions { | ||
| readonly forcePluginSessionStartReminder?: boolean; | ||
| } |
There was a problem hiding this comment.
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.
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |

Related Issue
No linked issue — this came from user feedback that
/reloadcannot refresh plugin session-start reminders.Problem
/reloadreloaded 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/reloadfor plugin development.What changed
<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.forcePluginSessionStartReminderflag that only the explicit/reloadcommand sets, so/configand/experiments(which reuse the reload RPC) do not spam the transcript.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.