Skip to content

Session log v0 ​

A poo session log is an append-only JSONL file: one JSON object per line, in the order the records were produced. This document is the contract a consumer parses.

A session log holds one session. The file is created exclusively, so a run pointed at a log that already exists fails before it sends a request rather than appending a second session to the log.

Where a session's log lives ​

A logged session's log is <dir>/<session_id>.jsonl, and its lock is <dir>/<session_id>.lock. The lock is an exclusive flock, taken when the session is created or loaded and held until the session is closed: a second process is refused while the session is live, and the kernel releases the lock when the holding process dies. The lock file is never deleted, and a lock file with no log beside it is a harmless leftover.

The log is built in a temporary file and renamed into place, so a session that was cut short during its construction is never a session: the temporary file is left behind, and a prune removes it once it is old.

A log that was cut short in the middle of a record is truncated when the session is loaded: the bytes after the last newline are not a record. The load then recovers the session, appending the records that resolve what the session left open: an interrupted result, and the message that carries it, for every tool call without one, a denied permission.answered for every ask without an answer, a run.settled with the reason interrupted for every run that never settled, a job.ended with the outcome interrupted for every job that never ended, a feed.ended with the outcome interrupted for every feed attempt that never ended, an input.delivered for every input whose message names it in input_id but has no input.delivered after it, and an input.dropped with the reason interrupted for every input that never reached the model. The recovery appends only what is missing, so loading a session twice writes nothing twice.

A delivery write that outlives the finalization's wait is a stalled store. The finalization gives a delivery's message and fate their own record budgets before that decision, so a delivery within both budgets is not a stall; the wait remains bounded at two record budgets. When the store does stall, the session breaks, the store failure is the run's reason (or a losing candidate when the run was cancelled), and the input's fate is left to the records that land and to a load, which applies the two rules above.

The finalization and the close each attempt a bounded flush. A store that is still stalled at the bound is reported by the close's ErrCloseStalled; records it has not stored or flushed cannot be recovered, so a load applies the rules above only to what the store holds.

The first record is always session.created, and it carries "format": "poo-session-v0". A consumer that does not recognise the format should stop rather than guess.

Common fields ​

Every record carries these three fields, from the same envelope:

FieldTypeMeaning
recordstringThe record's name, e.g. "tool.call".
seqintegerThe session-monotonic sequence number. The first record is 1.
tsstringThe record's timestamp, RFC 3339 with nanosecond precision, in UTC.

The record's own fields follow the envelope.

A record that someone produced also carries an origin:

FieldTypeMeaning
originstringWho produced the record: "user", "model", "tool", "system", "job", "steer", "interrupt", "follow_up", "compaction", "feed:<name>", "feed:<name>[<field>=<value>]" or "hook:<name>". Absent on the records that no one produced: the session's own header, a run's boundaries, the usage accounting.

Record names ​

NameWritten when
session.createdOnce, first, when the session starts.
run.startedOnce per run, when the run begins.
system_promptOnce per run whose prompt differs from the previous one, with the whole prompt.
messageOnce per message that enters the model's history.
tool.callOnce per tool call the model makes, before it runs. A call a running tool made through the nested seam is recorded here too, with the parent call's handle in parent.
tool.resultOnce per tool call, after it runs.
usageOnce per provider request.
provider.attemptOnce per attempt of a request that failed.
input.queuedOnce per input the session accepts.
input.deliveredOnce per input that reaches the model. It follows the message that delivers the input, and that message names the input in input_id.
input.droppedOnce per input that never reaches the model.
input.heldOnce per round of job results that were held instead of delivered.
job.startedOnce per background job, when it is accepted.
job.endedOnce per background job, when it finishes.
feed.startedOnce per attempt of a feed, when the attempt starts.
feed.endedOnce per attempt of a feed, when the attempt ends.
tool.startedOnce per side-effecting tool call, when the call starts.
run.resumedOnce per run that resumes after a crash.
turn.hookOnce per turn hook, at its start and at its end.
feed.subscribedOnce per feed instance, when it subscribes, and again when a call changes the prompt it screens its records with.
feed.unsubscribedOnce per feed instance, when it unsubscribes.
observer.droppedOnce a second at most, per observer that fell behind.
turn.interruptedOnce per turn an interrupt cut short.
compactionOnce per compaction a compactor produced.
session.models_changedOnce per model switch, between the runs.
model.output_limitOnce per learned output cap, when an endpoint rejects a request's max_tokens.
decisionOnce per decision call, failures included.
permission.askedOnce per permission ask, when the run starts waiting for an answer.
permission.answeredOnce per permission ask, when the answer arrives.
run.settledOnce per run, when the run ends.

The fields of the records grow over time. A consumer must tolerate a field it does not recognise: the fields below are the ones the current core writes, and a later stage adds more.

session.created ​

The first record of a log.

