From 33f728582615a5ac045a54d39531e3d0d1983306 Mon Sep 17 00:00:00 2001 From: kiki Date: Sat, 30 May 2026 09:51:08 -0400 Subject: [PATCH] fix: forward modelRegistry and model to workflow subagents Subagents created by the workflow tool fail silently because createAgentSession() receives no modelRegistry or model, so the LLM provider cannot authenticate. This passes the parent session's modelRegistry and model from the tool execution context through to the WorkflowAgent, matching how @tintinweb/pi-subagents handles the same case. Fixes: subagents returning null/empty output despite appearing to complete successfully. --- src/agent.ts | 9 ++++----- src/workflow-tool.ts | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/agent.ts b/src/agent.ts index 0164bcf..384fd2c 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -57,13 +57,12 @@ export class WorkflowAgent { customTools.push(createStructuredOutputTool({ schema: options.schema, capture }) as unknown as ToolDefinition); } + const agentDir = getAgentDir(); const { session } = await createAgentSession({ cwd: this.cwd, - agentDir: getAgentDir(), - sessionManager: SessionManager.inMemory(), - settingsManager: SettingsManager.inMemory({ - compaction: { enabled: false }, - }), + agentDir, + sessionManager: SessionManager.inMemory(this.cwd), + settingsManager: SettingsManager.create(this.cwd, agentDir), customTools, ...this.sessionOptions, }); diff --git a/src/workflow-tool.ts b/src/workflow-tool.ts index 890ba7a..087c269 100644 --- a/src/workflow-tool.ts +++ b/src/workflow-tool.ts @@ -88,6 +88,10 @@ export function createWorkflowTool(options: WorkflowToolOptions = {}): ToolDefin args: params.args, signal, concurrency: options.concurrency, + session: { + modelRegistry: ctx.modelRegistry, + model: ctx.model, + }, onLog(message) { snapshot.logs.push(message); update();