Observability and diagnostics
Part of the Workflow Modes reference.
Observability
-
Context budget: at session start, when the project instructions pi reads into every turn total more than 16 KiB, one warning names the total and the heaviest file — if that weight is status or history, it belongs in the tracker and the docs. Never a block;
contextBudgetKiB(default 16,0off) widens it or turns it off. The files are pi’s context files (AGENTS.mdand kin, the global one and one per directory from the root to the cwd), found by pi’s ownloadProjectContextFiles, so the names and the walk follow pi. This package’s own.pi/gadhs-guidance.mdis not counted. -
Status line:
🤖 auto · 1 waiting on you · 1 blocked · Explore working · judge $0.012 (7)— the mode,unguardedwhen no judge guards it, the steps waiting on you, the steps blocked and the ones that asked you, how near the denial-loop limit is, the helpers working, the monitors, jobs and unread messages, and the helpers' and the judge’s spend, all in words. Segments vanish when zero; the model is deliberately absent (pi’s footer already shows it truthfully). On pi’s shared bus, so another extension (the pivot client, forwarding to a phone) can show what the footer shows without reaching into the TUI:Event Carries, and when gadhs:status{ modeId, modeLabel, judgeEnabled, ruleCount, stats, text }— the structured input plustext, the line without colour; on every recompute, and once at session start for a late subscriber. Thestatsare a copy.gadhs:mode{ from, to }— the moment a switch records the new mode, before its model and tools apply (the status that follows carries the applied state).gadhs:title{ state, title }—idle | working | attentionand the tab’s text;workingincludes a helper running with no turn (#786); on every change of either and once at start, on every host (a headless box has no tab but may have a phone).gadhs-hub:askno payload — the hub opening (#545); an extension with facts answers at once on
gadhs-hub:facts. pi’s bus is synchronous, so answers are in before the hub draws.gadhs-hub:facts{ source, lines }— one extension’s lines for the hub’s Session tab, in answer to an ask. pi-ssh answers while the session has a remote, pi-remote while it has a link or a trusted device.gadhs-msg:received{ space, channel, record: { id, re?, agent, handle?, subject, tags, sent, preview, cut }, from, ownBox, agent, wake, collect, mine, handle? }— an agent message pi-remote delivered to this session (#566): its headline and the body’s first 4 KB (preview, withcutwhen there is more), and this session’s agent with its subscription’s tags there. pi-modes wakes or collects.gadhs-msg:read{ id }— this session’s agent read a message withmsg_read; its headline stops counting as unread.gadhs:pending{ steps: [{ id, shown, why?, full? }] }— every step still waiting on the human, oldest first (the widget’s order), on every change; an emptystepswhen it empties (#255).whyis the step’s reason, omitted when there is none;fullis the whole action whenshowncut or reflowed it, absent whenshownis all of it (#485). An approved step is not listed: it no longer waits (#369). The queue fills only in a mode that queues (pendingAsks: "queue"); a/pendingaction after a switch still changes it, and is published. -
Inline traces: every non-allow decision renders in the transcript —
policy BLOCKED bash — * | sh(red, will not reconsider) vsjudge BLOCKED read (6.2s) — …(amber, an opinion). Expanded view states the remedy. Allows are not traced (~90 % of verdicts; they would bury the rest). -
node tools/task.mjs verdicts [n] [--why]: the audit trail with the ask and the judge’s reason under each non-allow line. -
The diagnostics stream (below): lifecycle, guard and run records, always on. pi itself has no logging facility.
Diagnostics
pi has no logging facility, and console.error is unusable under the TUI.
The gadhs packages keep one diagnostics stream instead (#484). It is
always on, so a rare bug leaves a trail without anyone having switched
logging on before it happened.
-
Where.
~/.pi/agent/gadhs-diagnostics/log.jsonl, mode 0600 in a 0700 directory. Past 4 MiB it is renamed tolog.jsonl.1and a fresh file begun, so the stream never holds much more than 8 MiB. -
What. One JSON object per line, each stamped
ts,pid,startedandcwd(the review log’s stamp, so the two join by eye), pluseventand its details. The records cover mode and model application, session restore, guard decisions, plan reviews, helpers, dialogs, pi-remote’s link events, and:-
session.start: the pi and pi-modes versions, model, mode, whether there is a UI, and the terminal (term,ssh,mux, andkitty, whether the kitty keyboard protocol is active). -
run.settled: one per agent run, with whether it wasaborted, how long it took (ms), how many assistantturnsit had, and the last one’sstopReasonanderrorMessage. An aborted run’s record also carriesinput, the last 32 things the terminal sent as control sequences only (^[for Escape,^C,[Ifor a focus report; typed text and pastes as a length, never their content), andsinceEscapeMs/sinceCtrlCMs, how long before the run settled an Escape or Ctrl+C arrived. That is what tells an abort you pressed for from one nobody pressed for (#483). -
ask.verdictandtool.ran: where a tool call’s time went (#586).ask.verdict, one per permission decision, carriesgateMs, the gate’s own time from the ask to its verdict (a person’s wait excluded), andsource, the stage that decided: about a millisecond for a rule, the judge’s round trip when it was the judge.tool.ran, one per call that ran, carries the tool’s own execution time (ms, pi’s monotonic measure), whether it failed, andnestedfor a call another tool made. For a remote sessiontool.ranis the transport, apart from the gate. -
request.prefix_changed: a request to the model that did not start by repeating the previous request of the same session (#885). It names the first message that differs (firstChanged, itsrole, and theblockandkindof its first differing block), ortoolsChanged/systemChanged, with both requests' message counts. A request that only adds to the previous one writes nothing. The prompt cache charges for everything after the first difference, so this is where a miss within the cache’s lifetime is looked for: a miss with no such record was the provider’s. Messages are compared as short digests with the cache marks left out; no text is logged, and the previous request is held in memory only until the next. -
remote.abort: a phone’s abort through pi-remote, with the device, written before the abort runs. -
lone_escape.patch,lone_escape.rescuedandmouse_tail.after_escape: the lone-ESC patch and the mouse-report guard (The lone-ESC patch). -
pending.decided: your/pendingapprove or decline, with the step’sid, theaction, itskindand itsshownline (#675). The run an approval lets through is recorded as it happens, in the review log, asgadhs_pending.approved_by_commandwith the sameidand the line asaction. -
escape_confirm.spared,escape_confirm.escape(withcause,timeoutorkey, andwaitedMs) andescape_confirm.dropped: a lone ESC held while streaming, and what it turned out to be (Confirm before Escape acts).
-
-
What never. Typed text, paste bodies, prompts, file contents, tool output. Every string value is also scrubbed for token shapes (the ten that
tool_resultredaction catches) before it is written. -
Reading it.
/diagshows the last 20 records, one per line with the time in UTC, and the file’s path;/diag 100shows 100 (at most 500);/diag pathonly the path. Paste it into a bug report. An agent asked to read the file directly goes through the judge, as for any file outside the workspace. -
Turning it off, or elsewhere.
GADHS_PI_DIAGNOSTICS=offturns it off; any other value is a path to write to instead, which is what tests and a focused bug hunt use. Records logged before a session opens the stream wait in memory (the last 200) and are written when it opens.
OpenTelemetry export
Every permission decision and every helper run can also go to an
OpenTelemetry collector as a span (#272). It is off unless the standard
variable names one: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT (used as given)
or OTEL_EXPORTER_OTLP_ENDPOINT (/v1/traces appended). With neither,
nothing is built, no timer runs and no request leaves pi.
-
What. A decision is
execute_tool <tool>, from the ask to the verdict (a person’s wait excluded). It carries the GenAI conventions'gen_ai.operation.name,gen_ai.tool.nameand, for a helper’s step,gen_ai.agent.name, and our owngadhs.permission.verdict(allow,deny,defer),.source(rule,judge,valve,host,remote,pendingand the rest),.channel(deskorphone, when a person decided),.pattern,.modeand.forwarded. A helper run isinvoke_agent <agent>, from its launch to its end, withgadhs.helper.outcome(doneorfailed),.background,.yieldedand.model. Every span carriessession.idandgadhs.pi_modes.version(the emitting pi-modes' version); the resource’sservice.nameispi, orOTEL_SERVICE_NAME. One trace per pi session. Thegen_ai.*names are at the conventions' Development status, as read on 2026-11-01, and may be renamed upstream. -
What never. A verdict’s reason, a helper’s task or yield, or a header value. The command or path goes out as
gen_ai.tool.call.argumentsonly withOTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENTset (to anything butfalse). -
How. OTLP over HTTP with JSON, batched: 64 spans, or whatever waited 5 s, per POST, with
OTEL_EXPORTER_OTLP_TRACES_HEADERS, elseOTEL_EXPORTER_OTLP_HEADERS(k=v,k2=v2), on each, and a 10 s timeout. At each session’s end what is queued is sent, bounded by the same 10 s. Past 512 queued spans the oldest are dropped and the count rides on the next batch (gadhs.otel.dropped). A failed POST drops its batch, and each distinct failure is oneotel.export_faileddiagnostics line, naming the collector’s host and the status, never a header. Nothing here waits on the collector: a span is a push onto a queue. -
Refused. A protocol other than
http/json(OTEL_EXPORTER_OTLP_PROTOCOLor_TRACES_PROTOCOLset togrpcorhttp/protobuf), or an endpoint that is not an http(s) URL: oneotel.refuseddiagnostics line, and nothing is sent.OTEL_SDK_DISABLED=trueturns it off. -
Beside other OTel extensions. pi-modes registers no OpenTelemetry SDK, so an extension that does (pi-otel, for LLM requests and tokens) runs beside it and can send to the same collector. Join the two on
session.id.
Pins: test/otel-export.test.ts (the wire format of both spans, batching
and the timer, the queue’s bound, a shutdown during a flush, a failure
said once, the environment contract, a collector on a socket, any ask
encoded), and the wiring in test/judge-wiring-callback.test.ts,
test/subagent-wiring.test.ts and test/session-wiring.test.ts.
Review-log events
Everything lands in the permission review log, stamped with mode and session
identity (pid, started, cwd):
| Event | Meaning |
|---|---|
|
A deterministic rule fired ( |
|
Workspace-write stage allowed a path |
|
Workspace-read stage allowed an in-tree |
|
Plain-line stage allowed a bash line whose every command was cleared ( |
|
Operator-configured pattern deferred to human |
|
Plan-draft stage allowed a write to the plans directory ( |
|
One model call made ( |
|
The judge’s credentials could not be resolved ( |
|
Judge verdict ( |
|
Valve capped an allow / deferred under yolo |
|
An unreadable reply about to be asked again for the object alone (#294); |
|
Fail-safe defer ( |
|
Denial-loop guard tripped |
|
Delegation gate decision ( |
|
How a defer was settled beyond the gate ( |
|
The judge read the human’s reply to a queued step ( |
|
The human’s reply ended a loop-guard wait |