Skip to content

fix(coding-agent): defer extension reload requests safely#5735

Open
mitsuhiko wants to merge 1 commit into
mainfrom
flexible-reload
Open

fix(coding-agent): defer extension reload requests safely#5735
mitsuhiko wants to merge 1 commit into
mainfrom
flexible-reload

Conversation

@mitsuhiko

Copy link
Copy Markdown
Member

This makes extension reload requests safe and usable from all extension contexts, not just slash commands. ctx.reload() is now available on base ExtensionContext, remains awaitable, and is coordinated by AgentSession but 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 on ExtensionContext in addition to ExtensionCommandContext. 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.

@mitsuhiko mitsuhiko added the to-discuss This ticket requires further discussion outside of triage. label Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

to-discuss This ticket requires further discussion outside of triage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant