docs · reference
JSON output#
Every --json flag prints a versioned JSON document on stdout and nothing else there; notes and errors stay on stderr. Each document carries a schema_version, fields are snake_case, token counts are integers, and money is integer micro-dollars (1,000,000 = $1.00) with an estimate_label, never a formatted string. Within a schema version Hekma only adds fields, so parse what you need and ignore the rest.
Documents at a glance#
| Command | Shape | schema_version |
|---|---|---|
hekma agent list --json | One document: totals and instances | 2 |
hekma agent show NAME --json | One document: instance | 2 |
hekma agent usage [NAME] --json | One document: instance and usage, or totals | 2 |
hekma agent config get NAME --json | One document: entries | 1 |
hekma agent logs NAME --json | NDJSON: one object per line | 1 (on every line) |
hekma agent memory attach ... --json | One document | 1 |
hekma agent memory detach ... --json | One document | 1 |
hekma run open|close|show ... --json (Unreleased: after 0.11.0) | One document: run | 1 |
hekma label set|remove ... --json (Unreleased: after 0.11.0) | One document: results | 1 |
hekma ps --json (Unreleased: after 0.11.0) | One document: items and counts | 1 |
hekma agent stop|pause|resume|drain ... --json, hekma run close ... --json (Unreleased: after 0.11.0) | One document: results | 1 |
hekma budget show|set ... --json (Unreleased: after 0.11.0) | One document | 1 |
hekma run keys, revoke-keys ... --json (Unreleased: after 0.11.0) | One document: keys, or revoked | 1 |
| Engine events (embedders) | transition, budget_breach, usage_update; run, policy, breach_default_upgraded and credential (Unreleased: after 0.11.0) | 1 (inside each payload) |
The version belongs to the kind of content, not the command: list, show and usage share the fleet version (2), and the other families have their own.
Compatibility rule#
These documents, and the exit codes, are a stable interface:
- Within a
schema_version, Hekma only adds fields. An existing field keeps its name, type and meaning. - Fields marked optional below are left out when they have no value, rather than printed as
nullor0. Treat every optional field as possibly absent. - Removing or changing a field raises
schema_version. Such a change is announced in the release notes at least one minor release ahead and happens only in a major release.
Check schema_version before you trust the rest of a document, and ignore fields you do not know.
list#
hekma agent list --json prints the whole fleet: fleet totals and one entry per agent.
{
"schema_version": 2,
"totals": {
"total_input_tokens": 2400,
"total_output_tokens": 600,
"total_dollars": 14040,
"dollars_partial": false,
"unpriced_count": 0,
"estimate_label": "estimated",
"total_cached_tokens": 800
},
"instances": [
{
"name": "worker",
"kind": "worker",
"state": "running",
"restart_count": 0,
"restart_policy": "on-failure",
"budget": {
"cumulative_limit": 6000,
"cumulative_remaining": 3000,
"breach_action": "pause"
},
"usage": {
"cumulative_input_tokens": 2400,
"cumulative_output_tokens": 600,
"current_run_input_tokens": 1200,
"current_run_output_tokens": 300,
"cumulative_dollars": 14040,
"current_run_dollars": 7020,
"estimate_label": "estimated",
"cumulative_cached_tokens": 800,
"current_run_cached_tokens": 400
},
"metering_source": "self-reported",
"supervision": "detached",
"agent_home": "/Users/you/Library/Application Support/ktesio/agents/worker"
}
]
}An empty fleet prints "instances": [] and zero totals.
totals#
| Field | Type | Present | Meaning |
|---|---|---|---|
total_input_tokens | integer | always | Cumulative input tokens across all agents (cached tokens included). |
total_output_tokens | integer | always | Cumulative output tokens across all agents. |
total_cached_tokens | integer | optional | Cumulative cached tokens. Absent if any agent's ledger holds usage recorded before Hekma tracked cached tokens. |
total_dollars | integer (micro-dollars) | optional | Summed estimated cost of the agents that have a rate. Absent when no agent has one. |
dollars_partial | boolean | always | true when some agent has usage but no rate, so total_dollars is a lower bound. |
unpriced_count | integer | always | How many agents with usage were left out of total_dollars; 0 unless dollars_partial is true. |
estimate_label | string | optional | estimated; present when total_dollars is. |
Fleet entry#
Each element of instances (and the instance object of show) has these fields.
| Field | Type | Present | Meaning |
|---|---|---|---|
name | string | always | The agent's name. |
kind | string | always | The adapter kind, such as acp or a manifest's [adapter] kind. |
state | string | always | registered, starting, running, paused, stopping, stopped or failed. |
restart_count | integer | always | Consecutive restarts by the restart policy. |
restart_policy | string | always | on-failure or never. |
failed_cause | string | optional | Why the agent failed. Present only when state is failed. |
budget | object or null | always | The budget, or null when no budget is configured. |
usage | object | always | The usage totals; all zeros for an agent that never reported any. |
metering_source | string | always | self-reported or engine-observed. |
acp_context_usage | object | optional | acp agents only, while a live connection has reported its context window. See ACP fields. |
usage_gap | object | optional | acp agents only, when the ledger holds no usage for them. See ACP fields. |
supervision | string | optional | detached or session while a live process is recorded; absent otherwise. See supervision. |
recorded_state | string | optional | Unreleased: after 0.11.0. Present only when the shown state differs from the stored one: a running or paused agent whose process is gone is shown as failed, with a failed_cause naming the pid and no supervision, and its stored state is kept here. Reads write nothing; the next write records the change. See Reads never write. |
breach_default_upgraded | boolean | optional | Unreleased: after 0.11.0. true on an agent the breach-default upgrade keeps on pause; absent otherwise. |
agent_home | string | always | Absolute path of the Agent Home. |
budget object#
Each limit field is present only when that budget is set; each dollar field only when a rate is also set.
| Field | Type | Meaning |
|---|---|---|
per_run_limit, per_run_remaining | integer | Token ceiling for the current run, and what is left. |
cumulative_limit, cumulative_remaining | integer | Lifetime token ceiling, and what is left. |
per_run_cost_cap, per_run_dollars_remaining | integer (micro-dollars) | Dollar ceiling for the current run, and what is left. |
cumulative_cost_cap, cumulative_dollars_remaining | integer (micro-dollars) | Lifetime dollar ceiling, and what is left. |
estimate_label | string | estimated; present with the dollar fields. |
breach_action | string | Always present: pause, stop or warn; block (Unreleased: after 0.11.0) — settable through config set only on engine-observed agents — the wire fence. |
Remaining values never go below 0.
usage object#
| Field | Type | Present | Meaning |
|---|---|---|---|
cumulative_input_tokens | integer | always | Input tokens over the agent's life, cached tokens included. |
cumulative_output_tokens | integer | always | Output tokens over the agent's life. |
current_run_input_tokens | integer | always | Input tokens in the current run. |
current_run_output_tokens | integer | always | Output tokens in the current run. |
cumulative_cached_tokens | integer | optional | The cached part of cumulative_input_tokens. Absent when older usage without a cached count is in scope. |
current_run_cached_tokens | integer | optional | The cached part of current_run_input_tokens. |
cumulative_dollars | integer (micro-dollars) | optional | Estimated lifetime cost. Present only with a rate. |
current_run_dollars | integer (micro-dollars) | optional | Estimated cost of the current run. Present only with a rate. |
estimate_label | string | optional | estimated; present with the dollar fields. |
Cached tokens are a subset of input tokens. Add input and output for the total; never add cached on top. These totals equal the usage ledger exactly.
ACP fields#
Two optional fields appear only on acp agents. Every other kind leaves them out.
acp_context_usage is the agent's own report of its session context window. It is context usage, not billable usage: Hekma never adds it to the ledger or to budgets.
| Field | Type | Meaning |
|---|---|---|
used | integer, optional | Tokens currently in the context window. |
size | integer, optional | The context window size. |
cost | object, optional | The agent's own cost figure: amount (string) and currency (string). |
usage_gap appears when an acp agent's ledger holds no usage at all, and says which usage sources Hekma tried:
| Field | Type | Meaning |
|---|---|---|
observed | string | configured or not-configured: whether metering.upstream_base_url is set. |
sentinel | string | lines-seen or no-lines-seen: whether the agent printed any KTESIO_USAGE lines on stderr. |
context_usage_reported | boolean | Whether the agent reported its context window. |
notice | string | One sentence a person can read. |
{
"schema_version": 2,
"instance": {
"name": "coder",
"kind": "acp",
"state": "registered",
"restart_count": 0,
"restart_policy": "on-failure",
"budget": null,
"usage": {
"cumulative_input_tokens": 0,
"cumulative_output_tokens": 0,
"current_run_input_tokens": 0,
"current_run_output_tokens": 0,
"cumulative_cached_tokens": 0,
"current_run_cached_tokens": 0
},
"metering_source": "self-reported",
"usage_gap": {
"observed": "not-configured",
"sentinel": "no-lines-seen",
"context_usage_reported": false,
"notice": "no billing-grade usage in the ledger — tiers attempted: observed: not-configured; sentinel: no-lines-seen; no context usage reported (ACP usage_update is context-grain, never billed)"
},
"agent_home": "/Users/you/Library/Application Support/ktesio/agents/coder"
}
}show#
hekma agent show NAME --json prints one fleet entry under instance, with the same fields and rules as a list entry.
{
"schema_version": 2,
"instance": {
"name": "worker",
"kind": "worker",
"state": "running",
"restart_count": 0,
"restart_policy": "on-failure",
"budget": {
"cumulative_limit": 6000,
"cumulative_remaining": 3000,
"breach_action": "pause"
},
"usage": {
"cumulative_input_tokens": 2400,
"cumulative_output_tokens": 600,
"current_run_input_tokens": 1200,
"current_run_output_tokens": 300,
"cumulative_dollars": 14040,
"current_run_dollars": 7020,
"estimate_label": "estimated",
"cumulative_cached_tokens": 800,
"current_run_cached_tokens": 400
},
"metering_source": "self-reported",
"supervision": "detached",
"agent_home": "/Users/you/Library/Application Support/ktesio/agents/worker"
}
}The capability declaration that the human show prints is not in this document.
usage#
With a name, hekma agent usage NAME --json prints the agent's usage object:
{
"schema_version": 2,
"instance": "worker",
"usage": {
"cumulative_input_tokens": 2400,
"cumulative_output_tokens": 600,
"current_run_input_tokens": 1200,
"current_run_output_tokens": 300,
"cumulative_dollars": 14040,
"current_run_dollars": 7020,
"estimate_label": "estimated",
"cumulative_cached_tokens": 800,
"current_run_cached_tokens": 400
}
}Note that instance is a plain string here, the agent's name, while in show it is an object.
Without a name, hekma agent usage --json prints the fleet totals, the same object list --json carries:
{
"schema_version": 2,
"totals": {
"total_input_tokens": 2400,
"total_output_tokens": 600,
"total_dollars": 14040,
"dollars_partial": false,
"unpriced_count": 0,
"estimate_label": "estimated",
"total_cached_tokens": 800
}
}config get#
hekma agent config get NAME --json prints every effective config value; with a key, the entries list holds just that key.
{
"schema_version": 1,
"entries": [
{
"key": "agent.api_key",
"value": "secret:****",
"source": "instance",
"unvalidated": true
},
{
"key": "budget.tokens.cumulative",
"value": "6000",
"source": "instance",
"unvalidated": false
},
{
"key": "model",
"value": "gpt-4o-mini",
"source": "instance",
"unvalidated": false
}
]
}| Field | Type | Meaning |
|---|---|---|
entries[].key | string | The dotted key. Entries are sorted by key. |
entries[].value | string | The value as text, even for numbers. A secret:NAME value reads secret:**** unless you pass --reveal. |
entries[].source | string | The layer the value came from: engine-default, kind-default, instance or invocation-override. |
entries[].unvalidated | boolean | true for agent.* keys, which Hekma does not check. |
With no config set, entries is an empty list. A key with no value is an error (exit code 2) and prints nothing on stdout.
logs#
hekma agent logs NAME --json prints newline-delimited JSON: one complete object per line, in capture order. The shape is the same with --follow, so you can process each line as it arrives. An empty log prints nothing.
{"schema_version":1,"instance":"worker","stream":"agent-out","at":"2026-10-22T19:07:20Z","text":"worker ready, model=gpt-4o-mini"}
{"schema_version":1,"instance":"worker","stream":"agent-out","at":"2026-10-22T19:07:20Z","text":"KTESIO_USAGE {\"sequence\": 0, \"input_tokens\": 1200, \"output_tokens\": 300, \"cached_tokens\": 400}"}
{"schema_version":1,"instance":"worker","stream":"engine","at":"2026-10-22T19:07:20Z","text":"engine: starting -> running"}| Field | Type | Meaning |
|---|---|---|
schema_version | integer | 1. |
instance | string | The agent's name. |
stream | string | agent-out (the agent's stdout), agent-err (its stderr) or engine (a line Hekma wrote). |
at | string | UTC timestamp with whole seconds. Several lines often share one; keep the line order rather than sorting by time. |
text | string | The line, without its trailing newline. |
memory attach#
hekma agent memory attach NAME --kind KIND --json:
{
"schema_version": 1,
"instance": "worker",
"kind": "filesystem",
"guarantee": "managed_dir_byte_durable",
"dir": "/Users/you/Library/Application Support/ktesio/agents/worker/memory",
"declared": true
}| Field | Type | Meaning |
|---|---|---|
instance | string | The agent's name. |
kind | string | filesystem or native. |
guarantee | string | managed_dir_byte_durable for filesystem (the folder exists and its files survive restarts unchanged), home_persistence_only for native (only the Agent Home is kept). |
dir | string | The memory folder's path. For native this is where it would be; nothing is created. |
declared | boolean | true when the backing is filesystem and the agent's adapter maps the memory.dir key, so the agent will receive the path. Always false for native. |
A native attach reads "kind": "native", "guarantee": "home_persistence_only" and "declared": false.
memory detach#
hekma agent memory detach NAME --json confirms the detach and nothing more; the folder and its files stay on disk.
{
"schema_version": 1,
"instance": "worker"
}hekma run#
Unreleased: after 0.11.0.
hekma runis on Hekma's main branch and ships in the next release.
hekma run open, close and show with --json print one Run (close with --selector or --dry-run prints the results document instead). This is a child Run after close:
{
"schema_version": 1,
"run": {
"run_id": "run_01M76G5X0YP30AXB9BXRA00GPF",
"control_depth": "announced",
"wire_path": false,
"status": "ended",
"anomalies": [],
"parent_run_id": "run_01M76G5WZWBJ6WQMQP5EVHM6A3",
"instance": "worker",
"process_owner": false,
"end_cause": "closed",
"created_at": "2026-11-11T23:48:05Z",
"updated_at": "2026-11-11T23:48:05Z",
"ended_at": "2026-11-11T23:48:05Z",
"labels": [
{
"key": "task",
"value": "review",
"source": "caller"
}
],
"limits": {
"token_per_run": 20000,
"breach_action": "warn"
},
"policy": {
"tokens": {
"per_run": 20000,
"cumulative": null
},
"dollars": {
"per_run": null,
"cumulative": null
},
"action": "warn",
"effective_action": "warn",
"scent_check": "off",
"rate": null,
"sources": {
"tokens_per_run": "run",
"tokens_cumulative": "unset",
"dollars_per_run": "unset",
"dollars_cumulative": "unset",
"breach_action": "run",
"scent_check": "default",
"rate": "unset"
}
},
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"cached_tokens": 0,
"cost_micros": 0,
"estimate": "estimated"
},
"open_children": 0
}
}| Field | Type | Present | Meaning |
|---|---|---|---|
run_id | string | always | run_ and a ULID, so ids sort by creation time. Ids recorded by 0.11.0 (run-…) stay valid. |
control_depth | string | always | The Control Depth: supervised for an agent's own Run, announced for a child Run inside it. |
wire_path | boolean | always | Whether the Run's model calls pass through Hekma's metering listener. A supervised Run with false is shown as supervised (no wire). |
status | string | always | The Run Status: active, held or ended. |
anomalies | array of strings | always | The Run's Anomalies, such as failed or breach. |
parent_run_id | string | optional | The parent Run, for a child Run. |
instance | string | optional | The agent the Run belongs to. |
process_owner | boolean | always | true for the Run that owns the agent's process; such a Run is ended with hekma agent stop, not close. |
end_cause | string | optional | Why the Run ended, once it has, for example closed. |
created_at, updated_at, ended_at | string | ended_at optional | UTC timestamps. |
labels | array | always | Each label's key, value and source (bound or caller); a bound label also has origin, config or label-verb. |
limits | object | always | The Run's own ceilings, such as token_per_run and their breach_action; empty when it has none. |
policy | object | always | The Run's resolved limits, after the Run's own limits, the agent's configuration and every matching Policy: the tokens and dollars ceilings (per_run, cumulative; null when unset), the action and the effective_action after the depth fallback, scent_check, the rate, and sources, which says where each one comes from (see hekma budget). |
usage | object | always | Tokens of the Run and its children, and cost_micros with its estimate label. |
open_children | integer | always | How many child Runs are open. |
hekma label#
Unreleased: after 0.11.0.
hekma labelis on Hekma's main branch and ships in the next release.
hekma label set and remove with --json print one result per Run the target or Selector matched:
{
"schema_version": 1,
"verb": "label",
"dry_run": false,
"matched": 1,
"results": [
{
"run_id": "run_01M76G2GZDTHGJV3X7EP61Y78C",
"outcome": "labeled",
"labels": [
{
"key": "env",
"value": "prod",
"source": "bound",
"origin": "label-verb"
},
{
"key": "team",
"value": "payments",
"source": "bound",
"origin": "config"
},
{
"key": "tier",
"value": "gold",
"source": "bound",
"origin": "label-verb"
}
],
"prior_labels": [
{
"key": "env",
"value": "prod",
"source": "bound",
"origin": "label-verb"
},
{
"key": "team",
"value": "payments",
"source": "bound",
"origin": "config"
}
]
}
]
}| Field | Type | Meaning |
|---|---|---|
verb | string | Always label here. Every set-taking verb prints this same document and names itself (below). |
dry_run | boolean | true for --dry-run: nothing was written. |
matched | integer | How many Runs the target or Selector matched. |
results[].run_id | string | The Run. |
results[].outcome | string | labeled, unchanged, would-label (with --dry-run) or refused. |
results[].labels, results[].prior_labels | array | The Run's labels after the change (or as planned) and before, in the shape of a Run's labels. Absent on a refusal. |
results[].error | object | On a refusal only: code and message. |
A refusal carries a stable code, for example:
{
"run_id": "run_01M76G5WZWBJ6WQMQP5EVHM6A3",
"outcome": "refused",
"error": {
"code": "label-from-config",
"message": "label `team` on Run `run_01M76G5WZWBJ6WQMQP5EVHM6A3` comes from the configuration key `labels.team` of agent `worker`, so it cannot be removed from the Run — change it with `hekma agent config set worker labels.team <value>`, or override it on the Run with `hekma label set run_01M76G5WZWBJ6WQMQP5EVHM6A3 team=<value>`"
}
}The label refusals are label-from-config (the label comes from configuration), label-not-bound (removing a caller label, one the Run's Caller set when it opened the Run) and run-ended (the Run has ended). label-bound, a caller label on a key that is already bound, is refused when a child Run is opened, not here. The command's exit code is the first failure's; see hekma label.
hekma ps#
Unreleased: after 0.11.0.
hekma psis on Hekma's main branch and ships in the next release.
hekma ps --json prints one document, the same one GET /v0/runs serves (see the Control API):
{"schema_version": 1, "view", "selector", "items", "next_cursor", "counts"}| Field | Type | Meaning |
|---|---|---|
view | string | exceptions (the default) or all. |
selector | string | The Selector the listing was filtered by, if any. |
items | array | One object per listed Run, newest first. |
next_cursor | string | The cursor for the next page, or null exactly when the read is exhausted. A final page that is exactly full carries none. |
counts | object | listed (what the active view matches) and healthy_open (open Runs with nothing to report). |
Each item flattens the Run's fields (run_id, control_depth, wire_path, status, anomalies, instance, timestamps, as in hekma run) and adds:
| Field | Meaning |
|---|---|
labels | Each label with its source and, for bound labels, its origin. |
usage | The Run's subtree usage. |
cumulative_usage | The agent's cumulative usage, on process-owning rows only: a shared pot is not a per-Run figure. |
latched | The latched breaches, as [{dimension, scope, action}]. |
budget | The headroom against the Run's resolved limits: the same field names as a budget object, plus the names of the Policies that supply them (policies), each limit's source (sources) and the effective_action after the depth fallback. Dollar figures appear only where a Rate prices them; an unpriced cap shows the unpriced-model Anomaly instead. |
kept_on_pause | Present where the breach-default upgrade holds the agent on pause. |
Results of the lifecycle verbs#
Unreleased: after 0.11.0. On Hekma's main branch and shipping in the next release.
hekma agent stop, pause, resume and drain print the same results document as hekma label with --json, for one agent or Run as for a Selector's set. So does hekma run close with --selector or --dry-run; closing one Run by id prints the Run.
{"schema_version": 1, "verb", "dry_run", "matched", "results": [{"run_id", "outcome", "instance", "error"}]}verb names the command (stop, pause, resume, drain, close). Each result's outcome is the verb's past tense (stopped, paused, resumed, drained, closed), would-stop and its kin under --dry-run, or refused with error (code and message). instance is the agent's Fleet row after the act; a close result carries the closed Run as run instead, a drain result adds completed and waited_ms, and a --dry-run result names the agent as agent. The exit code is the first failure's class, with the number of failures in its message; see Selectors on the lifecycle verbs.
hekma budget#
Unreleased: after 0.11.0.
hekma budgetis on Hekma's main branch and ships in the next release.
hekma budget set --json prints the results document with verb budget. Each Run's result carries its outcome (raised, lowered, cleared, set, unchanged or would-set), the Run's own limits before and after, the resolved limits with their sources, what the change fired or re-armed, run_scoped: true and a note saying the limit ends with the Run. A source is the string run, instance, default or unset, the object {"policy": "<name>"} for a Policy, or caller where a Caller's tighter limit applies. The text output writes a Policy source as policy:<name>.
hekma budget show --json prints, per Run, each ceiling with its source, usage and headroom, the Breach Action, the latched breaches and the limits set on the Run itself. With --selector or with no target it lists Runs as hekma ps --all does and pages with --limit and --cursor: the document then has next_cursor.
hekma run keys and revoke-keys#
Unreleased: after 0.11.0. Run Keys are on Hekma's main branch and ship in the next release.
hekma run keys RUN --json lists a Run's credentials by token id, never by value. This is a child Run's pair after hekma run revoke-keys:
{
"schema_version": 1,
"run_id": "run_01M7TPDWV2TP4XZRJ4M4BR3X4S",
"keys": [
{
"token_id": "802e4f6cbe1f",
"class": "run-key",
"state": "revoked",
"issued_at": "2026-11-19T20:02:07Z",
"revoked_at": "2026-11-19T20:02:07Z",
"revoke_cause": "operator"
},
{
"token_id": "04c7eb8a1e78",
"class": "refresh",
"state": "revoked",
"issued_at": "2026-11-19T20:02:07Z",
"revoked_at": "2026-11-19T20:02:07Z",
"revoke_cause": "operator"
}
]
}An active key has no revoked_at or revoke_cause, and a supervised agent's key also carries its launch_generation. hekma run revoke-keys RUN --json prints what it revoked:
{
"cascade": true,
"reuse_cleared": false,
"revoked": [
{
"cascaded": false,
"class": "run-key",
"run_id": "run_01M7TPDWV2TP4XZRJ4M4BR3X4S",
"token_id": "802e4f6cbe1f"
},
{
"cascaded": false,
"class": "refresh",
"run_id": "run_01M7TPDWV2TP4XZRJ4M4BR3X4S",
"token_id": "04c7eb8a1e78"
}
],
"run_id": "run_01M7TPDWV2TP4XZRJ4M4BR3X4S",
"schema_version": 1
}cascaded is true for a credential issued under the Run's own, such as a child Run's key, and reuse_cleared says whether the credential-reuse Anomaly was cleared. hekma run open --print-key --json adds a credentials object beside run, with run_key, refresh_credential, token_id and refresh_token_id; it is the only document that ever carries a key.
Engine events#
A program that embeds the engine can subscribe to events. Each event is one of three payloads wrapped with a kind tag; the payload carries its own schema_version (1 for all three). The CLI does not print events, but it writes the same transition and breach records, without the kind tag, as JSON Lines to logs/instance.log and logs/breaches.log in the Agent Home. On Hekma's main branch (Unreleased: after 0.11.0) those records live in the state database, and the two files are still written after each commit as copies. A fourth kind, run, reports changes to Runs (below). Events, resync and diagnostics covers subscribing and catching up after a gap.
transition#
Sent after every lifecycle change. This one is an agent paused by a token budget:
{
"kind": "transition",
"schema_version": 1,
"instance": "spender",
"prior_state": "running",
"new_state": "paused",
"cause": {
"kind": "budget-exceeded",
"scope": "cumulative",
"dimension": "tokens",
"limit": 3000,
"observed": 3600
},
"at": "2026-10-22T19:11:09Z"
}| Field | Type | Meaning |
|---|---|---|
instance | string | The agent's name. |
prior_state, new_state | string | The states before and after. |
cause | object | Why it changed, tagged by cause.kind (below). |
at | string | UTC timestamp. |
cause.kind | Extra fields | When |
|---|---|---|
command | command (for example "start") | An operator command. |
adapter-ready | none | The process is up after a start. |
launch-error | detail | The launch failed. |
stop-graceful | none | The process exited within the stop window. |
stop-forced | detail | The process was killed after the window. |
pause-best-effort, resume-best-effort | detail | A pause or resume on a best-effort declaration, or with no process held. |
detached-resumed | detail | Hekma woke an operator-paused detached agent as the command exited. |
crashed | detail | The process exited on its own, or was gone when a command looked for it. |
restarted | count, waited_ms | The restart policy started it again. |
budget-exceeded | scope, dimension, limit, observed; with a dollar budget also dollar_limit, dollar_observed, estimate_label | A budget breach paused or stopped it. |
readiness-timeout (Unreleased: after 0.11.0) | probe, waited_ms | The declared readiness probe never passed; the agent is failed and is not restarted. |
unresponsive (Unreleased: after 0.11.0) | check, failing_for_ms; optional detail | The declared liveness check failed for its whole window. |
restart-requested (Unreleased: after 0.11.0) | code; optional detail | The agent exited with a code its adapter declares as a relaunch request. |
clean-exit (Unreleased: after 0.11.0) | code | The agent exited with a code its adapter declares as a clean finish; it is stopped. |
pause-cooperative, resume-cooperative (Unreleased: after 0.11.0) | command | A declared pause or resume command ran. |
drain-stopped (Unreleased: after 0.11.0) | completed, waited_ms | drain stopped the agent; completed is false when the wait ran out or the agent ended on its own. |
New cause kinds may be added within version 1; handle unknown ones. A program built against an older hekma-engine rejects a cause kind it does not know, so read events from a newer Hekma with a parser that accepts unknown kinds.
budget_breach#
Sent once per budget per run when a budget is crossed, whatever the breach action:
{
"kind": "budget_breach",
"schema_version": 1,
"instance": "spender",
"run_id": "run-1792696267061924000-0",
"scope": "cumulative",
"dimension": "tokens",
"limit": 3000,
"observed": 3600,
"action": "pause",
"metering_source": "self-reported",
"at": "2026-10-22T19:11:09Z"
}| Field | Type | Present | Meaning |
|---|---|---|---|
run_id | string | always | The run the breach happened in. |
scope | string | always | per-run or cumulative. |
dimension | string | always | tokens or dollars. |
limit, observed | integer | always | The ceiling and the value that crossed it, in tokens, or in micro-dollars for a dollar breach. |
dollar_limit, dollar_observed | integer (micro-dollars) | dollar breaches | The same values, as money. |
estimate_label | string | dollar breaches | estimated. |
action | string | always | The breach action taken: pause, stop or warn; block (Unreleased: after 0.11.0) — the wire fence. |
metering_source | string | always | Where the usage came from. |
usage_update#
Sent each time a usage event is written to the ledger. A replayed event (same run and sequence) is not written again and sends nothing.
{
"kind": "usage_update",
"schema_version": 1,
"event": {
"instance": "spender",
"run_id": "run-1792696267061924000-0",
"input_tokens": 1000,
"output_tokens": 200,
"cached_tokens": 100,
"metering_source": "self-reported",
"sequence": 2,
"occurred_at": "2026-10-22T19:11:09Z"
}
}| Field | Type | Meaning |
|---|---|---|
event.instance | string | The agent's name. |
event.run_id | string | The run the usage belongs to. |
event.input_tokens, event.output_tokens | integer | Tokens in this event; input includes cached. |
event.cached_tokens | integer or null | The cached part of the input. null only for usage recorded before Hekma tracked cached tokens. |
event.metering_source | string | self-reported or engine-observed. |
event.sequence | integer | The per-run number used to drop replays. Self-reporting agents supply it; Hekma assigns it for observed usage. |
event.occurred_at | string | UTC timestamp. |
This example was built from a usage row the v0.11.0 binary wrote to its ledger during the same run as the breach above; the field names and order are those of the engine's event type.
run#
Unreleased: after 0.11.0. Run events are on Hekma's main branch and ship in the next release.
Sent when a Run is created, ends, or changes its depth, status, Anomalies or labels, right after the event that caused it: a breach is followed by its Run's breach Anomaly, and a lifecycle transition by its Run's status change. The payload's schema_version is 1.
| Field | Type | Meaning |
|---|---|---|
change | string | created, depth-changed, status-changed, anomalies-changed, labels-changed, limits-changed (Unreleased: after 0.11.0, on main) or ended. |
run_id, parent_run_id, instance | string | The Run, its parent (child Runs only) and its agent (when it has one). |
control_depth, wire_path, status, anomalies, labels | The Run after the change, as in hekma run --json. | |
prior_status, prior_control_depth, prior_wire_path, prior_labels | Optional: the value before, on the change that moved it. | |
limits, prior_limits | Optional: on limits-changed, the Run's own limits after and before. The event schema stays 1. | |
cause | string | Optional: why it changed; on labels-changed, label-verb or config; on limits-changed, the actor that set the limits. |
policies | array of strings | Optional: the names of the Policies that supply the Run's limits. |
limits_layer | string | Optional: on limits-changed, which layer of the Run's limits changed, run (the Operator's or a Host's) or caller (a Run Key's). |
at | string | UTC timestamp. |
policy and breach_default_upgraded#
Unreleased: after 0.11.0. On Hekma's main branch and shipping in the next release.
The bus, the SSE stream and the export carry two more event kinds (and credential, below). policy reports a Policy created, changed or deleted: its payload names which under change, as the run event does, with the matched and fallback counts. breach_default_upgraded is recorded once, when the first open of an upgraded state directory keeps agents on pause: its instances lists each such agent by name, with config_written saying whether pause was written into its configuration. The OTLP v1 export ignores both, and every run event.
credential#
Unreleased: after 0.11.0. On Hekma's main branch and shipping in the next release.
Sent when a Run Key or refresh credential is issued, rotated by a refresh, revoked, or presented a second time. It names the credential by token id, never by value. These two are a child Run's key being issued and then revoked through the Control API's revoke-keys route, which is what hekma run revoke-keys calls:
{"kind":"credential","schema_version":1,"change":"issued","class":"run-key","token_id":"9dfac718f809","run_id":"run_01M7TPEB6XE5WDBTE21QRNBVJH","issued_by":"operator","at":"2026-11-19T20:02:22Z"}
{"kind":"credential","schema_version":1,"change":"revoked","class":"run-key","token_id":"9dfac718f809","run_id":"run_01M7TPEB6XE5WDBTE21QRNBVJH","cause":"operator","at":"2026-11-19T20:02:22Z"}| Field | Type | Meaning |
|---|---|---|
change | string | issued, rotated, revoked or reuse-detected. |
class | string | run-key or refresh. |
token_id | string | The credential's 12-character id, as hekma run keys shows it. |
run_id | string | The Run the credential belongs to. |
launch_generation, issued_by, prior_token_id, cause | Optional: the launch a supervised agent's key was issued for, who issued it, the credential a refresh replaced, and why it was revoked. | |
at | string | UTC timestamp. |
Read next#
- Logs, JSON and scripting: putting these documents to work in scripts.
- Exit codes and environment: the other half of the stable interface.
- Events, resync and diagnostics: receiving events from the engine.
- CLI reference: the commands that print these documents.