[Agent] Add AgentWorkflow#1707
Conversation
ca0ef4c to
28d6ba3
Compare
94noni
left a comment
There was a problem hiding this comment.
small comment passing by :)
workflow component is very powerful so this on top I think could be a valuable addition in the tooling chain of ai/agent 👍🏻
5fab9fd to
e24a663
Compare
|
@94noni If you have time, I pushed a rework of the PR, I resolved your previous comments as most of them were obsolete due to recent changes, I let you review it when you have time 🙂 |
|
Hi! Version 0.7 has been released. This PR has changelog/upgrade entries under the Please update the following files to place your entries under the next version 0.8:
For Thank you! 🤖 This comment was generated automatically by an agent. |
e24a663 to
504d2bb
Compare
Add a Workflow engine for orchestrating multi-step agent pipelines on top of the Symfony Workflow component. Agent component: * `AgentWorkflow` runs an executor at each workflow place and delegates transition logic to the Symfony Workflow component * `WorkflowState` is an immutable bag carrying data, progress and the next-transition hint; it is persisted after each place so an interrupted run can be resumed from where it stopped * Executors: `AgentExecutor` (delegates to an agent, with optional per-call options and a shared conversation history), `ProcessExecutor`, `CallableExecutor`, and the `RetryExecutor` and `TimeoutExecutor` decorators * Per-place `GuardInterface` checks (`AbstractGuard`, `ExpressionGuard`) and pluggable transition routing — state-based, expression-based or custom * Parallel execution of AND-split branches through `ParallelExecutionStrategyInterface`, with concurrent agent calls and configurable `MergePolicy` branch merging; an interrupted fork resumes only the branches that had not completed * Optional concurrency-safe locking of `run()` and `resume()` through a `symfony/lock` factory * State stores: in-memory plus PSR-6 cache, filesystem and Redis bridges; `ManagedWorkflowStateStoreInterface` provisions the backend and `ListableWorkflowStateStoreInterface` enumerates persisted states * `ai:workflow:setup`, `ai:workflow:drop`, `ai:workflow:list`, `ai:workflow:delete` and `ai:workflow:prune` console commands * Optional PSR-14 lifecycle events and PSR-3 logging; a `maxSteps` cap guards against cyclic definitions AI Bundle: * `workflow` configuration mapping executors, guards, state store, transition routing, locking, retry, timeout and parallel execution onto a registered Symfony Workflow * Guards can also be attached to a workflow with the `#[AsWorkflowGuard]` attribute instead of the `guards` configuration list * Profiler integration through `TraceableAgentWorkflow` and `TraceableWorkflowStateStore`, with a dedicated Workflow panel and a per-place execution timeline
504d2bb to
88e7265
Compare
This PR introduces a workflow system for orchestrating multi-step agent pipelines, built on top of the
Symfony Workflow component for place/transition logic.
Agent component (src/agent/)
Orchestration —
AgentWorkflowimplementsAgentWorkflowInterfacewith two entry points:run()(executionfrom an initial state) and
resume()(resumption from a persisted state). At each workflow place, anExecutorInterfaceis executed, then aTransitionResolverInterfacedetermines the next transition (orterminates the workflow).
Executors — Three implementations provided:
AgentExecutor: delegates execution to an existing AgentInterface (configurable prompt per place,read/write keys from/to state)
ProcessExecutor: runs a symfony/process (static command or closure)FiberExecutor: executes a closure inside a FiberState —
WorkflowStateis a mutable bag carrying data, current place, completed places, and an optional_next_transitionhint.WorkflowStateStoreInterfacehandles persistence with 4 implementations: InMemory,Cache (psr/cache), Filesystem, Redis.
Guards & Transition resolver —
GuardInterfaceenables pre-execution checks per place.StateBasedTransitionResolverreads_next_transitionfrom the state or automatically selects the singleavailable transition.
Dedicated exceptions:
WorkflowExecutorException,WorkflowGuardException,TransitionResolutionException,WorkflowStateNotFoundException.AI Bundle (src/ai-bundle/)
Configuration — New workflow section in the bundle config. Each workflow references an existing Symfony
Workflow (defined in config/packages/workflow.yaml) and maps executors to places. Supports stores
(memory/cache/filesystem/redis/service), guards per place, and a custom transition resolver.
Profiler —
TraceableAgentWorkflowandTraceableWorkflowStateStoretrace run/resume/save/load/etc. calls.The DataCollector and DebugCompilerPass integrate this data into the Symfony debug toolbar.
Documentation & examples
Tests
64 tests for the Agent component (workflow), covering AgentWorkflow, all 3 executors, the transition
resolver, state, normalizer, and all 4 stores. On the bundle side: configuration tests, compiler pass,
profiler/data collector.