Class AssistantToolCatalog
The tools a server serves an assistant, by name: what rdcore/tools/list lists and rdcore/tools/call calls.
public sealed class AssistantToolCatalog
- Inheritance
-
AssistantToolCatalog
- Inherited Members
Remarks
A call is answered with what the tool answers, its text cut at TextLength characters. A tool that refuses the call, by
throwing an AssistantToolRefusedException or an RpcErrorException, is answered with a refusal
(Refusal(string)): the call did nothing, and the assistant reads why. A call of a tool the catalog does not have is a JSON-RPC
error (-32602), as the Model Context Protocol answers it.
Constructors
AssistantToolCatalog(IEnumerable<IAssistantTool>)
A catalog of tools.
public AssistantToolCatalog(IEnumerable<IAssistantTool> tools)
Parameters
toolsIEnumerable<IAssistantTool>The tools, in the order the catalog lists them.
Exceptions
- ArgumentException
Two tools have the same name, or a name is not one a tool can have (Name).
Fields
UnknownToolCode
JSON-RPC "Invalid params": the code a call of a tool the catalog does not have is refused with.
public const int UnknownToolCode = -32602
Field Value
Properties
Tools
The tools, in the order the catalog lists them.
public IReadOnlyList<IAssistantTool> Tools { get; }
Property Value
Methods
CallAsync(ToolCallParams, CancellationToken)
Calls a tool (rdcore/tools/call).
public Task<ToolCallResult> CallAsync(ToolCallParams call, CancellationToken token)
Parameters
callToolCallParamsThe tool, and its arguments.
tokenCancellationTokenCancels the call.
Returns
- Task<ToolCallResult>
What the tool answers, or why it refuses the call.
Exceptions
- RpcErrorException
The catalog has no tool by the name the call gives (UnknownToolCode).
- OperationCanceledException
tokenwas cancelled.
List(CultureInfo)
Lists the tools (rdcore/tools/list).
public ToolsListResult List(CultureInfo culture)
Parameters
cultureCultureInfoThe language of the client's user interface.
Returns
- ToolsListResult
The descriptor of each tool, in that language.