Conjure.ToolCall (Conjure v0.1.1-alpha)

View Source

Represents a tool call from Claude's response.

When Claude uses a tool, the API response includes a tool_use content block with an ID, tool name, and input parameters. This struct captures that information for processing.

Example

A tool call from Claude's response:

%{
  "type" => "tool_use",
  "id" => "toolu_01ABC123",
  "name" => "view",
  "input" => %{"path" => "/path/to/file.txt"}
}

Becomes:

%Conjure.ToolCall{
  id: "toolu_01ABC123",
  name: "view",
  input: %{"path" => "/path/to/file.txt"}
}

Summary

Functions

Creates a ToolCall from a tool_use content block.

Gets an input parameter value.

Extracts the tool call ID.

Types

t()

@type t() :: %Conjure.ToolCall{id: String.t(), input: map(), name: String.t()}

Functions

from_content_block(block)

@spec from_content_block(map()) :: {:ok, t()} | {:error, term()}

Creates a ToolCall from a tool_use content block.

Returns {:ok, tool_call} on success, or {:error, reason} if the block is malformed.

get_input(tool_call, key, default \\ nil)

@spec get_input(t(), String.t(), term()) :: term()

Gets an input parameter value.

id(tool_call)

@spec id(t()) :: String.t()

Extracts the tool call ID.