FieldTypeMeaning
formatstringThe record vocabulary. Always "poo-session-v0".
session_idstringThe session's identifier.
modestringThe persistence mode. "logged" for a poo run.
created_atstringRFC 3339, UTC.
working_dirstringThe absolute directory the run works in.
profilestringThe profile the session was built from. Absent when the log was written before the field existed.
rolesobjectThe models the session talked to. See below.
modelobjectThe model the session talks to. See below.
toolsarray of objectsThe tools linked into the session, in call order.
settings_hashstringThe hash of the settings the session was built with. Absent when the log was written before the field existed.
context_limitintegerThe model's context window, in tokens.
tools_modestringHow the run asks for tool calls: "native", "text" or "auto".
reasoning_effortstringThe reasoning_effort the run sends. Absent when it sends none.
buildobjectThe binary that produced the session.

roles holds the session's effective roles:

FieldTypeMeaning
chatobjectThe chat model. Absent when the session had none.
deciderobjectThe decision model. Absent when the session had none.

A role holds model info: its name, its model_id, its endpoint, its api, its ops, its context_limit and its input_limit. The roles are the ones the session ran with, not the ones the current settings would pick: a session loaded by another binary keeps the roles it was made with.

context_limit is the whole window the prompt and the answer share, and input_limit is the largest prompt the endpoint accepts, absent when it takes its whole window. The prompt is bounded by the smaller of the two, so a consumer that measures a prompt reads both.

model holds:

FieldTypeMeaning
idstringThe provider's model identifier.
endpointstringThe endpoint, without credentials. Absent when empty. Renamed from base_url before v1; older logs carry base_url.
max_outputintegerThe model's output-token limit. Absent when unknown.

The endpoint never carries credentials: a URL that names a user and a password is written without its userinfo, so a consumer can read the log without picking up a secret.

Each entry of tools holds:

FieldTypeMeaning
namestringThe tool's identifier.
classstringThe tool's side-effect class: "read_only" or "side_effecting".
backgroundstringThe tool's background mode: "allowed" or "always". Absent when the tool never runs in the background.
idempotentbooleantrue for a "side_effecting" tool whose repeated execution is safe, so a durable session may replay an interrupted call. Absent when the tool does not declare it, and on a log written before the field existed.

build holds:

FieldTypeMeaning
namestringThe binary's name.
versionstringThe binary's version.

run.started ​

FieldTypeMeaning
run_idstringThe run's identifier: a ULID (26 characters of Crockford base32, the time first).
prompt_hashstringThe hex SHA-256 of the prompt text.
started_atstringRFC 3339, UTC.
model_idstringThe model the run talks to.
max_turnsintegerThe turn limit. 0 means the run is unlimited.
tools_modestringHow the run asks for tool calls.
reasoning_effortstringThe reasoning_effort the run sends. Absent when it sends none.
triggerstringWhat started the run: "prompt", "job" or "feed". Absent on a log written before the field existed.
jobsarray of objectsThe job results that started a job run. Absent on a prompt run.
feedsarray of stringsThe feed instances whose inputs started the run, by label (feed.started names the form), in queue order. Absent when no feed's input started the run. A wake that carried both a job's result and a feed's input has the trigger "job" and names the feeds too.

A jobs entry holds:

FieldTypeMeaning
jobstringThe job's identifier, e.g. "j3".
handlestringThe handle of the tool call the job came from, e.g. "r1". The call returned at once with a started outcome, and the job carries that call's handle.
toolstringThe tool the job ran.
textstringThe job's result, as the model reads it.
outcomestringThe job's outcome.

message ​

One message in the model's history. The messages in the log are the same list the model sees: nothing is trimmed, rewritten or summarised.

FieldTypeMeaning
run_idstringThe run the message belongs to.
turnintegerThe turn the message belongs to. 0 for the run's input.
originstringWho produced the message: "user", "model", "tool", "system", "job", "steer", "interrupt", "follow_up", "compaction", "feed:<name>", "feed:<name>[<field>=<value>]" or "hook:<name>".
rolestringThe message's role: "system", "user", "assistant" or "tool".
contentarray of objectsThe message's content blocks.
message_idstringThe message's session-monotonic id, e.g. "m7". Absent when the message has none.
input_idstringThe input delivered by this message. Absent on other messages and older logs.
partialbooleantrue when the message was cut short. Absent when it was not.
causestringWhy the message was cut short: "interrupt" or "provider_error". Absent unless the message is partial.
delivery_noteobjectHow much of the previous reply the user had seen. Absent when the message carries none.
dataobjectThe object a feed's filter wrote beside the message's text: the structured record. Absent unless a filter produced one.

A partial message is the text a cut-short response carried. The assistant's own tool calls in a partial response did not run, and the calls that did not run are recorded as skipped.

delivery_note holds:

FieldTypeMeaning
message_idstringThe assistant message the user had seen part of.
upto_charsintegerHow many characters of that message the user had seen, in code points over its text blocks.
textstringThe rendered note. It is prefixed to the text of the message, followed by a blank line, so the message's content holds it too. Empty when the whole reply was presented.

