Skip to content

Commit 10ba7f5

Browse files
committed
improv: Better default, preserve tool msgs
1 parent 9842d72 commit 10ba7f5

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

docs/components/agent.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,12 @@ If you need to react more granularly to the lifecycle of individual tool calls,
405405
// Let the client know, that the tool $event->toolCall->name failed with the exception: $event->exception
406406
});
407407

408-
Keeping Tool Messages
409-
~~~~~~~~~~~~~~~~~~~~~
408+
Hiding Tool Messages
409+
~~~~~~~~~~~~~~~~~~~~
410410

411-
Sometimes you might wish to keep the tool messages (:class:`Symfony\\AI\\Platform\\Message\\AssistantMessage` containing the ``toolCalls`` and :class:`Symfony\\AI\\Platform\\Message\\ToolCallMessage`
412-
containing the result) in the context. Enable the ``keepToolMessages`` flag of the toolbox' :class:`Symfony\\AI\\Agent\\Toolbox\\AgentProcessor`
413-
to ensure those messages will be added to your :class:`Symfony\\AI\\Platform\\Message\\MessageBag`::
411+
Sometimes you might wish to hide the tool messages (:class:`Symfony\\AI\\Platform\\Message\\AssistantMessage` containing the ``toolCalls`` and :class:`Symfony\\AI\\Platform\\Message\\ToolCallMessage`
412+
containing the result) in the context. Disable the ``keepToolMessages`` flag of the toolbox' :class:`Symfony\\AI\\Agent\\Toolbox\\AgentProcessor`
413+
to ensure those messages will be removed from your :class:`Symfony\\AI\\Platform\\Message\\MessageBag`::
414414

415415
use Symfony\AI\Agent\Toolbox\AgentProcessor;
416416
use Symfony\AI\Agent\Toolbox\Toolbox;
@@ -428,11 +428,11 @@ to ensure those messages will be added to your :class:`Symfony\\AI\\Platform\\Me
428428
$tool = new MyTool();
429429

430430
$toolbox = new Toolbox([$tool]);
431-
$toolProcessor = new AgentProcessor($toolbox, keepToolMessages: true);
431+
$toolProcessor = new AgentProcessor($toolbox, keepToolMessages: false);
432432

433433
$agent = new Agent($platform, $model, inputProcessor: [$toolProcessor], outputProcessor: [$toolProcessor]);
434434
$result = $agent->call($messages);
435-
// $messages will now include the tool messages
435+
// $messages will now exclude the tool messages
436436

437437
Code Examples (with built-in tools)
438438
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/agent/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* [BC BREAK] Rename `Symfony\AI\Agent\Toolbox\Tool\Agent` to `Symfony\AI\Agent\Toolbox\Tool\Subagent`
8+
* [BC Break] Agent Processor has `keepToolMessages` set to `true` now by default since its helps llms understand what was tried.
89

910
0.3
1011
---

src/agent/src/Toolbox/AgentProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(
5050
private readonly ToolboxInterface $toolbox,
5151
private readonly ToolResultConverter $resultConverter = new ToolResultConverter(),
5252
private readonly ?EventDispatcherInterface $eventDispatcher = null,
53-
private readonly bool $keepToolMessages = false,
53+
private readonly bool $keepToolMessages = true,
5454
private readonly bool $includeSources = false,
5555
private readonly ?int $maxToolCalls = null,
5656
) {

0 commit comments

Comments
 (0)