Skip to content

Troubleshooting

An escalation ladder for "something's wrong with an agent (or the host)". Each step answers a question the previous one can't: is anything actually broken, which unit, what does the unit say, what did the agent do, and — for a multi-host fleet — which host.

Run these as root or as the admin agent. A plain agent gets only its own row from most of these, and credential files are 0600 inside a 0750 home, so even that row is partial.

1. Is anything broken?

agentctl doctor              # every agent on this host, free-text findings + a fix: line each
agentctl doctor assistant    # one agent
agentctl health              # every agent, plus the host-level checks, folded into one exit code

health is not doctor over every agent. It runs the same per-agent sweep and adds host-level checks doctor never performs:

check severity means
agents group missing FAIL the host was never provisioned
unit failed: <unit> FAIL an agentctl-managed unit on this host is in a failed state — agent@*, pi-agent@*, agentctl-*, or a non-ephemeral mcp-*
no fleet config yet WARN the ledger's agents.yaml is absent — this host has no repo yet
secret shard "<name>" wrapped to N/M fleet recipients WARN that shard is decryptable by only some hosts; apply on a host that can already read it re-wraps it fleet-wide

The shard check is read-only — it reads the cleartext recipient metadata and never decrypts — and is a no-op on a single-host fleet, where there is nothing to compare against.

doctor does not emit a fixed set of named states — it prints whatever it found, one line per problem. A clean agent and a broken one look like this:

✓ assistant — healthy
⚠ scribe — 2 issue(s)
  ✗ unit failed/dead
      fix: agentctl logs scribe --since '-10 min' ; agentctl agents restart scribe
  ⚠ crash-looping (NRestarts=52)
      fix: agentctl logs scribe — check for a wedge / 529 / dead creds

Findings are free text — not a fixed taxonomy. Read the fix: line; it's generated for that specific finding, not a generic hint. The ones worth recognising on sight separate causes that want different fixes:

finding what it means
unit not installed the ledger knows this agent and the host does not — apply has not run here, or the agent is pinned to another host
unit failed/<substate> the process is down; read the journal first, or the restart destroys the evidence
unit active but not enabled — will not survive a reboot it is running and looks healthy, and it will not come back after a reboot — hand-started with systemctl start/restart instead of enable --now, and no real apply has run since. agentctl apply <agent> re-enables it, and nothing else will — no timer reconciles a host on its own, so this WARN is the only thing that surfaces the drift
crash-looping (NRestarts=…) it fails faster than it stays up — NRestarts ≥ 50, or SubState auto-restart
<provider> login dead (…) FAIL — a login expired. The fix line names the provider's own verb; for claude it also notes the plugin self-serves a re-login on the owner's next DM
<provider> login <state> WARN — expiring, not yet dead
claude creds absent WARN, claude agents only — login self-serves on the owner's first DM, or agentctl login claude <agent>
activated MCP "x" is missing its required_env secret "K" FAIL — the agent starts, that tool does not
can't verify required_env secret "K" for activated MCP "x" — agentd unreachable WARN — the same check from a caller that cannot reach agentd; this is what a plain agent sees

doctor does not check the shim, so it cannot report a claude agent whose unit is active but whose harness process is gone. The cockpit still lists it and every operation is dropped. agentctl agents status <name> shows it, on the shim: line:

  shim:     DOWN — agent is up but has NO shim: the cockpit lists it and every op is dropped

Exit codes: doctor returns 1 on any FAIL, 2 only when the agent name is syntactically invalid (doctor: invalid name "<x>"), 0 on WARNs or a clean sweep. A valid name that no host runs is 1, through the unit not installed FAIL. health returns 1 on any FAIL and 0 otherwise — WARNs never move it, so it doubles as a watchdog/cron signal.

NEEDS-LOGIN is a different thing: it's a one-time message a pi agent prints at provisioning time when no provider key was set yet, not a doctor diagnostic. It won't reappear in doctor's output later — agentctl creds is where you check login health after the fact.

2. Which unit is it?

The systemd unit name depends on the agent's runtime, and guessing wrong just gets you a confusing "unit not found":

runtime unit
claude agent@<name>.service
pi pi-agent@<name>.service
agentctl agents status <name>          # prints unit state, uptime, NRestarts, mem/cpu, creds, shim
systemctl status agent@<name>          # claude runtime
systemctl status pi-agent@<name>       # pi runtime

If you don't already know the runtime, agentctl agents status <name> (or agents list) tells you without having to guess the unit suffix.

3. Is anything else on the host down?

A failed agent unit is sometimes a symptom, not the cause — the daemon, a socket, or a timer went down first.

