Imp.Run.Event (Imp v0.5.0)

Copy Markdown View Source

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.
  • :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 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.

Summary

Functions

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

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

Types

kind()

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

One of kinds/0.

t()

@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
}

Functions

kinds()

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

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

to_map(event)

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