ToolBase
The runtime contract that every tool dispatched by the agent satisfies.
The agent runtime invokes execute uniformly, threading caller- and feature-supplied ToolCallMetadata alongside the typed TArgs. Subclasses define what that overload means:
Tool is the conventional shape with an Tool.execute taking only the arguments. Existing subclasses keep working unchanged.
ai.koog.agents.core.agent.tools.AgentContextAwareTool (in
agents-core) gives the implementation typed access to the liveAIAgentContextdriving the current call.
A subclass that needs raw ToolCallMetadata (for example to read a trace span id contributed by a feature) can extend ToolBase directly and override execute. Splitting that concern from the agent-context concern keeps agents-tools free of any agents-core dependency.
Type Parameters
The type of arguments the tool accepts.
The type of result the tool returns.
Inheritors
Constructors
Convenience constructor that generates ToolDescriptor from the provided name, description and argsType.
Properties
A ToolDescriptor representing the tool's schema, including its name, description, and parameters.
The name of the tool from the descriptor.
Type token representing result type TResult.
Functions
Decodes the provided raw JSON arguments into an instance of the specified arguments type.
Decodes the provided raw JSON element into an instance of the specified result type.
Encodes the given arguments into a JSON representation.
Encodes the provided arguments into a JSON string representation.
Encodes the provided arguments into a JSON string representation without type safety checks.
Encodes the given arguments into a JSON representation without type safety checks.
Encodes the given result into a JSON representation.
Encodes the given result of type TResult to its string representation. This is used to provide the LLM with the result of the tool execution. It can be overridden to customize the string representation the LLM will see.
Encodes the provided result object into a JSON string representation without type safety checks.
Encodes the given result object into a JSON representation without type safety checks.
Executes the tool with the provided arguments without type safety checks.
Executes the tool with the provided arguments and metadata without type safety checks.