Parses ~~~tool_call fenced blocks out of assistant text.
The contract with the model (enforced by the system-prompt preamble added by
ExAthena.ToolCalls.augment_system_prompt/2):
~~~tool_call
{"name": "read_file", "arguments": {"path": "/foo/bar"}}
~~~Rules:
- One block per call. Multiple blocks in one response are allowed.
- Both fences must be on their own lines.
idis optional in the payload; missing ids are generated server-side.- Malformed JSON in a block is returned as an error on that block; other well-formed blocks in the same text are still parsed (best-effort).
A valid ~~~tool_call block carries the model's intent to call a tool even
if the model also emitted a prose preamble around the block — this parser
returns tool calls only; the prose is left alone and should not be replayed
as a response to the user until the tools have actually run.
Summary
Functions
Extract tool calls from assistant text. Always returns a list.
Functions
@spec parse(String.t()) :: {:ok, [ExAthena.Messages.ToolCall.t()]} | {:error, term()}
Extract tool calls from assistant text. Always returns a list.