Repository navigation
S21a: Flow 'agent' step - run a createAgent() agent as one flow node - #803
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
FlowExecutorruns a new executable node{ type: 'agent', agent, input?, outputVariable? }: it sends the interpolatedinput(default'{{input}}') to the agent registered underFlowExecutionContext.agents[node.agent], and stores the reply text (a string, so durable checkpoints stay cloneable) inoutputVariable.src/types/flow.ts: newAgentStepNodeinRuntimeStep;StepNodeJSDoc now points atagentsteps.src/flows/FlowExecutor.ts: new exportedFlowStepAgent(acreateAgent()result fits as is), newFlowExecutionContext.agentsmap,agenthandler +executeAgentStep, and the'step'hint now reads('step' is an editor shape: use { type: 'agent', agent, input } with FlowExecutionContext.agents).llm-call/llm-responseevents carryingdata.agent(the map'smodel/usagefields are now optional; existingdata.modelreaders are unaffected). The agent'sinvoke_agentspan nests under the node'sflow.node agentspan viaparentSpanId.LOUSHO_FLOW_INVALIDnaming the registered keys;finishReason: 'awaiting-approval'→LOUSHO_FLOW_EXECUTION_FAILED(agent steps cannot pause a flow).docs/flows.md"Running an agent in a flow" shows theagentstep first (tool-wrapping recipe kept as the alternative);agentadded to the node table.llms-full.txtandapi/*reports regenerated.export *barrels insrc/flows/index.ts; no barrel edit needed.How tested
npx tsc --noEmit— cleannpm run typecheck:tests— cleannpm run test:types— 103 type tests passnpm run lint— cleannpx vitest run src/flows— 297 tests, all pass (8 new inflowAgentStep.test.ts)npm run docs:verify-snippets -- --source-only— 341 snippets type-checknpm run test:coverage— 6726 tests, all pass; first run failed 5 create-lousho-agent tests only because that workspace'sdist/was unbuilt locally (CI builds it first); they pass afternpm run build --workspace=packages/create-lousho-agentnpm run api:check,npm run docs:llms:check— cleannpm run fallow— clean (0 dead exports, 0 above complexity)Acceptance criteria
sequence[agent(writer, '{{topic}}', 'draft'), return('$draft')]withagents: { writer: createAgent(...) }completes with'A draft.'invoke_agentspan'sparentIdis theflow.node agentspan's idLOUSHO_FLOW_INVALIDnaming the available keysLOUSHO_FLOW_EXECUTION_FAILEDretry: { maxAttempts: 2 }retries asendthat throws once{ type: 'step' }still fails withLOUSHO_FLOW_INVALIDand the new hintGenerated with Devin