Events are the individual observations that make up a trace. Each time your agent calls an LLM, invokes a tool, submits a Solana transaction, or reaches a decision point, Mortem records that moment as an event with a type, payload, timing, and status. The dashboard assembles these events into a chronological decision sequence you can replay and inspect.Documentation Index
Fetch the complete documentation index at: https://docs.mortemlabs.com/llms.txt
Use this file to discover all available pages before exploring further.
How events work
Every event belongs to a session and is recorded through anEventBuilder. When you use the SDK wrappers (wrapOpenAI, wrapAnthropic, wrapConnection, and so on), events are captured automatically. For steps that wrappers do not cover, call session.beginEvent() directly.
event.run() to wrap an async function and have the SDK complete or fail the event automatically:
Event statuses
Every completed event has a status:| Status | Meaning |
|---|---|
"ok" | The event completed successfully. |
"error" | The event failed. The errorMessage field is populated. |
event.complete() to record status "ok", or event.fail(error) to record status "error".
Parent and child events
Nest events under a parent to represent hierarchical work — for example, a planning step that triggers several tool calls. Useoptions.parentEventId when calling session.beginEvent():
When you wrap LLM clients and tools with Mortem’s wrappers and call them inside
session.run(), parent-child linking is handled automatically through async context. Manual parentEventId is only needed when you manage the nesting yourself.Auto-captured event types
These event types are recorded automatically when you use the corresponding SDK wrapper. You do not need to callsession.beginEvent() for them.
llm_call
Recorded whenever your agent calls a wrapped LLM — OpenAI, Anthropic, Ollama, or a Vercel AI SDK model. Captures the model name, token usage, and estimated cost.
Captured by: mortem.wrapOpenAI(), mortem.wrapAnthropic(), mortem.wrapOllama(), mortem.wrapLanguageModel()
Payload shape:
tool_call
Recorded whenever a wrapped tool is invoked by the LLM. Captures the tool name, the input the model sent, and the output your function returned.
Captured by: mortem.wrapTools(), mortem.langchainHandler()
Payload shape:
solana_tx
Recorded whenever a Solana transaction is sent through a wrapped connection. Captures the transaction signature and the lamports transferred.
Captured by: mortem.wrapConnection()
Payload shape:
Manual event types
These event types are not captured by wrappers. Record them yourself withsession.beginEvent().
x402_payment
Record an x402 payment event — an HTTP 402-based micropayment made by your agent.
mcp_call
Record a Model Context Protocol tool call made by your agent.
custom
Record any arbitrary step in your agent’s reasoning process. Use custom events to mark decisions, checkpoints, strategy evaluations, or any other named step that is meaningful for post-trade debugging.
BeginEventOptions
Pass these as the third argument to session.beginEvent() to control timing, identity, and nesting.
Override the auto-generated event ID. Useful when you need to correlate this event with an external system identifier.
Nest this event under a parent event. Set to the parent
EventBuilder.id. Pass null explicitly to make the event a root event even when called inside a parent context.Backfill the event start time. Use this if the work already began before you called
beginEvent.CompleteEventOptions
Pass these to event.complete() to attach a result payload and override timing.
The result or output of this event. Any JSON-serializable value is accepted. If omitted, the payload passed to
beginEvent is used as-is.Override the completion status. Defaults to
"ok". Pass "error" if the event represents a failure you want to mark explicitly without calling event.fail().Override the event end time. Defaults to the moment
complete() is called.