Skip to content

fix: forward modelRegistry and model to workflow subagents - #15

Merged
Michaelliv merged 1 commit into
Michaelliv:mainfrom
Paul-Yuchao-Dong:fix/forward-modelregistry-to-subagents
May 31, 2026
Merged

fix: forward modelRegistry and model to workflow subagents#15
Michaelliv merged 1 commit into
Michaelliv:mainfrom
Paul-Yuchao-Dong:fix/forward-modelregistry-to-subagents

Conversation

@Paul-Yuchao-Dong

Copy link
Copy Markdown
Contributor

Problem

Subagents spawned by the workflow tool fail silently -- they return null or empty strings even for trivial tasks like echo "test". The workflow tool reports "N agent(s) completed" but produces no usable output.

Root Cause

The WorkflowAgent creates subagent sessions via createAgentSession() with SettingsManager.inMemory() but never passes modelRegistry or model. Without modelRegistry, the subagent session cannot authenticate to the LLM provider -- session.prompt() either fails silently or returns empty responses.

By contrast, the Agent tool from @tintinweb/pi-subagents works correctly because it explicitly passes:

modelRegistry: ctx.modelRegistry,
model: ctx.model,

Fix

In src/workflow-tool.ts, pass modelRegistry and model from the tool execution context into the runWorkflow options as a session property. This flows through:

workflow-tool.ts execute(ctx) -> runWorkflow(session) -> WorkflowAgent(session) -> createAgentSession({...session})

Verification

Tested with a minimal workflow (echo test with structured output schema) -- subagents now produce correct JSON output instead of returning null. A 5-agent inspection workflow on a real project also completed successfully with all agents returning structured results.

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.
@Michaelliv
Michaelliv force-pushed the fix/forward-modelregistry-to-subagents branch from 3fda335 to 33f7285 Compare May 31, 2026 06:12
@Michaelliv
Michaelliv merged commit 4189d2b into Michaelliv:main May 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants