Mimir.Ingest (Mimir v0.3.0)

Copy Markdown View Source

Decision-correlated ingestion of raw agent-session events into Mimir.TurnEvents. Targets RMA's documented plain-data event maps — raw provider events plus the synthetic "rma.text_delta" — but accepts any binary-keyed %{"type" => ...} map. No RMA types.

Build a context with new/1 or from_route/2, then call handle_event/2 from your session handler's event hook. Each ingested event lands in the TurnEvents buffer keyed by request_id, with the decision correlation merged into its gen_ai map — the same buffer the embedder drains (Mimir.TurnEvents.take/1) when it meters the run.

Summary

Functions

Build a context straight from a Mimir.RouteResponse.

Ingest one raw event map. Always returns :ok; never raises into the session loop.

Options: :request_id (required), :decision_id, :metadata — a binary-keyed map merged into every ingested event's gen_ai payload.

Types

t()

@type t() :: %Mimir.Ingest{
  decision_id: String.t() | nil,
  metadata: %{optional(String.t()) => term()},
  request_id: String.t()
}

Functions

from_route(resp, request_id)

@spec from_route(Mimir.RouteResponse.t(), String.t()) :: t()

Build a context straight from a Mimir.RouteResponse.

handle_event(ctx, event)

@spec handle_event(t(), map()) :: :ok

Ingest one raw event map. Always returns :ok; never raises into the session loop.

new(opts)

@spec new(keyword()) :: t()

Options: :request_id (required), :decision_id, :metadata — a binary-keyed map merged into every ingested event's gen_ai payload.