Skip to content

Commit d3b244f

Browse files
committed
bug #762 [Agent] Fix tool result conversion hand over (chr-hertel)
This PR was merged into the main branch. Discussion ---------- [Agent] Fix tool result conversion hand over | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | Issues | | License | MIT Another example why `mixed` is dangerous - phpstan, phpunit, and runtime didn't complain ... yay 😑 Commits ------- cfa5a79 Fix tool result conversion hand over
2 parents 14b2110 + cfa5a79 commit d3b244f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/agent/src/Toolbox/ToolResultConverter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ public function __construct(
2828
) {
2929
}
3030

31-
public function convert(mixed $result): ?string
31+
public function convert(ToolResult $toolResult): ?string
3232
{
33+
$result = $toolResult->getResult();
34+
3335
if (null === $result || \is_string($result)) {
3436
return $result;
3537
}

src/agent/tests/Toolbox/ToolResultConverterTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@
1313

1414
use PHPUnit\Framework\Attributes\DataProvider;
1515
use PHPUnit\Framework\TestCase;
16+
use Symfony\AI\Agent\Toolbox\ToolResult;
1617
use Symfony\AI\Agent\Toolbox\ToolResultConverter;
1718
use Symfony\AI\Fixtures\StructuredOutput\UserWithConstructor;
19+
use Symfony\AI\Platform\Result\ToolCall;
1820

1921
final class ToolResultConverterTest extends TestCase
2022
{
2123
#[DataProvider('provideResults')]
2224
public function testConvert(mixed $result, ?string $expected)
2325
{
26+
$toolResult = new ToolResult(new ToolCall('123456789', 'tool_name'), $result);
2427
$converter = new ToolResultConverter();
2528

26-
$this->assertSame($expected, $converter->convert($result));
29+
$this->assertSame($expected, $converter->convert($toolResult));
2730
}
2831

2932
public static function provideResults(): \Generator

0 commit comments

Comments
 (0)