The note is part of the record, so a replay shows exactly what the user saw. The assistant message itself is never trimmed: the note is the record.

Each content block holds:

FieldTypeMeaning
kindstring"text", "thinking", "tool_call", "tool_result", "image" or "provider".
textstringThe block's text. Absent when empty.
tool_call_idstringThe provider's id for the call. Set on tool_call and tool_result blocks.
namestringThe tool's name. Set on tool_call and tool_result blocks.
argumentsobject or stringA tool_call block's arguments. A JSON object when the model sent valid JSON, and a JSON string holding the raw text when it did not.
is_errorbooleantrue when a tool_result reports a failure. Absent when false.
media_typestringAn attachment block's media type, e.g. "image/png".
datastringAn attachment block's bytes, base64-encoded.
providerobjectThe block's opaque provider companion. Absent when the block has none.

A tool_result block's text is the model-facing text of the result.

A provider block holds:

FieldTypeMeaning
apistringThe wire API the payload belongs to: "chat_completions", "responses" or "anthropic_messages".
typestringThe provider's own name for the payload, e.g. "thinking_signature", "reasoning", "redacted_thinking" or "compaction".
dataanyThe payload, verbatim. The core never interprets it.
requiredbooleantrue when a request cannot be made without the payload. Absent when false.

A provider payload may also ride as the provider field of a thinking block: an Anthropic thinking block is one block on the wire, with a text part and a signature, and poo keeps the two together.

system_prompt ​

The prompt a run rendered, whole. A prompt that differs from the previous one is written; an unchanged one is not. The record is what a restored session takes: the prompt is never rendered from the sections again, so a session that was recorded under another prompt keeps that prompt.

FieldTypeMeaning
run_idstringThe run the prompt belongs to.
variantstringThe variant the prompt rendered in. Absent when it rendered in the default one.
textstringThe whole rendered prompt.
hashstringThe hex SHA-256 of the text.

tool.call ​

A tool call the model made. The record is written before the tool runs, so a log shows what the model asked for even when the tool never finished.

FieldTypeMeaning
run_idstringThe run the call belongs to.
turnintegerThe turn the call belongs to.
handlestringThe call's handle within the turn, e.g. "r1".
toolstringThe tool the model called.
summarystringThe call's human-facing summary, as the tool.call event shows it. A bash call shows the model's description, or the command when it supplied none. Absent when the tool has no summary, and on a log written before the field existed.
argumentsobject or stringThe full arguments, in the same shape as a tool_call content block. The reserved background argument is kept here, even though the core removes it before the tool sees it.
modestringHow the call ran: "sync" in the turn, "job" in the background, or "nested" from inside another call. Absent when the log was written before the field existed.
parentstringThe handle of the call that made this one, for a call a running tool made through the nested seam. The model-made call a script ran under, so a reader can walk the calls one script made. Absent on a call the model made. A nested call that never ran carries the parent and no mode, like any other call that did not run.

A nested call's result is recorded but never becomes a message: the model never saw the call, and the log's contract — the messages in the log are the same list the model sees — keeps holding. It goes back to the tool that made the call instead, after the same before-tool and after-tool hooks a model-made call goes through. The recovery's message rule leaves a call that names a parent out of the history, so a torn tail's nested calls are closed without polluting it either.

A nested call's tool runs under a cap of 1,048,576 characters (poo.NestedOutputCapChars) and not the session's context-relative caps, since its output never reaches the model directly. The tool that made the call reads the whole result. The record's text and the tool.result event's text are held to the session's observation cap, with the rest counted in elided_chars. A cut text ends with a line that says how many more characters went to the calling tool. A hook's replaced original is cut the same way.

The record's structured payload is kept whole, so a tool whose payload holds its output has that output in the log once. Bash's capture always fits under the nested cap. call_cli's stdout and stderr share the cap, so two streams that pass it together are kept as their heads and tails. A tool with no payload, such as read or grep, has only the cut text.

tool.result ​

The outcome of a tool call.

FieldTypeMeaning
run_idstringThe run the result belongs to.
turnintegerThe turn the result belongs to.
handlestringThe call's handle within the turn.
toolstringThe tool that ran.
outcomestring"ok", "error", "denied", "skipped", "cancelled", "interrupted" or "started".
textstringThe model-facing text of the result. A nested call's text is held to the session's observation cap.
elided_charsintegerThe characters a nested call's text left out. Absent when the text is whole.
structuredanyThe tool's side-channel payload. Absent when the tool has none.
originalobjectThe result the tool produced, when a hook replaced it. Absent when no hook replaced it, and absent for a redacted result: the original of a redacted result never reaches the log.
redactedbooleantrue when a hook redacted the result. Absent when it did not.
redacted_bystringThe name of the hook that redacted the result. Absent unless the result was redacted.
hooksarray of objectsThe after-tool hooks' decisions, in the order the hooks ran. Absent when no hook acted. A redacted chain's decisions carry no text.

