Skip to content

[Agent] Add AgentWorkflow#1707

Open
Guikingone wants to merge 1 commit into
symfony:mainfrom
Guikingone:agent/workflow
Open

[Agent] Add AgentWorkflow#1707
Guikingone wants to merge 1 commit into
symfony:mainfrom
Guikingone:agent/workflow

Conversation

@Guikingone

@Guikingone Guikingone commented Feb 28, 2026

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
Docs? yes
Issues Inspired by #155 - Part of #1301
License MIT

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/)

OrchestrationAgentWorkflow implements AgentWorkflowInterface with two entry points: run() (execution
from an initial state) and resume() (resumption from a persisted state). At each workflow place, an
ExecutorInterface is executed, then a TransitionResolverInterface determines the next transition (or
terminates 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 Fiber

StateWorkflowState is a mutable bag carrying data, current place, completed places, and an optional
_next_transition hint. WorkflowStateStoreInterface handles persistence with 4 implementations: InMemory,
Cache (psr/cache), Filesystem, Redis.

Guards & Transition resolverGuardInterface enables pre-execution checks per place.
StateBasedTransitionResolver reads _next_transition from the state or automatically selects the single
available 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.

ProfilerTraceableAgentWorkflow and TraceableWorkflowStateStore trace run/resume/save/load/etc. calls.
The DataCollector and DebugCompilerPass integrate this data into the Symfony debug toolbar.

Documentation & examples

  • RST documentation in docs/bundles/ai-bundle.rst (configuration, executors, stores, guards, profiler)
  • RST documentation in docs/components/agent.rst (standalone usage)
  • 4 examples: linear, linear-with-cache, conditional-branching, process-executor

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.

@Guikingone Guikingone changed the title feat(agent): add Workflow [Agent] Add Workflow Feb 28, 2026
@Guikingone Guikingone force-pushed the agent/workflow branch 5 times, most recently from ca0ef4c to 28d6ba3 Compare March 1, 2026 08:19

@94noni 94noni left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👍🏻

Comment thread src/agent/src/Workflow/WorkflowStatus.php Outdated
Comment thread src/agent/src/Workflow/WorkflowStoreInterface.php Outdated
Comment thread src/agent/src/Workflow/WorkflowStateInterface.php
Comment thread src/agent/src/Workflow/Action/ActionRunner.php Outdated
Comment thread src/agent/src/Workflow/EventListener/GuardListener.php Outdated
Comment thread src/agent/src/Workflow/MarkingStore/StateMarkingStore.php Outdated
Comment thread src/agent/src/Workflow/Event/WorkflowCompletedEvent.php Outdated
@Guikingone Guikingone force-pushed the agent/workflow branch 5 times, most recently from 5fab9fd to e24a663 Compare March 9, 2026 09:08
@Guikingone Guikingone marked this pull request as ready for review March 9, 2026 09:12
@carsonbot carsonbot added Agent Issues & PRs about the AI Agent component Feature New feature Status: Needs Review labels Mar 9, 2026
@Guikingone

Copy link
Copy Markdown
Contributor Author

@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 🙂

@Guikingone Guikingone changed the title [Agent] Add Workflow [Agent] Add AgentWorkflow Mar 9, 2026
@chr-hertel chr-hertel mentioned this pull request Mar 14, 2026
40 tasks
@chr-hertel

Copy link
Copy Markdown
Member

Hi! Version 0.7 has been released. This PR has changelog/upgrade entries under the 0.7 heading, which is now a released version.

Please update the following files to place your entries under the next version 0.8:

  • src/agent/CHANGELOG.md
  • src/ai-bundle/CHANGELOG.md

For CHANGELOG.md files: change the version heading from 0.7 to 0.8
For UPGRADE.md: place entries under UPGRADE FROM 0.7 to 0.8

Thank you!


🤖 This comment was generated automatically by an agent.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Agent Issues & PRs about the AI Agent component Feature New feature Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants