Workflow Gate won the Core Team Selection at the Symfony AI & MCP Hackathon. Fabien Potencier picked it.
In the announcement he said he was looking for something useful for many Symfony developers, not something super fancy. Three or four projects had the same idea: let the Symfony Workflow component decide what an agent is allowed to do. He picked this one because it is well done and works today, because the evaluation was honest, and because of the upstream contributions.
This post explains what it does, what I measured, and where it stops.
The rule lives in a sentence
An order that is not paid cannot be shipped. Most AI agents learn that from a sentence in the system prompt. The agent has a ship_order tool all the time, and the prompt asks it not to use it too early.
That works most of the time. But the rule now exists twice: in the workflow of the order, and in the prompt. And the copy in the prompt is only as strong as its wording and the model that reads it.
The workflow you already have
In Workflow Gate the agent has no ship_order tool until the order is paid. When the payment arrives, the tool appears.
You mark the transitions an agent may use in the workflow configuration. The value is the tool description:
# config/packages/workflow.yaml
framework:
workflows:
order:
type: state_machine
supports: [App\Order\Order]
transitions:
pay:
from: draft
to: paid
# No agent_tool: a payment comes from the payment provider, never from an agent.
ship:
from: paid
to: shipped
metadata:
agent_tool: Hands the open order to the carrier. Only possible once it is paid.
There is no tool class to write. The enabled transitions of the order are the agent's tools. An order in draft has only cancel_order. A paid order has ship_order and refund_order.
Guards become agent policy
A workflow guard is ordinary Symfony code. In the demo, agents may refund at most 500 EUR:
#[AsEventListener('workflow.order.guard.refund')]
public function guardRefund(GuardEvent $event): void
{
$order = $event->getSubject();
if ($order->total > self::REFUND_LIMIT) {
$event->addTransitionBlocker(new TransitionBlocker(
sprintf('Refunds above %d EUR need a human.', self::REFUND_LIMIT),
'refund_limit',
));
}
}
The same guard applies to people and to agents. When it blocks, its message is what the agent hears.
The tool list is only the visible part. Every call goes through the workflow again. A client that still holds an old tool list gets a refusal, and the order stays as it is.
Live, in a running MCP session
The same gate serves two places.
In a Symfony AI agent, WorkflowToolbox is a ToolboxInterface made of the enabled transitions. A small platform decorator sends the current tools with every model call, so a tool that appears while the agent works can be used in the same run.
For MCP, RegistrySynchronizer keeps the tools of the server equal to the enabled transitions. The PHP MCP SDK accepts registerTool() and unregisterTool() at runtime and announces the change. With the cache subscription bus of the MCP bundle, another PHP process can announce it too.
So you can open order 1001 in Claude Code, ask it to ship, and get "not possible". Then run php bin/console app:pay 1001 in a second terminal. The session receives notifications/tools/list_changed, reads the tools again and now has ship_order. Nothing restarts.
What I measured
I did not want to assume that hiding tools helps, so the project has a command for it: php bin/console app:measure. It asks the agent for three things the workflow forbids, in three setups:
- gated: Workflow Gate, the tools are the enabled transitions.
- all-tools: every tool in every state, the workflow refuses on call.
- prompt-rules: every tool in every state, the tools change the order directly, and the rules are only in the prompt.
One model (claude-haiku-4-5), five tries per scenario. The results:
- The prompt-only agent did well. With my final prompt it kept the rules in every try, and in 20 more tries of the refund scenario.
- It was not always so. With an earlier, shorter version of the same prompt, it refunded a 900 EUR order against its rule in 1 of 5 tries. Two more sentences fixed that.
- Hiding the tool saves the attempt. The all-tools agent called a forbidden tool in 10 of 15 tries and was refused every time. The gated agent had nothing to call.
- With the workflow in charge, the order never ended in a forbidden state, with either prompt.
So a good prompt gets you far. The difference is that with the workflow, safety does not depend on wording or on the model. Five tries and one model are a small sample, and the numbers moved between runs. Run the command yourself.
What I reported upstream
Two things did not work the way I needed, so I wrote them up:
- symfony/ai#2995: an agent reads its tools once per run, so a tool that appears during the run is not offered to the model. Workflow Gate works around it with the platform decorator.
- modelcontextprotocol/php-sdk#751: replacing
cancel_orderbyship_orderandrefund_ordersends threelist_changednotifications instead of one.
Where it stops
- The demo serves MCP over STDIO. Under PHP-FPM every HTTP request is a new process, so the server cannot push a tool list. The list is still right on every request.
- One open order per MCP session. A tool list belongs to a session, not to an object.
- There is no user in a STDIO session, so guards that depend on the logged-in user are not shown.
Try it
The code is on GitHub: RunIO-dev/workflow-gate. You need PHP 8.3, Composer and an Anthropic API key for the web demo. The MCP part needs no key.
The project page is on symfony.com, with a 90-second video.
Thanks to Fabien and the Symfony AI team for running the hackathon, and for the β¬1,000 Upsun credit.
Author Amer Malik Mohammed
Full-Stack Developer with 2+ years of experience in object-oriented PHP development (Symfony), JavaScript and MySQL. Specialized in e-commerce solutions (Shopware 5/6), REST API development and process automation in agile teams.
Contact author