model_config: ClassVar[ConfigDict] = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
visualize: Text
Return Rich Text representation of this action.
This method can be overridden by subclasses to customize visualization.
The base implementation displays all action fields systematically.
Bases: ProtocolProtocol for tools that are guaranteed to have a non-None executor.This eliminates the need for runtime None checks and type narrowing
when working with tools that are known to be executable.
model_config: ClassVar[ConfigDict] = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
ERROR_MESSAGE_HEADER: ClassVar[str] = ‘[An error occurred during execution.]n’
content: list[TextContent | ImageContent]
is_error: bool
kind: str
model_config: ClassVar[ConfigDict] = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
text: str
Extract all text content from the observation.
Returns:
Concatenated text from all TextContent items in content.
to_llm_content: Sequence[TextContent | ImageContent]
Default content formatting for converting observation to LLM readable content.
Subclasses can override to provide richer content (e.g., images, diffs).
visualize: Text
Return Rich Text representation of this observation.
Subclasses can override for custom visualization; by default we show the
same text that would be sent to the LLM.
model_config: ClassVar[ConfigDict] = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
model_config: ClassVar[ConfigDict] = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
model_config: ClassVar[ConfigDict] = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Bases: DiscriminatedUnionMixin, ABC, GenericBase class for all tool implementations.This class serves as a base for the discriminated union of all tool types.
All tools must inherit from this class and implement the .create() method for
proper initialization with executors and parameters.Features:
Normalize input/output schemas (class or dict) into both model+schema.
Validate inputs before execute.
Coerce outputs only if an output model is defined; else return vanilla JSON.
Simple tool with no parameters:
: class FinishTool(ToolDefinition[FinishAction, FinishObservation]):
: @classmethod
def create(cls, conv_state=None,
<br/>
model_config: ClassVar[ConfigDict] = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Create an action from parsed arguments.This method can be overridden by subclasses to provide custom logic
for creating actions from arguments (e.g., for MCP tools).
Parameters:
arguments – The parsed arguments from the tool call.
Returns:
The action instance created from the arguments.
Return this tool as an ExecutableTool, ensuring it has an executor.This method eliminates the need for runtime None checks by guaranteeing
that the returned tool has a non-None executor.
Returns:
This tool instance, typed as ExecutableTool.
Raises:
NotImplementedError – If the tool has no executor.
Create a sequence of Tool instances.This method must be implemented by all subclasses to provide custom
initialization logic, typically initializing the executor with parameters
from conv_state and other optional parameters.
Parameters:
args** – Variable positional arguments (typically conv_state as first arg).
kwargs* – Optional parameters for tool initialization.
Returns:
A sequence of Tool instances. Even single tools are returned as a sequence
to provide a consistent interface and eliminate union return types.
add_security_risk_prediction – Whether to add a security_risk field
to the action schema for LLM to predict. This is useful for
tools that may have safety risks, so the LLM can reason about
the risk level before calling the tool.
action_type – Optionally override the action_type to use for the schema.
This is useful for MCPTool to use a dynamically created action type
based on the tool’s input schema.
Close the executor and clean up resources.Default implementation does nothing. Subclasses should override
this method to perform cleanup (e.g., closing connections,
terminating processes, etc.).