AgentForceWorkflow
AgentForceWorkflow
Section titled “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.
WorkflowConfig
Section titled “WorkflowConfig”The constructor accepts a WorkflowConfig
object with the following properties:
name
(string): Required name identifier for the workflowlogger?
(AgentForceLogger): Optional custom logger instance
Configuration Methods
Section titled “Configuration Methods”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
Execution Control Methods
Section titled “Execution Control Methods”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
Error Handling Methods
Section titled “Error Handling Methods”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
Execution Methods
Section titled “Execution Methods”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
Utility Methods
Section titled “Utility Methods”Method
Type
Required
Description
.debug()
Chainable
Optional
Enable debug logging for workflow configuration and execution
Method Types
Section titled “Method Types”- 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
Quick Start Example
Section titled “Quick Start Example”import { AgentForceAgent, AgentForceWorkflow } from '@agentforce/adk';
// Create agentsconst 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 workflowconst 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));