Skip to content

ToolResult

The result of a tool execution. Contains a list of content parts, enabling rich tool results (text, images, files, audio) rather than just strings.

Implementations MUST support conversion from a plain string to a ToolResult containing a single TextPart for backward compatibility.

---
title: ToolResult
config:
  look: handDrawn
  theme: colorful
  class:
    hideEmptyMembersBox: true
---
classDiagram
    class ToolResult {
        +ContentPart[] parts
        +text() string [async-capable]
    }
    class ContentPart {
      <<abstract>>
        +string kind
    }
    ToolResult *-- ContentPart
parts:
- kind: text
value: 72°F and sunny
NameTypeDescription
partsContentPart[]The content parts of the tool result(Related Types: TextPart, ImagePart, FilePart, AudioPart)

The following helper methods are declared via @method and must be implemented by every runtime. The schema declares the logical protocol contract; each runtime maps async-capable methods to idiomatic sync/async shapes for that language.

NameSignatureRuntime shapeDescription
texttext() -> stringasync-capableConcatenate all TextPart values joined by newline

The following factory methods are declared via @factory and are generated automatically by the emitter in every language.

  • text(value: string)

The following types are composed within ToolResult: