# `Imp.Run.Event`
[🔗](https://github.com/deepfates/imp/blob/v0.18.1/lib/imp/run.ex#L533)

A single ordered, protocol-neutral execution event.

`kinds/0` is the complete list of kinds Imp emits:

  * `:run_started`, `:run_finished`, `:run_failed`, `:run_cancelled` — the
    run's lifecycle. Exactly one of the last three ends a run;
    `:run_finished` carries the program's prediction as its `output`.
  * `:model_request`, `:model_response` — one `Imp.LM.request/2` call.
  * `:model_resend` — an attempt at a model call that failed and that the
    client sends again before the call's `:model_response`, such as a
    connection that closed or a 429; `metadata.model_call_id` names the
    call, `attempt` counts from 1 and `retry_in_ms` is the wait.
  * `:tools_sent` — the tool definitions a request sent, once per run per
    distinct roster.
  * `:tool_call`, `:tool_result` — one tool call a ReActV2 or RLM loop
    made, and what came of it; `metadata.outcome` is the call's
    `t:Imp.Tool.outcome/0`.
  * `:reasoning` — a thought the model reported.
  * `:context_projected` — older episodes left out of one request after a
    provider refused it for length.
  * `:capture_gap` — events evicted from the snapshot.

A host may emit kinds of its own inside a run with `Imp.Run.emit/2`; they
are atoms not in `kinds/0`. `Imp.Trajectory.to_atif/2` reads a stored event
whose kind it does not know with the kind kept as the stored string.

# `kind`

```elixir
@type kind() ::
  :run_started
  | :run_finished
  | :run_failed
  | :run_cancelled
  | :model_request
  | :model_response
  | :model_resend
  | :tools_sent
  | :tool_call
  | :tool_result
  | :reasoning
  | :context_projected
  | :capture_gap
```

One of `kinds/0`.

# `t`

```elixir
@type t() :: %Imp.Run.Event{
  component: module() | atom() | String.t() | nil,
  error: term(),
  input: term(),
  kind: kind() | atom() | String.t(),
  metadata: map(),
  output: term(),
  reasoning: term(),
  run_id: String.t(),
  sequence: non_neg_integer(),
  timestamp: String.t() | nil,
  tool_call_id: String.t() | nil,
  tool_name: atom() | String.t() | nil
}
```

# `kinds`

```elixir
@spec kinds() :: [kind()]
```

Every event kind Imp emits, in the order the module documentation lists them.

# `to_map`

Serializes a native event for JSON storage, redacting again at the boundary.

---

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