Skip to content

Commit 4b22015

Browse files
committed
minor #763 [Agent] Drop mixed in favor of ToolResult in event (chr-hertel)
This PR was merged into the main branch. Discussion ---------- [Agent] Drop mixed in favor of ToolResult in event | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | | License | MIT Found another `mixed` that is not needed and just dangerous Commits ------- 5da2a28 Drop mixed in favor of ToolResult in event
2 parents d3b244f + 5da2a28 commit 4b22015

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/agent/src/Toolbox/Event/ToolCallSucceeded.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\AI\Agent\Toolbox\Event;
1313

14+
use Symfony\AI\Agent\Toolbox\ToolResult;
1415
use Symfony\AI\Platform\Tool\Tool;
1516

1617
/**
@@ -25,7 +26,7 @@ public function __construct(
2526
private object $tool,
2627
private Tool $metadata,
2728
private array $arguments,
28-
private mixed $result,
29+
private ToolResult $result,
2930
) {
3031
}
3132

@@ -47,7 +48,7 @@ public function getArguments(): array
4748
return $this->arguments;
4849
}
4950

50-
public function getResult(): mixed
51+
public function getResult(): ToolResult
5152
{
5253
return $this->result;
5354
}

src/agent/src/Toolbox/Toolbox.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function execute(ToolCall $toolCall): ToolResult
8282

8383
$arguments = $this->argumentResolver->resolveArguments($metadata, $toolCall);
8484
$this->eventDispatcher?->dispatch(new ToolCallArgumentsResolved($tool, $metadata, $arguments));
85-
$result = $tool->{$metadata->getReference()->getMethod()}(...$arguments);
85+
$result = new ToolResult($toolCall, $tool->{$metadata->getReference()->getMethod()}(...$arguments));
8686
$this->eventDispatcher?->dispatch(new ToolCallSucceeded($tool, $metadata, $arguments, $result));
8787
} catch (ToolExecutionExceptionInterface $e) {
8888
$this->eventDispatcher?->dispatch(new ToolCallFailed($tool, $metadata, $arguments ?? [], $e));
@@ -93,7 +93,7 @@ public function execute(ToolCall $toolCall): ToolResult
9393
throw ToolExecutionException::executionFailed($toolCall, $e);
9494
}
9595

96-
return new ToolResult($toolCall, $result);
96+
return $result;
9797
}
9898

9999
private function getMetadata(ToolCall $toolCall): Tool

0 commit comments

Comments
 (0)