From bc29b52f119b2e00933c3dd02c91fd774ec554e1 Mon Sep 17 00:00:00 2001 From: Franz Wilding Date: Mon, 29 Sep 2025 11:04:08 +0200 Subject: [PATCH 1/6] Update AgentProcessor.php --- src/agent/src/Toolbox/AgentProcessor.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/agent/src/Toolbox/AgentProcessor.php b/src/agent/src/Toolbox/AgentProcessor.php index b966d29d6..72f39568a 100644 --- a/src/agent/src/Toolbox/AgentProcessor.php +++ b/src/agent/src/Toolbox/AgentProcessor.php @@ -44,12 +44,18 @@ public function __construct( public function processInput(Input $input): void { + $options = $input->getOptions(); + + // If the option 'tools' is already an array of tools, do nothing + if (isset($options['tools']) && $this->isToolsArray($options['tools'])) { + return; + } + $toolMap = $this->toolbox->getTools(); if ([] === $toolMap) { return; } - $options = $input->getOptions(); // only filter tool map if list of strings is provided as option if (isset($options['tools']) && $this->isFlatStringArray($options['tools'])) { $toolMap = array_values(array_filter($toolMap, fn (Tool $tool) => \in_array($tool->name, $options['tools'], true))); @@ -85,6 +91,11 @@ private function isFlatStringArray(array $tools): bool return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && \is_string($item), true); } + private function isToolsArray(array $tools): bool + { + return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && $item instanceof Tool, true); + } + private function handleToolCallsCallback(Output $output): \Closure { return function (ToolCallResult $result, ?AssistantMessage $streamedAssistantResponse = null) use ($output): ResultInterface { From b304b3c30a725e3fc6607f3b2723a015c19285de Mon Sep 17 00:00:00 2001 From: Franz Wilding Date: Wed, 1 Oct 2025 10:27:02 +0200 Subject: [PATCH 2/6] Update AgentProcessor.php --- src/agent/src/Toolbox/AgentProcessor.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/agent/src/Toolbox/AgentProcessor.php b/src/agent/src/Toolbox/AgentProcessor.php index 72f39568a..6cd273b82 100644 --- a/src/agent/src/Toolbox/AgentProcessor.php +++ b/src/agent/src/Toolbox/AgentProcessor.php @@ -91,6 +91,9 @@ private function isFlatStringArray(array $tools): bool return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && \is_string($item), true); } + /** + * @param array $tools + */ private function isToolsArray(array $tools): bool { return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && $item instanceof Tool, true); From 78aad6d97fd7aba9feee01047470a212e6dd00c7 Mon Sep 17 00:00:00 2001 From: Franz Wilding Date: Mon, 29 Sep 2025 11:04:08 +0200 Subject: [PATCH 3/6] Update AgentProcessor.php --- src/agent/src/Toolbox/AgentProcessor.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/agent/src/Toolbox/AgentProcessor.php b/src/agent/src/Toolbox/AgentProcessor.php index b966d29d6..72f39568a 100644 --- a/src/agent/src/Toolbox/AgentProcessor.php +++ b/src/agent/src/Toolbox/AgentProcessor.php @@ -44,12 +44,18 @@ public function __construct( public function processInput(Input $input): void { + $options = $input->getOptions(); + + // If the option 'tools' is already an array of tools, do nothing + if (isset($options['tools']) && $this->isToolsArray($options['tools'])) { + return; + } + $toolMap = $this->toolbox->getTools(); if ([] === $toolMap) { return; } - $options = $input->getOptions(); // only filter tool map if list of strings is provided as option if (isset($options['tools']) && $this->isFlatStringArray($options['tools'])) { $toolMap = array_values(array_filter($toolMap, fn (Tool $tool) => \in_array($tool->name, $options['tools'], true))); @@ -85,6 +91,11 @@ private function isFlatStringArray(array $tools): bool return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && \is_string($item), true); } + private function isToolsArray(array $tools): bool + { + return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && $item instanceof Tool, true); + } + private function handleToolCallsCallback(Output $output): \Closure { return function (ToolCallResult $result, ?AssistantMessage $streamedAssistantResponse = null) use ($output): ResultInterface { From e8459c47683f568e82639787cf063f8008fb659c Mon Sep 17 00:00:00 2001 From: Franz Wilding Date: Wed, 1 Oct 2025 10:27:02 +0200 Subject: [PATCH 4/6] Update AgentProcessor.php --- src/agent/src/Toolbox/AgentProcessor.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/agent/src/Toolbox/AgentProcessor.php b/src/agent/src/Toolbox/AgentProcessor.php index 72f39568a..6cd273b82 100644 --- a/src/agent/src/Toolbox/AgentProcessor.php +++ b/src/agent/src/Toolbox/AgentProcessor.php @@ -91,6 +91,9 @@ private function isFlatStringArray(array $tools): bool return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && \is_string($item), true); } + /** + * @param array $tools + */ private function isToolsArray(array $tools): bool { return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && $item instanceof Tool, true); From a669ea4a49d12d44d91861e22b5dd2f8bd9c3444 Mon Sep 17 00:00:00 2001 From: Franz Wilding Date: Mon, 29 Sep 2025 11:04:08 +0200 Subject: [PATCH 5/6] Update AgentProcessor.php # Conflicts: # src/agent/src/Toolbox/AgentProcessor.php --- src/agent/src/Toolbox/AgentProcessor.php | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/agent/src/Toolbox/AgentProcessor.php b/src/agent/src/Toolbox/AgentProcessor.php index 6cd273b82..b966d29d6 100644 --- a/src/agent/src/Toolbox/AgentProcessor.php +++ b/src/agent/src/Toolbox/AgentProcessor.php @@ -44,18 +44,12 @@ public function __construct( public function processInput(Input $input): void { - $options = $input->getOptions(); - - // If the option 'tools' is already an array of tools, do nothing - if (isset($options['tools']) && $this->isToolsArray($options['tools'])) { - return; - } - $toolMap = $this->toolbox->getTools(); if ([] === $toolMap) { return; } + $options = $input->getOptions(); // only filter tool map if list of strings is provided as option if (isset($options['tools']) && $this->isFlatStringArray($options['tools'])) { $toolMap = array_values(array_filter($toolMap, fn (Tool $tool) => \in_array($tool->name, $options['tools'], true))); @@ -91,14 +85,6 @@ private function isFlatStringArray(array $tools): bool return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && \is_string($item), true); } - /** - * @param array $tools - */ - private function isToolsArray(array $tools): bool - { - return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && $item instanceof Tool, true); - } - private function handleToolCallsCallback(Output $output): \Closure { return function (ToolCallResult $result, ?AssistantMessage $streamedAssistantResponse = null) use ($output): ResultInterface { From 0c55951189559ff9d39b33e66129e5985244746c Mon Sep 17 00:00:00 2001 From: Franz Wilding Date: Wed, 1 Oct 2025 10:27:02 +0200 Subject: [PATCH 6/6] Update AgentProcessor.php --- src/agent/src/Toolbox/AgentProcessor.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/agent/src/Toolbox/AgentProcessor.php b/src/agent/src/Toolbox/AgentProcessor.php index b966d29d6..6cd273b82 100644 --- a/src/agent/src/Toolbox/AgentProcessor.php +++ b/src/agent/src/Toolbox/AgentProcessor.php @@ -44,12 +44,18 @@ public function __construct( public function processInput(Input $input): void { + $options = $input->getOptions(); + + // If the option 'tools' is already an array of tools, do nothing + if (isset($options['tools']) && $this->isToolsArray($options['tools'])) { + return; + } + $toolMap = $this->toolbox->getTools(); if ([] === $toolMap) { return; } - $options = $input->getOptions(); // only filter tool map if list of strings is provided as option if (isset($options['tools']) && $this->isFlatStringArray($options['tools'])) { $toolMap = array_values(array_filter($toolMap, fn (Tool $tool) => \in_array($tool->name, $options['tools'], true))); @@ -85,6 +91,14 @@ private function isFlatStringArray(array $tools): bool return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && \is_string($item), true); } + /** + * @param array $tools + */ + private function isToolsArray(array $tools): bool + { + return array_reduce($tools, fn (bool $carry, mixed $item) => $carry && $item instanceof Tool, true); + } + private function handleToolCallsCallback(Output $output): \Closure { return function (ToolCallResult $result, ?AssistantMessage $streamedAssistantResponse = null) use ($output): ResultInterface {