original holds:

FieldTypeMeaning
textstringThe model-facing text of the result the tool produced.
structuredanyThe tool's side-channel payload. Absent when the tool had none.
is_errorbooleantrue when the result reported a failure. Absent when it did not.

A hooks entry holds:

FieldTypeMeaning
hookstringThe name of the hook that decided.
actionstringWhat the hook did: "keep", "annotate", "replace" or "redact".
textstringThe text the hook added or substituted. Absent when the chain was redacted, and absent when the hook kept the result.

An error outcome is recoverable: the model saw the text and the run continued. A bash call that hit its timeout is an error outcome, because the model has to see that the command failed rather than read its partial output as a finished command.

The started outcome belongs to a background job: the call returned at once and its result arrives later as a message. The denied, skipped, cancelled and interrupted outcomes arrive with the later stages that produce them.

An interrupted outcome is written by a load, never by a live run: the call was cut short, its outcome is unknown, and the model is told so. The result is the model-facing text of the call, and the message that carries it answers the call the model made, so a session that is loaded again asks the model nothing it cannot answer.

input.queued ​

An input the session accepted. The record is written before the call that accepted the input returns, so an accepted input is never lost: its fate is in the records.

FieldTypeMeaning
session_idstringThe session's identifier.
run_idstringThe run the input belongs to. Absent when the session had no run.
input_idstringThe input's identifier: a ULID.
modestringHow the input is delivered: "steer", "interrupt", "follow_up" or "feed".
textstringThe message text.
attachmentsarray of objectsThe files the input carries, each holding modality, media_type and data (base64), so a held input survives a restart with what it carried. Absent when the input carries none. A feed's input carries its image this way.
delivery_noteobjectHow much of the previous reply the user had seen. Absent when the input carries none. Its text is empty when the reply was still streaming at acceptance; the delivered message carries the note rendered at delivery.
dataobjectThe object a feed's filter wrote beside the text, kept so a held input is still a structured record after a restart. Absent unless a filter produced one.
queued_atstringRFC 3339, UTC.

input.delivered ​

An input that reached the model.

The message that delivers the input is the delivery's commit point: once that record is in the log the input has reached the model, and a store that refuses this record does not undo the delivery. The load writes the missing record from the message.

FieldTypeMeaning
session_idstringThe session's identifier.
run_idstringThe run the input was delivered to.
input_idstringThe input's identifier: a ULID.
modestringHow the input was delivered: "steer", "interrupt", "follow_up", "job" for a background job's result, or "feed" for a feed's input.
delivered_atstringRFC 3339, UTC.

input.dropped ​

An input that never reached the model. The reason is the run's final settle reason, or backlog when the feed's backlog cap dropped the input with no run involved.

FieldTypeMeaning
session_idstringThe session's identifier.
run_idstringThe run the input belonged to. Absent when the session had no run.
input_idstringThe input's identifier: a ULID.
modestringHow the input was accepted.
reasonstringWhy the input was dropped.
dropped_atstringRFC 3339, UTC.

input.held ​

Job results that were held instead of delivered. A held result waits for the next run, or for the next load: it is never lost.

FieldTypeMeaning
session_idstringThe session's identifier.
run_idstringThe run the results were held for. Absent when the session had no run.
jobsarray of stringsThe jobs whose results were held, or the feeds whose inputs were held. A feed's entry is its origin, e.g. "feed:inbox".
reasonstringWhy they were held: "on_idle", "wake_limit" or "session_closed".
held_atstringRFC 3339, UTC.

job.started ​

A background job was accepted and started. The record is the acceptance: the job, the call it came from, the run that started it and the tool it runs.

FieldTypeMeaning
session_idstringThe session's identifier.
jobstringThe job's identifier, e.g. "j3".
handlestringThe handle of the tool call the job came from, e.g. "r1". The call returned at once with a "started" outcome.
toolstringThe name of the tool the job runs.
run_idstringThe run that started the job.
started_atstringRFC 3339, UTC.

job.ended ​

A background job finished. The record carries the result the model reads, so a held result survives a crash and a load can deliver it.

FieldTypeMeaning
session_idstringThe session's identifier.
jobstringThe job's identifier, e.g. "j3".
handlestringThe handle of the tool call the job came from.
toolstringThe name of the tool the job ran.
run_idstringThe run that started the job.
outcomestringHow the job ended: "ok", "error", "cancelled" or "interrupted".
causestringWhy the job ended, when something else ended it. Absent unless the cause is "session_closed".
timed_outbooleantrue when the job hit the jobs timeout. Absent when it did not.
fatalbooleantrue when the job failed with a fatal error. A run that receives the result settles tool_fatal. Absent when the job did not.
input_idstringThe id the queued result is delivered under.
textstringThe result the model reads.
attachmentsarray of objectsThe files the result carries, each holding modality, media_type and data (base64), so a held result survives a restart with what it carried. Absent when the result carries none. An earlier build wrote this field as images, holding only media_type and data; a reader takes those as images.
ended_atstringRFC 3339, UTC.

