MingaAgent.ToolCall (Minga v0.1.0)

Copy Markdown View Source

A single tool call in the agent conversation.

Tracks the tool's identity (id, name, args), its execution lifecycle (status, result, error state, timing), and display state (collapsed).

Mutation methods live here so consumers don't scatter %{tc | ...} updates across 11 files. Each method encodes a domain transition: complete/2 records the result and collapses the output, error/2 marks a failure, abort/1 handles user cancellation mid-execution.

Summary

Types

Scope that auto-approved this tool call.

Tool call execution status.

t()

A tool call.

Functions

Aborts a running tool call. Only transitions :running calls.

Marks the tool call as successfully completed, recording the result and duration.

Marks the tool call as failed, recording the error result and duration.

Returns true if the tool call has finished (complete or error).

Creates a new running tool call with a monotonic start timestamp.

Records the trust scope that auto-approved this tool call.

Sets the collapsed state to a specific value.

Toggles the collapsed display state.

Updates the partial result during streaming, auto-expanding the display.

Types

auto_approved_scope()

@type auto_approved_scope() :: :session | :turn

Scope that auto-approved this tool call.

status()

@type status() :: :running | :complete | :error

Tool call execution status.

t()

@type t() :: %MingaAgent.ToolCall{
  args: map(),
  auto_approved_scope: auto_approved_scope() | nil,
  collapsed: boolean(),
  duration_ms: non_neg_integer() | nil,
  id: String.t(),
  is_error: boolean(),
  name: String.t(),
  result: String.t(),
  started_at: integer() | nil,
  status: status()
}

A tool call.

Functions

abort(tc)

@spec abort(t()) :: t()

Aborts a running tool call. Only transitions :running calls.

complete(tc, result)

@spec complete(t(), String.t()) :: t()

Marks the tool call as successfully completed, recording the result and duration.

error(tc, result)

@spec error(t(), String.t()) :: t()

Marks the tool call as failed, recording the error result and duration.

finished?(tool_call)

@spec finished?(t()) :: boolean()

Returns true if the tool call has finished (complete or error).

new(id, name, args \\ %{})

@spec new(String.t(), String.t(), map()) :: t()

Creates a new running tool call with a monotonic start timestamp.

set_auto_approved_scope(tc, scope)

@spec set_auto_approved_scope(t(), auto_approved_scope() | nil) :: t()

Records the trust scope that auto-approved this tool call.

set_collapsed(tc, collapsed)

@spec set_collapsed(t(), boolean()) :: t()

Sets the collapsed state to a specific value.

toggle_collapsed(tc)

@spec toggle_collapsed(t()) :: t()

Toggles the collapsed display state.

update_partial(tc, partial_result)

@spec update_partial(t(), String.t()) :: t()

Updates the partial result during streaming, auto-expanding the display.