# `MingaAgent.ToolCall`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_agent/tool_call.ex#L1)

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.

# `status`

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

Tool call execution status.

# `t`

```elixir
@type t() :: %MingaAgent.ToolCall{
  args: map(),
  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.

# `abort`

```elixir
@spec abort(t()) :: t()
```

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

# `complete`

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

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

# `error`

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

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

# `finished?`

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

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

# `new`

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

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

# `set_collapsed`

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

Sets the collapsed state to a specific value.

# `toggle_collapsed`

```elixir
@spec toggle_collapsed(t()) :: t()
```

Toggles the collapsed display state.

# `update_partial`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
