StructuredContent call tool result, added ability to return error from tool (#93)
This commit is contained in:
parent
6100ffcf3f
commit
d347c84472
1 changed files with 74 additions and 5 deletions
|
|
@ -59,14 +59,17 @@ final class CallToolHandler implements RequestHandlerInterface
|
|||
}
|
||||
|
||||
$result = $this->referenceHandler->handle($reference, $arguments);
|
||||
$formatted = $reference->formatResult($result);
|
||||
|
||||
if (!$result instanceof CallToolResult) {
|
||||
$result = new CallToolResult($reference->formatResult($result));
|
||||
}
|
||||
|
||||
$this->logger->debug('Tool executed successfully', [
|
||||
'name' => $toolName,
|
||||
'result_type' => \gettype($result),
|
||||
]);
|
||||
|
||||
return new Response($request->getId(), new CallToolResult($formatted));
|
||||
return new Response($request->getId(), $result);
|
||||
} catch (ToolNotFoundException $e) {
|
||||
$this->logger->error('Tool not found', ['name' => $toolName]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue