Skip to content

AgentForceWorkflow


AgentForceWorkflow Workflow Class Multi-Agent

The AgentForceWorkflow class provides powerful orchestration capabilities for coordinating multiple AI agents, managing shared state, and executing complex multi-step workflows.

The constructor accepts a WorkflowConfig object with the following properties:

  • name (string): Required name identifier for the workflow
  • logger? (AgentForceLogger): Optional custom logger instance
Method
Type
Required
Description
.prompt()
Chainable
Required
Set the main prompt that defines the workflow's objective
.dispatcher()
Chainable
Optional
Set an agent as the workflow coordinator and dispatcher
.registerAgent()
Chainable
Required
Register agents within the workflow for execution steps
.sharedStore()
Chainable
Optional
Store data accessible by all agents in the workflow
Method
Type
Required
Description
.sequence()
Chainable
Optional
Execute agents sequentially, passing output between them
.parallel()
Chainable
Optional
Execute agents simultaneously for faster processing
.iterate()
Chainable
Optional
Iterate over a collection of items with an agent
Method
Type
Required
Description
.onSuccess()
Chainable
Optional
Define an agent to execute when workflow completes successfully
.onFail()
Chainable
Optional
Define an agent to execute when workflow encounters errors
Method
Type
Required
Description
.run()
Execute • Async
Required
Execute the workflow and return the final result
.loop()
Execute
Optional
Run the workflow in a continuous loop with optional delay
Method
Type
Required
Description
.debug()
Chainable
Optional
Enable debug logging for workflow configuration and execution
  • Chainable: Returns the workflow instance for method chaining
  • Terminal: Executes the workflow and returns results (ends the chain)
  • Async: Returns a Promise and must be awaited
import { AgentForceAgent, AgentForceWorkflow } from '@agentforce/adk';
// Create agents
const dispatcher = new AgentForceAgent({ name: "DispatcherAgent" })
.useLLM("ollama", "gemma3:12b")
.systemPrompt("You will manage the workflow and coordinate between different agents.");
const gcpAgent = new AgentForceAgent({
name: "gcpAgent",
skills: ["devops"]
})
.useLLM("ollama", "gemma3:12b")
.systemPrompt("You are a GCP expert. You will run gcloud commands to create resources in GCP.");
const productOwnerAgent = new AgentForceAgent({
name: "productOwnerAgent",
skills: ["productOwner"]
})
.useLLM("ollama", "gemma3:12b")
.systemPrompt("You will create a user story based on the user prompt.");
// Create and execute workflow
const workflowOutput = await new AgentForceWorkflow({ name: "TaskListWorkflow"})
.prompt("I want to create a Cloudbucket in GCP using gcloud cli")
.dispatcher(dispatcher)
.sharedStore("projectId", "my-gcp-project")
.registerAgent(gcpAgent)
.registerAgent(productOwnerAgent)
.run();
console.log(JSON.stringify(workflowOutput, null, 2));