Conjure.ToolResult (Conjure v0.1.1-alpha)

View Source

Result of executing a tool call.

Tool results are sent back to Claude in the conversation to report the outcome of tool executions. They include the original tool call ID, the result content, and an error flag.

Content Types

The content can be:

  • A simple string for text output
  • A list of content blocks for complex responses (text, images)

Example

A successful file read:

%Conjure.ToolResult{
  tool_use_id: "toolu_01ABC123",
  content: "File contents here...",
  is_error: false
}

A failed command:

%Conjure.ToolResult{
  tool_use_id: "toolu_01ABC123",
  content: "Command failed with exit code 1: No such file",
  is_error: true
}

Summary

Functions

Creates an error tool result.

Creates a successful tool result.

Converts the tool result to the format expected by the Claude API.

Types

content()

@type content() :: String.t() | [content_block()]

content_block()

@type content_block() ::
  %{type: :text, text: String.t()} | %{type: :image, source: map()}

t()

@type t() :: %Conjure.ToolResult{
  content: content(),
  is_error: boolean(),
  tool_use_id: String.t(),
  type: :tool_result
}

Functions

error(tool_use_id, content)

@spec error(String.t(), content()) :: t()

Creates an error tool result.

success(tool_use_id, content)

@spec success(String.t(), content()) :: t()

Creates a successful tool result.

to_api_format(result)

@spec to_api_format(t()) :: map()

Converts the tool result to the format expected by the Claude API.