class ToolSearch

Properties

protected int $maxToolCalls
protected int $maxOutputBytes
protected array<int, string|Tool> $tools

Methods

__construct(iterable $tools)

Create a searchable tool catalog.

array
tools()

Return the search and execution tools.

array
search(string $query, int $limit)

Search eligible tools within the output limit.

array
execute(array $calls, Request $parentRequest)

Execute requested tools and collect their results.

response(array $content, bool $isError = false)

Encode a tool-search result as response content.

array
invokeTool(Collection $tools, string $name, array $arguments, Request $parentRequest, int $index)

Invoke a catalog tool under its own request context.

resolvedTools()

Resolve the catalog and reject duplicate names.

array
terms(string $text)

Split search text into normalized terms.

array
failedResult(string $message)

Build a failed tool result.

array
outputLimitExceeded(int $completedToolCalls = 0, int $attemptedToolCalls = 0)

Describe an output-limit failure.

int
outputSize(array $output)

Measure the encoded output size.

Details

at line 36
__construct(iterable $tools)

Create a searchable tool catalog.

Parameters

iterable $tools

at line 57
array tools()

Return the search and execution tools.

Return Value

array

Search eligible tools within the output limit.

Parameters

string $query
int $limit

Return Value

array

at line 134
array execute(array $calls, Request $parentRequest)

Execute requested tools and collect their results.

Parameters

array $calls
Request $parentRequest

Return Value

array

at line 165
Response response(array $content, bool $isError = false)

Encode a tool-search result as response content.

Parameters

array $content
bool $isError

Return Value

Response

at line 179
protected array invokeTool(Collection $tools, string $name, array $arguments, Request $parentRequest, int $index)

Invoke a catalog tool under its own request context.

Parameters

Collection $tools
string $name
array $arguments
Request $parentRequest
int $index

Return Value

array

at line 234
protected Collection resolvedTools()

Resolve the catalog and reject duplicate names.

Return Value

Collection

at line 254
protected array terms(string $text)

Split search text into normalized terms.

Parameters

string $text

Return Value

array

at line 267
protected array failedResult(string $message)

Build a failed tool result.

Parameters

string $message

Return Value

array

at line 280
protected array outputLimitExceeded(int $completedToolCalls = 0, int $attemptedToolCalls = 0)

Describe an output-limit failure.

Parameters

int $completedToolCalls
int $attemptedToolCalls

Return Value

array

at line 298
protected int outputSize(array $output)

Measure the encoded output size.

Parameters

array $output

Return Value

int