Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/agent/src/Toolbox/Event/ToolCallSucceeded.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\AI\Agent\Toolbox\Event;

use Symfony\AI\Agent\Toolbox\ToolResult;
use Symfony\AI\Platform\Tool\Tool;

/**
Expand All @@ -25,7 +26,7 @@ public function __construct(
private object $tool,
private Tool $metadata,
private array $arguments,
private mixed $result,
private ToolResult $result,
) {
}

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

public function getResult(): mixed
public function getResult(): ToolResult
{
return $this->result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/agent/src/Toolbox/Toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function execute(ToolCall $toolCall): ToolResult

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

return new ToolResult($toolCall, $result);
return $result;
}

private function getMetadata(ToolCall $toolCall): Tool
Expand Down