agentctl host units             # no args = every FAILED unit on the host (systemctl --failed)

With no pattern it lists every failed unit on the host, agentctl-managed or not — which is what you want here, because the cause is often a unit agentctl does not own. Give it a pattern (agentctl host units 'sami*') to list a specific agent's units instead of just the failed ones; add --failed to force the failed-only reading even with a pattern.

4. Read the actual logs

doctor and host units tell you that something's wrong; the journal tells you why.

agentctl logs <name>                        # an agent's own unit journal, via agentd
agentctl logs <name> --since '-10 min'
agentctl logs <name> -f                     # follow

agentctl unit logs <unit>                   # ANY unit on the host, not just an agent's
agentctl unit logs agentctl-webview-gateway.service -f
agentctl unit logs agentctl-usercron-<agent>-<label>.service --cron-output [--cron-date YYYY-MM-DD]
agentctl unit logs agentctl-usercron-<agent>-<label>.service --cron-artifact state.json|runs.log
agentctl unit status <unit>                 # properties + exact exit fields + cgroup memory.events

agentctl logs is the agent-scoped shortcut (it resolves the runtime-correct unit for you); agentctl unit logs/unit status reach any unit at all — agentd.service, a timer, an mcp-* socket. Both go through agentd, because an agent's uid is in neither adm nor systemd-journal, so a bare journalctl as that user reads the wrong journal (or nothing). For a per-agent script cron, --cron-output reads the newest unit-specific run log (or the newest one for a UTC --cron-date), with a bounded tail and URL/token/key/certificate redaction. --cron-artifact state.json|runs.log reads only one of those exact bundle-local files, with path/ownership checks and byte/line bounds; it does not accept arbitrary paths or workspace-script artifacts. Both are admin-gated reads, and returned content remains sensitive. Older shared daily logs cannot be attributed safely.

5. Look inside the workspace, without shelling in

