AshAi.ToolLoop.Result (ash_ai v1.5.6)

Copy Markdown View Source

Result returned from a completed tool loop.

:status is one of:

  • :complete
  • :awaiting_approval - the loop stopped for the tool calls in :pending_approvals. See "Approvals" in AshAi.ToolLoop.
  • :paused - a tool asked to pause, for example because the user has to authorize an MCP server. :paused_calls holds %{call: call, reason: reason} for each. Resume like an approval.

:approvals holds the decisions from the :approvals option for calls that are still waiting, such as an approved call that then paused. Store them with the turn and pass them back when resuming, so the user isn't asked twice.

:usage is the token-usage totals summed across every stream_text/3 call made during the loop (one per iteration). Keys mirror what the underlying ReqLLM provider reports — typically :input_tokens, :output_tokens, and any cost/cache fields. Numeric fields are summed; non-numeric fields fall through to the most recent value. Empty %{} when no provider reported usage.