> For the complete documentation index, see [llms.txt](https://krynix.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krynix.gitbook.io/docs/reference/event-types.md). Agents can also search and read this documentation through its [MCP server](https://krynix.gitbook.io/docs/~gitbook/mcp).

# Event types

A session is a sequence of events. Every event, whatever produced it, is one of eight types in one envelope. The full schema (version 1.1.0) is in the [Trace format](https://krynix.gitbook.io/docs/reference/trace-format.md); this page is what you need to read a session or write one.

## The envelope

| Field                                     | Who sets it     | Notes                                                                                                        |
| ----------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------ |
| `event_id`                                | you             | A UUID.                                                                                                      |
| `session_id`                              | you             | Must equal the session in the request path.                                                                  |
| `agent_id`                                | you             | The agent that produced the event. The first event of a new session names the session's agent.               |
| `event_type`                              | you             | One of the eight below.                                                                                      |
| `timestamp`                               | you             | ISO-8601, the agent's clock.                                                                                 |
| `parent_id`                               | you             | The causal parent's `event_id`, or `null`. For OpenTelemetry spans Krynix fills it from the span's parent.   |
| `payload`                                 | you             | Type-specific, below.                                                                                        |
| `metadata`                                | you, and Krynix | Free-form context. Krynix adds provenance here: the source family, the actor (sub-agent), the capture flags. |
| `redacted`                                | you             | `true` if the payload was scrubbed before sending.                                                           |
| `schema_version`                          | you             | `1.1.0`.                                                                                                     |
| `sequence_num`, `prev_hash`, `event_hash` | **Krynix**      | Assigned on arrival. Values you send are ignored.                                                            |

## The eight types

| Type           | Payload                                                                                                                                                                                    | Example source                                                                 |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
| `tool_call`    | `tool_name`, `arguments` (object; `{}` with `arguments_captured: false` in metadata when the source did not carry them)                                                                    | Claude Code's `PreToolUse`, a GenAI `execute_tool` span, `session.tool_call()` |
| `tool_result`  | `tool_name`, `output`, `duration_ms` (`-1` when unmeasured), `exit_code` (absent when unreported, never `0` by default)                                                                    | `PostToolUse`, the span's end                                                  |
| `llm_request`  | `model`, `messages`, `parameters`                                                                                                                                                          | Claude Code's logs, an inference span                                          |
| `llm_response` | `model`, `content`, `usage` (`prompt_tokens`, `completion_tokens`; cache counters in metadata), `finish_reason` (`stop`, `max_tokens`, `tool_use`)                                         | the same                                                                       |
| `decision`     | `action`, `reasoning`, and `policy_decision` (policy, rule, verdict, the attempted action characterised without raw arguments)                                                             | `POST /v1/decide`, the gateway                                                 |
| `observation`  | `source`, `content`; typed observations carry a `category` (`user_prompt`, `assistant_response`, `plugin_loaded`, `hook_registered`, `subagent_completed`, `managed_settings_resolved`, …) | a human message, a webhook, Claude Code's own records                          |
| `error`        | `code`, `message`, `recoverable`                                                                                                                                                           | a failed API call, a tool timeout                                              |
| `lifecycle`    | `action`: `session_start`, `session_end`, `checkpoint`; `session_end` carries `closed_by`                                                                                                  | written by the session's start and end                                         |

## What the record says about itself

A few conventions keep the record honest, and they show up on the session page:

* **Absent is not zero.** A result with no exit code is recorded without one, and the tool's failure rate is reported as a floor with the unreported count beside it. Token counts the source did not report carry `token_usage_reported: false`.
* **Not captured is not empty.** `messages: []` with `content_captured: false` means the install did not capture the conversation. An empty tool output with `output_captured: false` is not a tool that returned nothing.
* **A record Krynix did not interpret** keeps its vendor namespace in metadata and is counted as uninterpreted, so a control cannot pass a session on the strength of records it could not read.
* **One call, several records.** Claude Code describes one tool call three ways (hook, logs, spans), and no copy is complete. Krynix keeps the first copy in the chain and the fields a later copy adds as an enrichment record, merged when you read, so the chain is never amended and the call is counted once.
* **Prompt text and response text** live on `user_prompt` and `assistant_response` observations, never on `llm_request` or `llm_response`.
* **A sub-agent** is an actor within its session (`metadata.subagent_id`, `subagent_type`, `parent_subagent_id`), never a separate agent.
