-   Notifications  You must be signed in to change notification settings 
- Fork 8
Open
Labels
enhancementNew feature or requestNew feature or request
Description
For agents whose top-level behavior is a pre-defined graph.
Desired features:
- Max depth / max loop iterations to avoid infinite loops
- Easy forking & joining - join on all tasks in the workflow
- create a semaphore, add tasks, check if all tasks are done
 
- “Pause” for user input
- Read the output of any parent step, by name or by traversing graph
- Allow returning a status (e.g. expected failure) return value, and optionally a mutation handle to call exactly once and args for it (if you want more than the state in the graph journal)
Sample syntax
- In the s.doWhatTheLLMSaid(brain) mutation, it doesaddChildfor all LLM tool calls / other actions, waiting for them to finish before continuing. The whole loop could be run from a brain mutation.
- In the future, we could add inline mutation functions, since .defineis registering a mutation & can get called as the step, with a cursor pointing to the step it should execute & with what context.
import { WorkflowManager, workflowBrain, chain, loop, parallel } from "@convex-dev/workflow"; const workflow = new WorkflowManager(components.workflow, { workpool: components.workpool, // you can share it between agents }); // for conciseness const s = internal.mySteps; export const support = workflow.define({ name: "supportOrchestrator", args: { userId: v.id("users"), initialComplaint: v.string() }, steps: chain() .mutation(s.createThread) // args are typed as workflow initial args .parallel([ chain().action(s.investigateUserHistory), chain().action(s.detectProductOutage) ]) .loop({ maxIterations: 10, steps: chain() .action(s.askLLMWhatToDo) .mutation(s.doWhatTheLLMSaid), // this step dispatches children shouldContinue: s.askLLMToContinue }) .action(s.askLLMForNextStep) .mutation(s.updateStatusAndDispatch) ) });adamk-au
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request