Skip to content

S21a: Flow 'agent' step - run a createAgent() agent as one flow node - #803

Merged
LinuxDevil merged 2 commits into
mainfrom
fb-s21a-flow-agent-step
Oct 30, 2026
Merged

LinuxDevil merged 2 commits into
mainfrom
fb-s21a-flow-agent-step

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

What changed

FlowExecutor runs a new executable node { type: 'agent', agent, input?, outputVariable? }: it sends the interpolated input (default '{{input}}') to the agent registered under FlowExecutionContext.agents[node.agent], and stores the reply text (a string, so durable checkpoints stay cloneable) in outputVariable.

  • src/types/flow.ts: new AgentStepNode in RuntimeStep; StepNode JSDoc now points at agent steps.
  • src/flows/FlowExecutor.ts: new exported FlowStepAgent (a createAgent() result fits as is), new FlowExecutionContext.agents map, agent handler + executeAgentStep, and the 'step' hint now reads ('step' is an editor shape: use { type: 'agent', agent, input } with FlowExecutionContext.agents).
  • The step reuses llm-call/llm-response events carrying data.agent (the map's model/usage fields are now optional; existing data.model readers are unaffected). The agent's invoke_agent span nests under the node's flow.node agent span via parentSpanId.
  • Unknown agent name → LOUSHO_FLOW_INVALID naming the registered keys; finishReason: 'awaiting-approval' → LOUSHO_FLOW_EXECUTION_FAILED (agent steps cannot pause a flow).
  • Docs: docs/flows.md "Running an agent in a flow" shows the agent step first (tool-wrapping recipe kept as the alternative); agent added to the node table. llms-full.txt and api/* reports regenerated.
  • Both new exports come through the existing export * barrels in src/flows/index.ts; no barrel edit needed.

How tested

  • npx tsc --noEmit — clean
  • npm run typecheck:tests — clean
  • npm run test:types — 103 type tests pass
  • npm run lint — clean
  • npx vitest run src/flows — 297 tests, all pass (8 new in flowAgentStep.test.ts)
  • npm run docs:verify-snippets -- --source-only — 341 snippets type-check
  • npm run test:coverage — 6726 tests, all pass; first run failed 5 create-lousho-agent tests only because that workspace's dist/ was unbuilt locally (CI builds it first); they pass after npm run build --workspace=packages/create-lousho-agent
  • npm run api:check, npm run docs:llms:check — clean
  • npm run fallow — clean (0 dead exports, 0 above complexity)

Acceptance criteria

  • sequence[agent(writer, '{{topic}}', 'draft'), return('$draft')] with agents: { writer: createAgent(...) } completes with 'A draft.'
  • The writer's invoke_agent span's parentId is the flow.node agent span's id
  • Unknown agent name → LOUSHO_FLOW_INVALID naming the available keys
  • An agent whose tool needs approval (no approver) fails with LOUSHO_FLOW_EXECUTION_FAILED
  • retry: { maxAttempts: 2 } retries a send that throws once
  • A durable run resumed after the agent step does not call the agent again
  • { type: 'step' } still fails with LOUSHO_FLOW_INVALID and the new hint

Generated with Devin

LinuxDevil and others added 2 commits October 30, 2026 02:36
Add an executable 'agent' flow node ({ type: 'agent', agent, input?,
outputVariable? }) that sends the interpolated input to a createAgent()
agent registered in FlowExecutionContext.agents, stores its reply text and
nests the agent's invoke_agent span under the node span. An agent that
pauses for approval fails the step; the editor-only 'step' hint now points
at 'agent' steps. llm-call/llm-response events carry data.agent.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
JSDoc on FlowStepAgent.send and its result fields, AgentStepNode.type/id
and the 'agent' field of the llm-call/llm-response event data, so the
typedoc undocumented count drops below the baseline (ratchet 1756 < 1758;
baseline locked in typedoc-baseline.json).

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@LinuxDevil
LinuxDevil merged commit 874f4a6 into main Oct 30, 2026
2 checks 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.

1 participant