An AI agent that calls your code
A support bot that answers with live data from your app, in three small files. First, the config: pick a platform and a model, write the system prompt, list the tools the agent may use. No SDK boilerplate.
A tool is one of your services with an attribute. Its typed parameters become the tool schema automatically: when a customer asks "where is my order 4242", the model calls this method with 4242 and your regular repository does the lookup.
Talking to the agent is a two-line service. Symfony runs the loop for you: model asks for a tool, your PHP runs, the answer goes back, until the reply is grounded in your data. Vector stores for RAG, multiple platforms (OpenAI, Anthropic, Gemini, local models) and a profiler panel are part of the same toolkit.
ai: platform: anthropic: api_key: '%env(ANTHROPIC_API_KEY)%' agent: support: model: 'claude-sonnet-5' prompt: 'You help customers of the Acme online store.' tools: - 'App\Ai\OrderStatusTool'<?phpnamespace App\Ai;use App\Repository\OrderRepository;use Symfony\AI\Agent\Toolbox\Attribute\AsTool;#[AsTool('order_status', 'Finds the current status of an order')]class OrderStatusTool{ public function __construct( private OrderRepository $orders, ) { } public function __invoke(int $orderNumber): string { // plain PHP: the model decides when to call this tool and // extracts the typed arguments from the conversation return $this->orders->find($orderNumber)->getStatus(); }}<?phpnamespace App\Service;use Symfony\AI\Agent\AgentInterface;use Symfony\AI\Platform\Message\Message;use Symfony\AI\Platform\Message\MessageBag;class SupportChat{ public function __construct( private AgentInterface $agent, ) { } public function ask(string $question): string { $messages = new MessageBag(Message::ofUser($question)); return $this->agent->call($messages)->getContent(); }}