feed.started ​

One attempt of a feed started. A feed is a long-lived source that pushes messages into a session, and the session owns its lifecycle: this record names the attempt.

One instance's attempts never overlap, so the attempt's end is the next feed.ended of the same origin. The origin is the instance's: the feed's own "feed:<name>", or "feed:<name>[<field>=<value>]" for an instance the model started with subscribe_feed.

FieldTypeMeaning
session_idstringThe session's identifier.
feedstringThe feed's name, e.g. "inbox". The origin names the instance.
attemptintegerThe attempt's number within the session and the instance, counting from 1. A loaded session carries on past the numbers the log holds, except an optional feed a subscription started: a restored session holds no optional instances, so a re-subscribed one restarts at attempt 1.
started_atstringRFC 3339, UTC.

feed.ended ​

One attempt of a feed ended. The record is terminal: the attempt is never resumed, and a feed's failure reaches the model through the record and the event, never as a message. A loaded session starts the feed's next attempt under the next number, and a subscription's instance does not start again on its own.

FieldTypeMeaning
session_idstringThe session's identifier.
feedstringThe feed's name.
attemptintegerThe attempt's number within the session.
outcomestringHow the attempt ended: "exited", "failed", "cancelled", "suspended", "session_closed" or "interrupted".
errorstringThe runner's error, when it returned one. Absent when it did not.
restart_in_msintegerHow long the session waits before the next attempt, in whole milliseconds, rounded up. Absent when no restart is scheduled.
ended_atstringRFC 3339, UTC.

exited means the runner returned without an error, and failed means it returned an error or panicked. cancelled means cancel_job stopped the attempt, and session_closed means the session closed under it, or its store broke. interrupted is written by a load, never by a live session: the process stopped during the attempt.

suspended means the feed's filter failed closed: the filter exited nonzero, or wrote something other than a record, so the attempt ended and the feed did not restart, whatever its restart policy says. The error names the fault.

A suspension wakes the session with a feed input of its own, and that input is the report of how the feed went down. Its text is the feed's <feed> element with fault and log attributes beside name: the fault's code, and the path of a file beside the session's own that holds the filter's diagnostics for the attempt. Those diagnostics never ride the input. One suspension is one wake: a further fault that arrives before the report is delivered joins it, and the report counts it.

tool.started ​

A side-effecting tool call started. The record is written before the tool runs, so a durable session sees the effect a crash cut short and may replay it. A read-only call writes none: it changes nothing to replay.

FieldTypeMeaning
run_idstringThe run the call belongs to.
turnintegerThe turn the call belongs to.
handlestringThe call's handle within the turn, e.g. "r1".
call_idstringThe provider's id of the call. The id the call answers, so a reader pairs the start with the call and the result by it.
toolstringThe name of the tool the call names.

run.resumed ​

A run resumed after a crash. The record names the phase the run stopped in, so a reader of the log sees where the run picked up.

FieldTypeMeaning
run_idstringThe run that resumed.
resumption_attemptintegerThe resumption's number, counting from 1.
from_phasestringThe phase the run was in when it stopped: one of the session's states, e.g. "executing".
turnintegerThe turn the run was in when it stopped.

turn.hook ​

A turn hook's start or end. The record is written when the hook starts and when it ends, so a reader of the log sees a hook that a crash cut short: its start has no end, and its end may say it was interrupted.

FieldTypeMeaning
run_idstringThe run the hook belongs to.
turnintegerThe turn the hook runs in.
phasestringThe hook's phase: "after_turn" or "before_settle".
statusstringThe record's status: "started", "ended", or "skipped" for a hook a resumed turn left out because it is not safe to run twice.
hook_indexintegerThe hook's position in the chain, counting from 0.
interruptedbooleantrue when the hook's turn was ended by an interrupt. Set on the hook's records along the interrupted path, so a crash between them keeps the fact on the started record. Absent when it was not.

feed.subscribed ​

A feed instance subscribed. The record is written before the instance runs, so a reader of the log sees the instances a session ran, and a durable session knows which to take on again and the scope and prompt to take them on with. A call that sets a prompt on a running instance writes the record again, so the last one is the subscription the session would repeat.

FieldTypeMeaning
feedstringThe feed's name, e.g. "inbox".
instancestringThe instance's identifier.
scopestringThe instance's scope.
promptstringThe prompt the instance was started with. Absent when the instance was started without one.

feed.unsubscribed ​

A feed instance unsubscribed. The record is written when the instance unsubscribes, so a reader of the log sees the instances a session let go, and a durable session does not take them on again.

FieldTypeMeaning
feedstringThe feed's name, e.g. "inbox".
instancestringThe instance's identifier.

observer.dropped ​

The events an observer missed. The record is written at most once a second per observer, so an observer that fell behind does not flood the log, and it is never delivered to an observer: the diagnostics must not cause more overflow.

