ExAgent.Message.Part.ToolCall (ExAgent v3.0.0)

View Source

The model asking the agent to run a tool.

Stability — Stable.

args may be nil, a decoded map(), or raw JSON binary() (the latter when the provider streams partial JSON). Use args_as_map/1 to normalise.

Summary

Functions

Decode args to a map. Maps pass through and nil returns :empty. Invalid JSON returns {:error, reason}. Duplicate object keys, including differently escaped spellings of the same key, return a uniqueKeys error. The agent can ask the model to correct invalid arguments.

Types

arg()

@type arg() :: nil | map() | binary()

kind()

@type kind() :: :function | :output | :external

t()

@type t() :: %ExAgent.Message.Part.ToolCall{
  args: arg(),
  kind: kind(),
  metadata: map(),
  tool_call_id: String.t() | nil,
  tool_name: String.t()
}

Functions

args_as_map(tool_call)

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

Decode args to a map. Maps pass through and nil returns :empty. Invalid JSON returns {:error, reason}. Duplicate object keys, including differently escaped spellings of the same key, return a uniqueKeys error. The agent can ask the model to correct invalid arguments.