AI.Message.FunctionCall (fnord v0.9.40)

View Source

Assistant-emitted tool call request. Wire shape:

%{type: "function_call", call_id: "...", name: "tool_name",
  arguments: "<json-encoded-string>"}

Critical invariant

arguments MUST be a JSON-encoded string, NEVER a decoded map. The previous Responses API attempt drove off this cliff: when arguments are stored as maps, Util.string_keys_to_atoms/1 recurses into them on read and atomizes LLM-emitted garbage keys, exhausting the BEAM atom table. See engram memory "Conversation file corruption - responses branch tool arguments".

Callers that need to parse the arguments map can do so on demand at the call site (where the keys are bounded by the tool's schema), but the canonical form on disk and in memory is the raw JSON string.

Summary

Functions

Hydrate from a Responses-shaped map (atom or string keys). Re-encodes arguments to a JSON string if a legacy v0 conversation file stored it as a decoded map - the atom-table-safe invariant on disk is "string", not "map".

Build a function-call request. arguments must already be a JSON string.

Types

t()

@type t() :: %AI.Message.FunctionCall{
  arguments: binary(),
  call_id: binary(),
  name: binary(),
  type: term()
}

Functions

from_map(raw)

@spec from_map(map()) :: t()

Hydrate from a Responses-shaped map (atom or string keys). Re-encodes arguments to a JSON string if a legacy v0 conversation file stored it as a decoded map - the atom-table-safe invariant on disk is "string", not "map".

new(call_id, name, arguments)

@spec new(binary(), binary(), binary()) :: t()

Build a function-call request. arguments must already be a JSON string.