FieldTypeMeaning
session_idstringThe session's identifier.
observerstringThe observer that fell behind.
countintegerHow many events the observer missed.
dropped_atstringRFC 3339, UTC.

turn.interrupted ​

A turn an interrupt cut short. The record follows the turn's end: a client reads it as a note on the turn that just closed.

FieldTypeMeaning
session_idstringThe session's identifier.
run_idstringThe run the turn belongs to.
turnintegerThe turn that was interrupted.
input_idsarray of stringsThe inputs whose messages aborted the turn.
interrupted_atstringRFC 3339, UTC.

compaction ​

What a compactor did. The store keeps every original record, and the compaction record says what the model's view was replaced with.

FieldTypeMeaning
run_idstringThe run the compaction belongs to.
strategystringThe strategy that produced the compaction.
compactionobjectThe compaction itself. Its shape is the strategy's form: replace, rewrite, window or end.

usage ​

The token accounting of one provider request. Every request whose stream started gets a record, so a consumer can see the time to the first token even when the endpoint reports no token counts.

FieldTypeMeaning
run_idstringThe run the request belongs to.
turnintegerThe turn the request belongs to.
requestintegerThe request's number within the run, starting at 1. 0 for a request a compaction made, which is not one of the run's turns.
input_tokensintegerThe prompt tokens the endpoint reported. 0 when it reported none.
output_tokensintegerThe completion tokens the endpoint reported. 0 when it reported none.
cache_read_tokensintegerThe prompt tokens served from the provider's cache. Absent when the endpoint does not report it.
ttft_msnumberThe time to the first streamed token, in milliseconds. Measured by the transport, not reported by the endpoint.
originstringAbsent for the run's own turn. compaction when a compaction strategy made the request: a fork that wrote a handoff, or the request that wrote a summary.

The time to the first token is the time to the first token: a non-empty text delta, a thinking delta or a tool call. A chunk that only announces the assistant's role carries no token, so it does not start the clock.

Every provider request whose stream started gets a usage record, including a request whose stream failed part way through: the request still cost tokens, and the record is what a consumer reads to account for it. That includes the requests a compaction made, which carry the compaction's origin so their share of the spend stays its own. A request that failed before the endpoint's stream started has no usage record: no token was spent on it. An endpoint that reports no usage for a request writes no record either: the charge is an estimate, and the log holds what the endpoint said.

provider.attempt ​

One attempt of a provider request that failed. Every attempt is written, the last one included, so a reader of the log sees what the request tried and what each attempt failed with.

FieldTypeMeaning
run_idstringThe run the request belongs to.
turnintegerThe turn the request belongs to.
requestintegerThe request's number within the run, starting at 1. Every attempt record belongs to a turn's request.
attemptintegerThe attempt's number, counting from 1.
errorstringThe failure's message.
kindstringThe provider error kind, when the failure is one. Absent when it is not.
delay_msintegerHow long the transport waited before the next attempt. Absent when no retry followed.

session.models_changed ​

The session switched models. The switch happens between the runs, so a reader of the log knows which model answered which turn.

FieldTypeMeaning
fromstringThe name of the model the session talked to.
tostringThe name of the model the session talks to now.
warningsarray of stringsWhat the caller should know about the switch. Absent when there was nothing to say.
omittedarray of objectsThe provider blocks that are left out of the requests from now on, because they belong to another API. Each object holds api, type and count. Absent when nothing was left out.

The history is never truncated by a switch. A view that does not fit the new window is a warning, and the next run settles context_exhausted.

model.output_limit ​

The session learned a model's output cap from an endpoint that rejected a request whose max_tokens was above it. The session keeps the cap for the requests that follow, and the record says why the value dropped.

FieldTypeMeaning
model_idstringThe identifier of the model the endpoint rejected.
previousintegerThe max_tokens the rejected request asked for.
limitintegerThe max_tokens the endpoint accepts, which the session asks for from now on.

A restored session applies the last record for the model it talks to, unless that model declares its own limit.

decision ​

One decision call. The record is written whatever the outcome was, so a reader of the log sees the calls that could not be answered too.

FieldTypeMeaning
originstringWho asked the questions.
questionsarray of objectsThe questions that were asked. Each holds id, instructions and its kind's own fields.
state_hashstringThe hex SHA-256 of the state payload the questions were asked about.
answersarray of objectsThe answers, when the call succeeded. Absent when it did not.
outcomestring"ok", "deferred" or "invalid".
errorstringThe failure, when the call did not succeed. Absent when it did.
latency_msnumberHow long the call took, in milliseconds.
requestsintegerThe number of wire requests the call made. Absent when the decider did not report one.
atstringRFC 3339, UTC.

permission.asked ​

The ask a run is waiting on. The record is written when the run starts waiting, before any asker has answered.

