In previous articles, we built an e-commerce assistant using Symfony AI: first with a single tool, then with conversation history and multiple tools, followed by SSE streaming, and finally a migration to v0.12 with granular exception handling.
Since then, the component has continued to evolve rapidly. Between v0.12 and v0.14.1, key pieces changed: the return value of call(), the way tools are executed, and exceptions related to provider limits. In this article, I document that migration, the code changes required, and what we validated in production.
1. What Changed Between v0.12 and v0.14.1
A. The Execution Object (v0.13)
Until now, $agent->call(...) returned a ResultInterface. Starting with v0.13, it returns a Symfony\AI\Agent\Execution\Execution, which is both a ResultInterface and a lazy iterable (\IteratorAggregate). It brings three methods of interest:
asTextStream(): a typed generator that emits onlyTextDeltainstances. No moreinstanceof TextDeltachecks inside each streaming loop.cancel(): cancels the call and closes the underlying HTTP connection.isStreamed(): indicates whether the execution was configured for streaming.
B. Goodbye to AgentProcessor (v0.13)
In the first article, we mentioned AgentProcessor as the component responsible for executing tools. Since v0.13, it no longer exists: the Agent class orchestrates the tool call lifecycle itself, relying on ToolExecutorInterface implementations. By default, SequentialToolExecutor is used.
C. Concurrent Execution with Fibers (v0.14)
When the model requests multiple tools at once, we can now execute them concurrently using FiberToolExecutor. It is enabled in configuration:
# config/packages/ai.yaml
ai:
agent:
default:
platform: 'ai.platform.generic.groq'
model: 'openai/gpt-oss-120b'
tools:
execution_strategy: fiber # o sequential (por defecto)
services:
- { service: 'App\AI\Tool\ProductSearchTool' }
- { service: 'App\AI\Tool\ProductPriceTool' }
- { service: 'App\AI\Tool\ProductCategoryTool' }
In our store, the performance gain will be noticeable when a user asks something like “compare the prices of these two laptops”, because the model can request two price lookups in the same turn.
D. Resilience Exceptions (v0.14)
The Symfony\AI\Platform\Exception hierarchy was expanded with two exceptions that handle scenarios that previously fell back to a generic catch (\Throwable):
RateLimitExceededException: thrown on HTTP 429 responses from providers like Groq or OpenAI. It includesgetRetryAfter(), which provides the suggested wait time in seconds.MaxOutputTokensException: thrown when the model truncates the response because it exceeded the output token limit.
2. Composer Version Resolution
The Symfony AI monorepo does not version all its components at the same pace. In our case, ai-bundle, ai-agent, and ai-platform are at v0.14.1, while the OpenAI and OpenRouter bridges remain at v0.14.0. To avoid dependency conflicts, we use the minor compatibility prefix:
"require": {
"symfony/ai-agent": "^0.14",
"symfony/ai-bundle": "^0.14",
"symfony/ai-open-ai-platform": "^0.14",
"symfony/ai-open-router-platform": "^0.14"
}
Remember that the component is still experimental. Before upgrading, it is wise to review the release notes for each version.
3. Migrated Code
3.1. The Service: Lazy Execution and asTextStream()
The most visible change is in ProductChatService. We no longer iterate through the stream checking for TextDelta; instead, we use the typed generator:
// src/AI/ProductChatService.php
public function streamAsk(string $userQuestion, \Closure $onChunk): void
{
$session = $this->requestStack->getSession();
$history = $session->get('chat_history', []);
$history[] = ['role' => 'user', 'content' => $userQuestion];
$messages = $this->buildMessageBag($history);
// Clonamos el MessageBag: el agente lo muta in-place durante las tool calls
$execution = $this->defaultAgent->call(clone $messages, ['stream' => true]);
$fullAnswer = '';
foreach ($execution->asTextStream() as $delta) {
$content = $delta->getText();
if ($content !== '') {
$fullAnswer .= $content;
$onChunk($content);
}
}
if (trim($fullAnswer) === '') {
$fullAnswer = 'Lo siento, hubo un problema procesando tu solicitud.';
$onChunk($fullAnswer);
}
$history[] = ['role' => 'assistant', 'content' => $fullAnswer];
$session->set('chat_history', array_slice($history, -10));
}
The code is shorter and much more readable, but the underlying logic remains unchanged: the conversation history is still a sliding window of 10 session messages, and we only persist the assistant’s final text.
3.2. The Controller: Resilience Against Rate Limits
With RateLimitExceededException, we can tell users exactly how long they need to wait, instead of showing a generic error message:
// src/Controller/ProductChatController.php (fragmento)
} catch (RateLimitExceededException $e) {
$retry = $e->getRetryAfter();
$msg = $retry
? sprintf('Límite de peticiones alcanzado. Por favor, reintenta en %d segundos.', $retry)
: 'Límite de peticiones alcanzado temporalmente. Espera unos instantes.';
error_log('AI RATE LIMIT: ' . $e->getMessage());
echo 'data: ' . json_encode(['error' => $msg]) . "\n\n";
ob_flush();
flush();
} catch (MaxOutputTokensException $e) {
error_log('AI MAX TOKENS: ' . $e->getMessage());
echo 'data: ' . json_encode([
'error' => 'La respuesta del modelo excedió el límite de salida y se cortó.'
]) . "\n\n";
ob_flush();
flush();
}
These blocks go inside the same try block of the StreamedResponse we covered in part three, alongside the catch blocks for ExceedContextSizeException, ModelNotFoundException, and ServerException. Order matters: specific exceptions must be caught before the final \Throwable.
4. Validation
We tested the migration end-to-end and verified:
- Category lookups using
ProductCategoryTool, with real-time streaming. - Search and pagination using
ProductSearchTool. - Unit price queries using
ProductPriceTool. - Rate limit handling with
RateLimitExceededException, displaying the wait time. - Polite redirection when handling off-topic queries.
5. Gotchas That Cost Us Time
- Migrate the API, not just the version. Moving from
instanceof TextDeltatoasTextStream()might seem cosmetic, but it eliminates a class of silent bugs: if the generator’s structure changes, the old code stops emitting text without throwing any errors. - A 429 is not a code error. Treating it as a generic failure frustrates users. With
getRetryAfter(), the UI can inform them when to retry. - Clone the
MessageBag, always. Since v0.10, the agent mutates the bag during tool calls. Without cloning, the history saved in the session might contain internal tool execution messages. - Only enable Fibers if your tools are independent. Concurrent execution helps when calls do not depend on one another. If one tool depends on the result of another, the sequential executor is still the right choice.
What We Learned from the Upgrade
Migrating from v0.12 to v0.14.1 results in cleaner code: streaming is handled with a single foreach, tools are orchestrated directly within the agent, and provider limits are treated as what they are: expected errors with a straightforward recovery path.
In the next article, we will continue the series with Structured Output using typed DTOs and the Symfony AI Profiler, as well as exploring multi-provider failover strategies.
Keep on coding.