Skip to content

Trace anomalies for stall diagnosis: design doc + --json on inspect trace anomalies/http#4524

Open
ransomr wants to merge 6 commits into
UKGovernmentBEIS:mainfrom
meridianlabs-ai:claude/issue-81-20260714-2157
Open

Trace anomalies for stall diagnosis: design doc + --json on inspect trace anomalies/http#4524
ransomr wants to merge 6 commits into
UKGovernmentBEIS:mainfrom
meridianlabs-ai:claude/issue-81-20260714-2157

Conversation

@ransomr

@ransomr ransomr commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

This PR contains:

  • New features
  • Docs
  • Bug fixes

What is the current behavior? (You can also link to an open issue here)

Refs meridianlabs-ai#81 (the issue stays open for the remaining slices).

design/control-channel.md has no coverage of the trace log / inspect trace anomalies content, even though field use showed that telling an LLM agent about trace anomalies — what, if anything, is still running or hung — is a valuable part of the live-eval diagnosis loop. Today inspect trace anomalies and inspect trace http emit only styled Rich tables (the worst case for an agent parser), nothing in inspect ctl joins to the trace subsystem, and anomalies --filter crashes with a RuntimeError when the filter matches an action's completion record but not its start record.

What is the new behavior?

Design doc. Adds a "Trace-log anomalies for stall diagnosis" section to design/control-channel.md (slotted into phase 3, since it needs no server changes), designing:

  • --json on inspect trace anomalies and http (implemented in this PR — see below).
  • inspect ctl process anomalies [PID] [--filter TEXT] [--all] [--json] — a client-side trace-file read (deliberately no HTTP endpoint, so it works against exactly the busy/hung process it exists to diagnose), placed in the process noun group since trace records carry no task/sample identity, with a dead-pid post-mortem fallback to trace-<pid>.log[.gz].
  • Stall-site pointers (long-idle samples, busy-skip notes) that teach the escalation path through the surface itself.
  • Open question: inlining running actions into sample show.

Implementation (first slice). --json on both commands:

  • inspect trace anomalies --json emits a {trace_file, as_of, running, cancelled, errors, timeouts} envelope with per-action rows {action, detail, start_time, duration, error?}; running durations are computed against the envelope's as_of. All four buckets are always populated — --all gates only the human table — so an empty list always means "none occurred", never "not collected".
  • inspect trace http --json emits a {trace_file, as_of, requests} envelope.
  • The anomalies flags (--filter / --all / --json) are defined once as a shared click decorator, so the planned ctl process anomalies mirrors them structurally rather than by convention.
  • The anomaly reconstruction is refactored out of the command into a pure function returning a TraceAnomalies NamedTuple (one reconstruction, two renderings), fixing the misspelled anomolies_* names along the way.
  • Bug fix: anomalies --filter no longer raises when a completion record matches the filter but its start record doesn't (orphan completions are now skipped).

Covered by new CLI tests (tests/cli/test_cli_trace.py) and two CHANGELOG entries.

Still to come (tracked in meridianlabs-ai#81): inspect ctl process anomalies and the stall-site pointers.

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No.

Other information:

None.

🤖 Generated with Claude Code

github-actions Bot and others added 6 commits July 14, 2026 22:01
Designs the affordances requested in issue #81: --json on
`inspect trace anomalies`, an `inspect ctl process anomalies` verb
(client-side trace-file read, deliberately no HTTP endpoint so it
works against a wedged process), and stall-site pointers. Design
only — no implementation.

Co-authored-by: Ransom Richardson <1209015+ransomr@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…otting

- ctl process anomalies mirrors every inspect trace anomalies flag
  (--filter included) via a shared click decorator so they can't drift
- Resolve the dead-pid open question: fall back to trace-<pid>.log or
  .log.gz for post-mortem reads; fix the rotation-vs-gzip conflation
- Slot the work into phase 3 (current phase), --json first; remove the
  post-phase-4 deferral and add the verb to the CLI listings

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
First slice of the trace-log anomalies design (issue #81): both commands
emit `{trace_file, as_of, ...}` envelopes per the agent output contract.
Anomalies buckets (running/cancelled/errors/timeouts) are always present,
rows are `{action, detail, start_time, duration, error?}` with running
durations computed against `as_of`. Flags live in a shared
`anomalies_options` decorator and the reconstruction in a shared
`_trace_anomalies` function, ready for the planned
`inspect ctl process anomalies` to reuse.

Co-authored-by: Ransom Richardson <1209015+ransomr@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…crash

- `inspect trace anomalies --json` now always populates the errors/timeouts
  buckets so an empty list always means "none occurred"; --all gates only
  the human rendering (design doc updated to match)
- fix "anomolies" typo in the shared --all help text and rename the internal
  anomolies_command* functions
- tolerate exit-side action records with no matching enter record (e.g.
  --filter matching only the exit side, or a truncated log) instead of
  crashing with RuntimeError

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants