fix(coding-agent): scoped subagent local root overrides
Keep subagent localProtocolOptions on their ToolSession instead of installing them as the process-global LocalProtocolHandler override. No-context URL consumers therefore retain the active top-level session's mapping while tan and task subagents continue to resolve through their caller context. Add SDK regression coverage proving subagent creation preserves an existing global mapping. Fixes #6971 (cherry picked from commit a02eef174b03036dc960c842a0901d22333ad9cd)
This commit is contained in:
@@ -390,8 +390,9 @@ export class LocalProtocolHandler implements ProtocolHandler {
|
||||
|
||||
/**
|
||||
* Install a process-global override that wins over the AgentRegistry-based
|
||||
* derivation. Used by SDK consumers that wire `localProtocolOptions` on
|
||||
* `createAgentSession` and by subagents that share their parent's root.
|
||||
* derivation. Used by top-level SDK consumers that wire
|
||||
* `localProtocolOptions` on `createAgentSession`; subagents keep their
|
||||
* inherited mapping session-bound.
|
||||
*/
|
||||
static setOverride(value: LocalProtocolOptions | undefined): void {
|
||||
LocalProtocolHandler.#override = value;
|
||||
|
||||
@@ -1772,7 +1772,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
||||
getArtifactsDir,
|
||||
getSessionId: () => sessionManager.getSessionId?.() ?? null,
|
||||
};
|
||||
if (options.localProtocolOptions) {
|
||||
if (options.localProtocolOptions && !options.parentTaskPrefix) {
|
||||
LocalProtocolHandler.setOverride(options.localProtocolOptions);
|
||||
}
|
||||
toolSession.getArtifactsDir = getArtifactsDir;
|
||||
|
||||
Reference in New Issue
Block a user