ExAgent.Message.Part.ToolCall (ExAgent v0.1.0)

Copy Markdown View Source

The model asking the agent to run a tool.

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. Accepts a map (passthrough), a JSON string, or nil. On unparseable JSON, returns :error (the agent turns that into a retry prompt so the model can fix its arguments).

Types

arg()

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

kind()

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

t()

@type t() :: %ExAgent.Message.Part.ToolCall{
  args: arg(),
  kind: kind(),
  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. Accepts a map (passthrough), a JSON string, or nil. On unparseable JSON, returns :error (the agent turns that into a retry prompt so the model can fix its arguments).