ToolResult
Represent the outcome of a tool execution.
Usage
ToolResult()Every tool returns a ToolResult (or Talk Box wraps the return value in one). The object carries the primary data, success/failure status, optional metadata such as confidence scores and source citations, and a display format hint that controls how the result is rendered in conversations.
Parameters
data: Any-
The primary return value of the tool. Can be any serializable type.
success: bool = True-
Whether the tool executed without errors. Defaults to
True. error: Optional[str] = None-
A human-readable error message when
successisFalse. metadata: Optional[Dict[str, Any]] = None-
Arbitrary key-value pairs for downstream consumers (analytics, logging, etc.).
display_format: str = "auto"-
Hint for how to render the result in a conversation. One of
"auto","json","text","html", or"markdown". Defaults to"auto". should_continue: bool = True-
Whether the conversation should continue after this tool result. Set to
Falseto signal that the tool’s output is terminal. Defaults toTrue. confidence: Optional[float] = None-
Optional float between 0 and 1 indicating how confident the tool is in its result.
sources: Optional[List[str]] = None-
Optional list of source URLs or identifiers that back the result.
extra: Optional[Dict[str, Any]] = None- Open-ended dictionary for additional data.
Examples
Return a successful result from a tool function:
from talk_box.tools import ToolResult
result = ToolResult(data={"temperature": 72, "unit": "F"}, confidence=0.95)
result.successSignal an error:
err = ToolResult(data=None, success=False, error="API key expired")
err.successMethods
| Name | Description |
|---|---|
| to_chatlas_result() | Convert to chatlas ContentToolResult for integration. |
to_chatlas_result()
Convert to chatlas ContentToolResult for integration.
Usage
to_chatlas_result()