FieldTypeMeaning
run_idstringThe run that is waiting.
ask_idstringThe ask's identifier. A client answers by it.
toolstringThe name of the tool the model called.
summarystringWhat the call does, as the permission ask shows it. A bash call shows the command, never the model's description. Absent when the tool has no summary.
classstringThe tool's class: "read_only" or "side_effecting". Absent when the tool names none.
reasonstringWhy the call is being asked about: "policy" or "doom_loop". Absent when there is none.
repeat_countobjectThe doom loop's counts, for a doom-loop ask: exact and near. Absent for a policy ask.
deadlinestringThe wall-clock time, RFC 3339 with nanosecond precision, when the ask expires. Absent when the ask has no deadline, and on a log written before the field existed.
fallbackstringThe decision an expired ask resolves to: "allow" or "deny". It is the request's effective fallback, so an ask that names none resolves to "deny". Absent on a log written before the field existed.

permission.answered ​

The answer that resolved an ask. It follows its permission.asked, and it is written whatever the decision was.

FieldTypeMeaning
run_idstringThe run the answer belongs to.
ask_idstringThe ask the answer resolves. Absent for a doom loop's deterministic action, which answers no ask.
decisionstring"allow" or "deny".
answered_bystringWho answered: an asker, the chain's fallback, the policy's own action, or "cancelled" for a run that ended.
provenancestringHow the ask was resolved: "answered", "timeout", "default", "no_asker", "cancelled" or "interrupted".
reasonstringWhy the call was being asked about. Absent when there is none.
messagestringThe note the answer carried for the model. For a policy ask the model saw it in the refused call's tool result; for a doom-loop ask the model sees the doom loop's own refusal text instead, and the record keeps the message. Absent when the answer carried none.

run.settled ​

The end of a run. It is the last record of a run.

FieldTypeMeaning
run_idstringThe run's identifier: a ULID (26 characters of Crockford base32, the time first).
reasonstringThe settle reason. See below.
detailobjectWhy the run settled.
turnsintegerThe number of provider requests the run made.
settled_atstringRFC 3339, UTC.

detail holds:

FieldTypeMeaning
sourcestringThe condition that settled the run.
textstringThe human-readable explanation. Absent when there is none.
losingarray of stringsOther candidates that lost the precedence order. Absent when there were none.
providerobjectSet when a provider request failed.
handoffstringThe note a compactor wrote when it refused to compact. Absent when the run did not settle that way.
undelivered_inputarray of objectsThe accepted inputs that never reached the model. Absent when there were none.
jobs_runningarray of stringsThe jobs that were still running when the run settled. Absent when there were none.
resultanyThe payload of a valid finish call, when the run settled as finished. Absent otherwise.
usageobjectThe run's token accounting: the sum of what its requests reported. Absent when no request reported usage.

A usage entry holds:

FieldTypeMeaning
input_tokensintegerThe prompt tokens the requests reported, in total.
output_tokensintegerThe completion tokens the requests reported, in total.
cache_read_tokensintegerThe prompt tokens the providers served from their caches, in total. Absent when no request reported one.

A undelivered_input entry holds:

FieldTypeMeaning
input_idstringThe input's identifier: a ULID.
modestringHow the input was accepted: "steer", "interrupt" or "follow_up".

provider holds:

FieldTypeMeaning
kindstringThe failure class, e.g. "context_length" or "server".
statusintegerThe HTTP status. Absent when the failure was not a response.
codestringThe provider's own error code. Absent when it sent none. It also holds the kind a failure had before it was reclassified: an interrupted_stream keeps the kind it broke in here.
retry_after_sintegerHow long the endpoint asked the client to wait, in seconds. Absent when it said nothing.

Settle reasons ​

The reasons are a closed set, and the exit code is the process's exit code. The precedence is the order of the table: a run collects a candidate from every source, and the highest-precedence one wins at the commit point.

PrecedenceReasonExitMeaning
1cancelled130The run was cancelled.
2store_error23The session's store failed. The session becomes broken.
3hook_error22An executable hook failed or missed its deadline.
4tool_fatal21A tool failed with an error that means the environment is unusable.
5provider_limit24The provider refused for quota or plan reasons. The session is not broken.
5bprovider_error20A provider request failed and cannot be retried, or the retry budget was spent.
6context_exhausted13The context window is full.
7hook_continue_limit12The BeforeSettle hooks asked for more continuations than the run allows.
8max_turns11The run hit its turn limit.
8bbudget_exhausted14The run hit a token or time budget.
8cinvalid_turns15The model kept producing turns the run could not use: it asked for tool calls and sent none, or its calls did not parse, for as many consecutive turns as the run allows.
9finished0The model called the finish tool with a valid result.
9bstop_requested0A hook or a stop condition asked the run to stop.
10output_truncated10The provider stopped on the output-token limit.
11end_turn0The model stopped on its own.
—interrupted—The run's outcome is unknown: the process stopped while the run was going. It is never produced live; a load writes it for a run that never settled.

provider_limit and provider_error share a precedence level, because a single failed request produces only one of them.

A cancellation and a deadline are the same outcome: the run was stopped before the model finished, and both settle cancelled.