Sometimes the unit is healthy and the problem is in what the agent wrote (or didn't).

agentctl ws ls <agent> [relpath]     # list a workspace directory, as JSON
agentctl ws cat <agent> <relpath>    # print a workspace text file

ws cat refuses binary files and anything over 2 MiB (exit 3). ws render applies the same gate and refuses the same files, so ws raw is the only route for one of those. Use ws render on a file that passes, to get the markdown/code/CSV rendering the cockpit uses.

6. Cross-host and fleet-wide

On a multi-host fleet, the agent you need to touch may not be on the host you're logged into.

Which mechanism you reach for depends on whether the thing you need is a host or an agent.

agentctl host list                                   # every host in the fleet, agents pinned to each
agentctl host job run <host> <verb> [args…]          # an allowlisted verb, as root on ANOTHER host
agentctl host job status <host> <job-id>
agentctl host job logs <host> <job-id> --follow      # resume after the last cursor
agentctl host job cancel <host> <job-id>             # a request, NOT a rollback

For an operator-only aggregate pressure snapshot, on this host or a named host:

agentctl host pressure --sample 30s --json
agentctl host job run <host> host pressure --sample 30s --json

The optional sample is bounded to 1–60 seconds; without it the command takes one snapshot. Schema version 1 reports UTC time, the OS hostname (the host-job identity), boot ID, online CPUs counted from /proc/stat, memory and swap in bytes, selected /proc/vmstat counters, and CPU/memory/io PSI. The reported cgroup-v2 quota is only /sys/fs/cgroup/cpu.max at this process's visible cgroup mount root, as in host load: limited, unlimited, or unavailable. It is not the worker's own cgroup quota, does not walk ancestors, and may be namespace-relative. It is not necessarily the host's effective capacity. Effective capacity is explicitly unavailable because hidden ancestors and cpusets are not established. Missing or malformed fields are omitted or null and named in errors, never silently zero. Sample rates use elapsed time between vmstat reads: swap counters are pages multiplied by OS page size, while pgpgin/pgpgout are KiB. Missing counters, resets, or a missing/changed boot ID make affected rates null. Both sample errors are retained. No process names, user data, paths supplied by callers, or kernel-log content are collected.

The remote job uses the existing 90-second diagnostic deadline and output limit; job ID, errors, and protocol metadata go to stderr, leaving successful JSON on stdout. Detaching leaves the durable job running. For replay or follow:

agentctl host job logs <host> <job-id> --follow --meta-stderr

The option redirects only journal metadata to stderr and leaves other jobs' default framing unchanged. A replay from --after is only a suffix, not a complete JSON document; concatenate it with the already delivered stdout, or replay from zero (and continue from any reported page cursor) to obtain the whole output.

host job run crosses hosts through the web-view gateway (the target dialled in, so it traverses NAT — no SSH key needed from here). A receipt is persisted on the target before anything runs, so the job survives an agentd restart, a gateway bounce and a reconnect. The command prints the job id, follows automatically, and exits with the verb's real code on the target. Ctrl-C detaches without cancelling — pick it back up with host job logs.

The target may be a hostname or an agent name, which resolves to the host that agent is pinned to. And for three verbs you need no wrapper at all:

agentctl apply <agent>              # these reach the right host on their own
agentctl agents restart <agent>
agentctl login <provider> <agent>

To look inside one agent on another host, just name it — §5's commands above are already cross-host, as are mem, skills, sessions, cron list, creds, doctor and the rest of the read surface. Those run as that agent's own uid on its own host, not as root.

Fleet-wide, when the fix is the same everywhere:

agentctl fleet apply                 # one apply host job per host; a failed host doesn't stop the rest
agentctl fleet upgrade

Read the per-host lines as they print, not only the closing summary — each host's job id is printed before its dispatch, so a host whose stream breaks is still addressable with host job status.

agentctl host gateway-snapshot is a single bounded read of the gateway host's own health — login/gateway unit status, the reverse-proxy container, socket state, gateway ports, upload-spool capacity, agent registration. Reach for it when the symptom is "the cockpit itself looks wrong" rather than one agent.

See Multi-host fleet for joining, renaming and relocating agents across hosts, and host shell or host job run for the interactive alternative to a scripted verb.

7. "A reply takes too long" — where the time actually went

Every hop of a chat turn logs one line to the journal:

TIMING component=<c> phase=<p> ms=<n> turn=<t> msg=<id> [k=v …]

Seven components, in two units:

component What it measures Unit
cockpit the /api/inject handler, the gateway hop, the SSE seed agentctl-webview-gateway.service
gateway the inside of the gateway hop: connection resolve, write wait, ack wait, attachment offer and pull agentctl-webview-gateway.service
upload an attachment's PATCH and staging agentctl-webview-gateway.service
shim the claude shim's record write, stdin write and ack agent@<name>
bridge queue wait, first token, per-tool spans, the turn total pi-agent@<name>
pii the redaction seam, both directions pi-agent@<name>
provider the model HTTP call and its body stream pi-agent@<name>

gateway and shim break down the same window cockpit inject_gateway already reports — they are a finer view of it, not a second number to add.

msg is the message_id the browser minted; it is the join key across every component. turn (t1, t2, …) correlates spans within one agent turn — one turn can answer several messages, so both are needed.

One more component, webview, is logged in the browser's devtools console (the submit and POST spans), keyed on the same message_id. It never leaves the browser.

Read a turn with /usr/share/agentctl/scripts/turn-waterfall.sh:

W=/usr/share/agentctl/scripts/turn-waterfall.sh

# one agent, last 10 minutes
agentctl logs <name> --since '-10 min' | "$W"

# one specific turn (a short prefix of the id is enough)
agentctl logs <name> --since '-1 h' | "$W" 4f1cab12

# the WHOLE path including the cockpit hops — two units, so concatenate them
{ agentctl unit logs agentctl-webview-gateway.service --since '-10 min'
  agentctl logs <name> --since '-10 min'; } | "$W"

It prints the raw spans, then a roll-up in this order: inbound (HTTP) — with the gateway and CLI-verb shares called out — then the gateway sub-spans, the shim's three, the two upload spans, transcript seed, to first token, provider HTTP, model streaming, PII filter, tools, TURN TOTAL and unattributed.

Reading the result:

  • cockpit inject_total is large — the POST itself is slow. inject_gateway is the blocking wait for the agent to acknowledge the turn (5 s budget); inject_verb means the agent was not dialled in and the cockpit spawned the inject CLI verb instead.
  • cockpit sse_seed is large — the chat pane is slow to open, not slow to answer. The seed runs session-stream as a subprocess on the agent host, once per connection.
  • bridge turn_open is large — the message waited behind an in-flight turn.
  • pii redact is large — the redaction seam. detector_ms is the part that left the process; it runs once per model call over the whole transcript, so it grows with session length. msgs= is the history it scanned.
  • provider is most of the turn — it is the model, not the plumbing.
  • bridge tool name=codemode — one span covers the whole sandbox run; nested=N counts the MCP calls the script made inside it.

Timing is on by default. AGENTCTL_TURN_TIMING=0 in the agent's environment silences the three agent-side components (the cockpit ones are unconditional).

Timing lines carry durations, counts, model ids and correlation ids only — never message content, tool arguments or redacted values.