Tool Result • AI Agent SDK

ToolResult: Wrapper for tool execution results.

ToolResult

Defined in the base module.

AI Agent

Wrapper for tool execution results.

In addition to the text/JSON `output channel, tools may return a structured, multimodal content` channel so that images/files produced by a tool become model-visible message parts on the next turn (e.g. a screenshot tool, chart renderer, or PDF rasteriser feeding a vision model).

`content` is an ordered list of content parts. Each part is a dict:

  • `{"type": "text", "text": "..."}`
  • “{”type”: “image”, “data”: <base64-str-or-bytes>, “mime”: “image/png”,
  • “name”: “shot.png”}“
  • `{"type": "image", "url": "https://... or data:..."}`
  • `{"type": "file", "data": ..., "mime": "application/pdf", "name": ...}`

Plain text/JSON tool returns behave exactly as before; multimodal is purely additive and opt-in by the tool author.

For context economy, a tool may also set `model_output to a compact, model-facing summary/diff. When present the executor feeds model_output to the LLM instead of the full output (fewer tokens), while the full output/content` remain available to display, hooks, and tracing.

Diagram

uses

returns

Agent

Tool: ToolResult

Result

Constructor

ParamField Any

No description available.

ParamField bool

No description available.

ParamField Optional[str]

No description available.

ParamField Optional

No description available.

ParamField Optional

No description available.

ParamField Any

No description available.

Methods

Internal & Generic Methods
  • to_dict: Generic utility method.

Source

View on GitHub

praisonaiagents/tools/base.py at line 32


Related Documentation