detail.source names the condition. The values the core writes:

SourceMeaning
end_turnThe model stopped on its own.
output_truncated:defaultThe provider stopped on the output-token limit, and the request carried poo's default for the model's context window, because the model declares no max_output. The detail's text names the max_tokens the request carried and the setting that raises it.
output_truncated:modelThe provider stopped on the output-token limit, and the request carried the model's own max_output.
output_truncated:contextThe provider stopped on the output-token limit, and the request carried the room the context window had left, which was under the model's output limit. The detail's text gives the estimated prompt size and the window.
output_truncated:endpointThe provider stopped on the endpoint's own output limit: the request body carried no max_tokens, because the endpoint takes none.
max_turnsThe run hit its turn limit.
max_run_tokensThe run hit its token budget.
max_durationThe run hit its wall-clock budget.
empty_turnsThe model reached the bound on consecutive turns that asked for tool calls and sent none. The detail's text says how many turns. A run that mixed the two kinds of unusable turn is named for its last turn.
unparsed_callsThe model reached the bound on consecutive turns whose tool calls did not parse. The detail's text says how many turns. A run that mixed the two kinds of unusable turn is named for its last turn.
truncated_turnsThe model reached the bound on consecutive turns whose response stopped on the output-token limit before a complete call arrived, with limits.truncation_retries retries already spent. The detail's text says how many turns.
no_output_roomThe computed max_tokens was under 256, so the request was never sent.
prompt_limitThe estimate plus the reserve was over the endpoint's input cap, so the request was never sent.
compaction_failedThe compactor failed when the next request could not go out.
provider:context_lengthThe endpoint reported that the request was too long. It is recognised whatever status the endpoint sent it with, including a 5xx. The run compacts once and sends the request again when it has a compactor, the refused request carried no partial answer, and no interrupt is pending. A handoff strategy forks the refused request, which fails, so the run settles with the refusal. Without those conditions the run settles as before.
provider:<kind>The provider request failed with that kind.
finishThe model called the finish tool with a valid result.
before_settleA BeforeSettle hook stopped the run, or the run asked for more continuations than it allows.
after_turn:<name>An AfterTurn hook stopped the run.
stop_conditionA stop condition matched.
cancel:contextThe run's context was cancelled.
cancel:deadlineThe run's context deadline passed.
cancel:clientThe client cancelled the run.
cancel:closeThe session closed while the run was active.
storeThe session's store refused a record.

Reading a log ​

A consumer reads the file line by line and decodes each line as a JSON object. It keys off record, and it must tolerate fields it does not recognise: a later stage adds records and fields, and a consumer that fails on an unknown field breaks on a newer log.

A log written by an earlier core is still readable. The fields added after the first version are all optional: message_id, input_id, delivery_note and trigger are absent from an older log, and a consumer that needs them must treat an absent field as "the log does not say".

The order of the records is the order of the events. A tool.call is always followed by its tool.result, and a run.started is always followed by a run.settled. One feed instance's attempts never overlap, so a feed.started is followed by its feed.ended before that instance's next feed.started. The core writes the settle record itself, so a run that was cancelled, or whose provider failed, still ends with one. Every record is written under a context of its own, bounded at 5 s, so a cancelled run still records what it did. A usage record the store refuses is dropped rather than ending the run. Only a store that refuses the run's other records stops it before its run.settled.

The tools' observations ​

A tool.result carries the tool's own text in text, and the tool's side-channel payload in structured. The two tools the skeleton ships have these shapes.

The bash tool's payload is the observation the model reads, as JSON:

FieldTypeMeaning
returncodeinteger or nullThe command's exit status. Null when the process was killed, which is the case for a timeout.
timed_outbooleanWhether the command hit its timeout.
outputstringThe output, when it fits under the observation cap.
output_headstringThe head of the output, when it was elided.
output_tailstringThe tail of the output, when it was elided.
elided_charsintegerThe characters dropped from the middle. Absent when the output was not elided.
truncatedbooleanTrue when the output passed the 1 MiB capture and the rest was dropped. Absent otherwise.
hintstringHow to see the elided middle, or the dropped end when truncated is set. Absent when the output was neither elided nor truncated.

The observation cap and elided_chars are counted in characters, not bytes, and a cut never splits a rune. A byte that is not part of a valid character counts as one character. The output is captured up to 1 MiB, and a capture cut that lands in the middle of a character drops the partial one. Bytes the command printed are otherwise kept as they are.

The read tool's payload is the range the model saw. Its text carries a header naming the range, such as [path · lines 1–2000 of 5312], and the body below it. The header says · capped when the output cap ended the read early, and names an empty range when the offset is past the end of the file. A line is truncated at 2000 characters, counted in characters, and a cut never splits a rune. A carriage return at the end of a line is stripped, so a file with CRLF endings reads the same as one with LF endings.

Released under the Apache-2.0 License. Machine-readable index: llms.txt · llms-full.txt