fix(coding-agent): defer extension reload requests safely#5735
Open
mitsuhiko wants to merge 1 commit into
Open
fix(coding-agent): defer extension reload requests safely#5735mitsuhiko wants to merge 1 commit into
mitsuhiko wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes extension reload requests safe and usable from all extension contexts, not just slash commands.
ctx.reload()is now available on baseExtensionContext, remains awaitable, and is coordinated byAgentSessionbut uses a deferral mechanism so reloads run only at safe boundaries. Existing command-context reloads keep the old immediate-capable behavior, while tools, event hooks, user bash handlers, session lifecycle hooks, and prompt hooks can request reload without re-entering the runtime while their results are still being applied.This came up because we shipped an example that implied that one can reload extensions from an extension when this was in fact not possible (#4754).
For compatibility,
ctx.reload()remains awaitable but that functionality is now also available onExtensionContextin addition toExtensionCommandContext. The command-context host binding is kept as an optional legacy callback, while the new base-context reload binding is also optional, so custom SDK hosts and tests are not forced to add a new required action.The runner prefers the legacy command reload handler for command contexts when a host provides one, and otherwise falls back to the new base reload handler. This keeps older custom hosts working while letting first-party sessions route reloads through the new
AgentSession.