Skip to content

Workflow Support #2

Description

@omeraplak

1. Overview:*

Enable users to define, execute, and monitor complex, multi-step processes involving multiple agents. Workflows allow orchestrating agents where the output of one agent step can serve as the input for subsequent steps, potentially involving conditional logic, branching, and parallel execution. This feature will significantly enhance the capability of voltagent to handle sophisticated tasks requiring agent collaboration.

2. Goals:

  • Provide a clear and flexible mechanism for defining workflows (e.g., using a declarative format like YAML/JSON or a programmatic API).
  • Implement a robust Workflow Engine capable of parsing definitions and managing the execution lifecycle of workflow instances.
  • Enable seamless data passing between different agent steps within a workflow.
  • Offer comprehensive monitoring and logging for workflow execution, status, and potential errors.
  • Integrate workflow management into the existing voltagent ecosystem (e.g., VoltAgent, AgentRegistry, AgentEventEmitter).
  • Ensure fault tolerance and provide basic error handling strategies (e.g., retry, failure notification).

3. Proposed Architecture & Components:

  • WorkflowDefinition: A data structure (or class) representing the static definition of a workflow. This will include:
    • Workflow ID and metadata.
    • A graph or sequence of WorkflowStep nodes.
    • Definitions for data flow between steps (input/output mapping).
    • Conditional logic definitions (if applicable).
  • WorkflowStep: Represents a single unit of work within a workflow, typically involving a call to a specific Agent. Contains:
    • Step ID.
    • Target Agent ID (to be resolved via AgentRegistry).
    • Input mapping configuration (how to construct the agent's input from workflow state or previous step outputs).
    • Output mapping configuration (how to store the agent's output in the workflow state).
    • Error handling configuration (e.g., retry count, fallback step).
  • WorkflowManager: A central service (potentially integrated with VoltAgent or running independently) responsible for:
    • Loading and validating WorkflowDefinitions.
    • Instantiating and executing workflows (WorkflowInstance).
    • Managing the lifecycle and state of active WorkflowInstances.
    • Interacting with AgentRegistry to locate and invoke agents.
    • Persisting workflow state (potentially leveraging or extending MemoryManager or using a dedicated store).
  • WorkflowInstance: Represents a single, running execution of a WorkflowDefinition. Contains:
    • Instance ID.
    • Reference to the WorkflowDefinition.
    • Current execution state (e.g., current step, status - running, completed, failed).
    • Intermediate data and outputs from completed steps.
    • Execution history/log.
  • Workflow Events: Extend AgentEventEmitter or create a dedicated event stream for workflow-specific events (e.g., workflow_started, step_started, step_completed, step_failed, workflow_completed, workflow_failed). This integrates with the existing monitoring infrastructure.

4. Affected Core Modules:

  • AgentRegistry: Will be used by WorkflowManager to look up agents.
  • Agent: Agent methods will be invoked by the workflow engine. Input/output consistency is crucial.
  • AgentEventEmitter: Needs to be extended or used to emit workflow-level events for monitoring.
  • MemoryManager: Might be leveraged for storing intermediate workflow data or state.
  • server: API endpoints for workflow management will be added.

5. Acceptance Criteria (Initial MVP):

  • Users can define a simple sequential workflow involving two agents using a YAML or JSON format.
  • The WorkflowManager can parse the definition and execute the workflow.
  • Data output from the first agent step is correctly passed as input to the second agent step.
  • Workflow start, step completion, and workflow completion/failure events are emitted via AgentEventEmitter.
  • The final status (completed/failed) of the workflow instance can be retrieved.
  • Basic documentation outlines how to create and run a two-step workflow.

6. Potential Challenges & Considerations:

  • Designing a schema that is both powerful (supporting branching, parallelism) and easy to use.
  • Efficiently managing state for potentially long-running or numerous concurrent workflows.
  • Robust error handling, retry mechanisms, and compensation logic.
  • Providing effective debugging and monitoring tools for complex workflows.
  • Ensuring security when workflows involve agents with different permissions or access to tools.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions