Skip to content

Commit c72f97c

Browse files
docs: update README and bump version to 0.32.0
Add documentation for v0.23–v0.32 features: - watch --rules: rule-based kill switch for runaway sessions - diff --compare: rich side-by-side session comparison - audit-tools: shadow AI detection for repositories - replay --format html: self-contained HTML session viewer - standup: standup report from session trace - freshness: context freshness check before starting a session - oncall: on-call readiness for agent-modified files - curve: personal agent cost-efficiency curve - inflation: token inflation calculator across model versions - a2a-tree: A2A protocol support with cross-agent trace correlation Co-authored-by: Ona <no-reply@ona.com>
1 parent 63c6767 commit c72f97c

2 files changed

Lines changed: 141 additions & 6 deletions

File tree

README.md

Lines changed: 140 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![License](https://img.shields.io/github/license/Siddhant-K-code/agent-trace)](LICENSE)
77
[![CI](https://github.com/Siddhant-K-code/agent-trace/actions/workflows/test.yml/badge.svg)](https://github.com/Siddhant-K-code/agent-trace/actions/workflows/test.yml)
88

9-
`strace` for AI agents. Capture and replay every tool call, prompt, and response from Claude Code, Cursor, or any MCP client.
9+
`strace` for AI agents. Capture and replay every tool call, prompt, and response from Claude Code, Cursor, or any MCP client — then analyse, diff, audit, and share what happened.
1010

1111
![demo](assets/demo.svg)
1212

@@ -115,6 +115,7 @@ agent-strace hook <event> Handle a Claude Code hook event
115115
agent-strace record -- <command> Record an MCP stdio server session
116116
agent-strace record-http <url> [--port N] Record an MCP HTTP/SSE server session
117117
agent-strace replay [session-id] Replay a session (default: latest)
118+
agent-strace replay --format html [-o file] Export a self-contained HTML replay viewer
118119
agent-strace replay --expand-subagents Inline subagent sessions under parent tool_call
119120
agent-strace replay --tree Show session hierarchy without full replay
120121
agent-strace list List all sessions
@@ -126,15 +127,23 @@ agent-strace export <session-id> Export as JSON, CSV, NDJSON, or
126127
agent-strace import <session.jsonl> Import a Claude Code JSONL session log
127128
agent-strace cost [session-id] Estimate token cost for a session
128129
agent-strace diff <session-a> <session-b> Compare two sessions structurally
130+
agent-strace diff --compare <a> <b> Side-by-side table with verdict
129131
agent-strace diff --semantic <a> <b> Compare sessions by outcome, not event order
130132
agent-strace why [session-id] <event-number> Trace the causal chain for an event
131133
agent-strace audit [session-id] [--policy] Check tool calls against a policy file
134+
agent-strace audit-tools [--repo .] [--approved] Scan a repo for shadow AI tool usage
132135
agent-strace policy [--output file] Generate .agent-scope.json from observed traces
133136
agent-strace dashboard [--last N] [--html file] Aggregate stats and trends across sessions
134137
agent-strace annotate <session-id> <offset> Add notes, labels, or bookmarks to events
135138
agent-strace token-budget <session-id> Check token usage against model context limit
136-
agent-strace watch [--max-context-pct N] Watch a live session with per-operation limits
139+
agent-strace watch [--rules file] Watch a live session; kill/pause on rule breach
137140
agent-strace share <session-id> [-o file] Export a self-contained HTML report
141+
agent-strace standup [--session id] Standup report from session trace (no LLM)
142+
agent-strace freshness [--scope glob] Context freshness check vs last session
143+
agent-strace oncall --rotation-start DATE On-call readiness for agent-modified files
144+
agent-strace curve [--export csv] Personal agent cost-efficiency curve
145+
agent-strace inflation [--compare m1,m2] Token inflation calculator across model versions
146+
agent-strace a2a-tree [session-id] Visualise A2A agent call graph
138147
```
139148

140149
### Import existing Claude Code sessions
@@ -669,6 +678,125 @@ Export a structured JSON report for CI assertions:
669678
agent-strace diff SESSION_A SESSION_B --semantic --eval-config eval.json
670679
```
671680

681+
### Rich side-by-side comparison
682+
683+
`--compare` produces a structured table across cost, duration, tool calls, redundant reads, context resets, files modified, and errors — with a deterministic verdict requiring no LLM.
684+
685+
```bash
686+
agent-strace diff SESSION_A SESSION_B --compare
687+
```
688+
689+
New metrics: **redundant reads** (files read more than once), **context resets** (LLM requests separated by >120s), **approach divergence** (first phase pairs where behaviour differs). Useful for asserting on in CI.
690+
691+
### Kill switch for runaway sessions
692+
693+
Add a declarative rules file to `agent-strace watch` to pause, kill, or alert when a session crosses a threshold.
694+
695+
```bash
696+
agent-strace watch --rules .watch-rules.json
697+
agent-strace watch --rules .watch-rules.json --dry-run # evaluate without acting
698+
```
699+
700+
**Rule conditions:** `files_modified`, `cost_usd`, `consecutive_test_failures`, `duration_minutes`, `file_path` (glob).
701+
702+
**Actions:**
703+
- `pause` — SIGSTOP the agent process (resume with SIGCONT)
704+
- `kill` — SIGTERM, then SIGKILL after 5s; auto-generates a postmortem
705+
- `alert` — log only, no interruption
706+
707+
### Shadow AI detection
708+
709+
Scan a repository for AI tool usage signatures — no network calls, no API keys.
710+
711+
```bash
712+
agent-strace audit-tools
713+
agent-strace audit-tools --repo . --since "90 days ago" --approved cursor,copilot
714+
```
715+
716+
Detected tools: Claude Code, Cursor, GitHub Copilot, Codex/ChatGPT, Windsurf, Aider — identified via file signals (`.cursorrules`, `CLAUDE.md`, `.github/copilot-instructions.md`, etc.) and commit message patterns. Flags unapproved tools, unknown LLM API endpoints in `.env` history, and PII patterns in recently committed files.
717+
718+
### HTML session replay viewer
719+
720+
Generate a single-file HTML viewer for any session. No server, no dependencies — open in any browser.
721+
722+
```bash
723+
agent-strace replay --format html
724+
agent-strace replay --format html --output review.html SESSION_ID
725+
```
726+
727+
The viewer includes an animated event timeline, scrubber bar, running cost counter, click-to-expand event detail, color-coded event types, and dark theme. All event data is embedded as a JSON constant — useful for attaching to PR reviews.
728+
729+
### Standup report
730+
731+
Generate a structured standup from a session trace — no LLM call required.
732+
733+
```bash
734+
agent-strace standup
735+
agent-strace standup --session SESSION_ID
736+
```
737+
738+
Report covers: files read and modified, approaches tried (including abandoned ones detected from retry patterns), new dependencies added, TODO/FIXME comments written, large changes and auth/migration patterns to review, and session stats (tool calls, retries, errors).
739+
740+
### Context freshness check
741+
742+
Before handing a task to an agent, check how stale its last view of the codebase is.
743+
744+
```bash
745+
agent-strace freshness
746+
agent-strace freshness --since 2026-04-01 --scope "src/**"
747+
```
748+
749+
Reports files changed since the last session, per-file change type and line count, a freshness score 0–100, and estimated catch-up reading time. Scope is auto-detected from `CLAUDE.md` / `AGENTS.md`, or overridden with `--scope`.
750+
751+
### On-call readiness
752+
753+
Cross-reference agent-modified files against git history to surface cognitive gaps before a rotation.
754+
755+
```bash
756+
agent-strace oncall --rotation-start 2026-04-25
757+
agent-strace oncall --rotation-start 2026-04-25 --scope "src/payments/**"
758+
```
759+
760+
For each file the agent has written in the last N days: how long ago it was modified, lines changed, estimated reading time, and total catch-up time before rotation.
761+
762+
### Cost-efficiency curve
763+
764+
Analyse stored session history to see which task types are worth delegating to an agent.
765+
766+
```bash
767+
agent-strace curve
768+
agent-strace curve --min-sessions 10 --export csv
769+
```
770+
771+
Sessions are classified into 10 task types (unit tests, debugging, refactoring, architecture, etc.) and compared against a community sweet-spot benchmark. Verdict per type: **efficient / over sweet spot / do this yourself**. Potential monthly savings are calculated for types running above 1.5× their sweet spot.
772+
773+
### Token inflation calculator
774+
775+
Measure the tokenizer cost impact of switching model versions before committing to an upgrade — no API calls required.
776+
777+
```bash
778+
agent-strace inflation
779+
agent-strace inflation --compare claude-opus-4-6,claude-opus-4-7 --sessions 30
780+
```
781+
782+
Applies per-model inflation factors to stored session content and breaks down the impact by content type (system prompt, tool definitions, user messages, assistant messages). Projects per-session, daily, and monthly cost delta.
783+
784+
| Model | Factor |
785+
|---|---|
786+
| claude-opus-4-7 | 1.38× (community median: 1.3–1.47×, April 2026) |
787+
| gpt-4o | 1.05× (cl100k_base → o200k_base) |
788+
789+
### A2A protocol support
790+
791+
First-class support for agent-to-agent calls following the Google A2A spec. A2A calls are captured as `TOOL_CALL` events with `event_subtype=a2a_call` — backward-compatible with all existing replay and export tooling.
792+
793+
```bash
794+
agent-strace a2a-tree
795+
agent-strace a2a-tree SESSION_ID --format json
796+
```
797+
798+
Builds the full agent call graph by following `sub_session_id` links and `parent_session_id` back-references. Renders as an ASCII tree or exports as OTLP-compatible spans for Jaeger, Tempo, or any OpenTelemetry backend.
799+
672800
## Production tracing (OTLP export)
673801

674802
Export sessions as OpenTelemetry spans to your existing observability stack. Sessions become traces. Tool calls become spans with duration and inputs. Errors get exception events. Zero new dependencies.
@@ -805,22 +933,29 @@ src/agent_trace/
805933
redact.py # secret redaction (key/value pattern matching)
806934
masking.py # PII masking (email, phone, CC, SSN, ARN)
807935
otlp.py # OTLP/HTTP JSON exporter with GenAI semantic conventions
808-
replay.py # terminal replay and display
936+
replay.py # terminal replay, HTML viewer export
809937
decorator.py # @trace_tool, @trace_llm_call, log_decision
810938
jsonl_import.py # Claude Code JSONL session import
811939
explain.py # session phase detection and plain-English summary
812940
cost.py # token and cost estimation
813941
subagent.py # parent-child session tree, tree replay, stats rollup
814-
diff.py # structural and semantic session comparison
942+
diff.py # structural, semantic, and side-by-side session comparison
815943
why.py # causal chain tracing (backwards event walk)
816944
audit.py # policy-based tool call checking, sensitive file detection
945+
audit_tools.py # shadow AI detection (file signals + commit patterns)
817946
policy.py # generate .agent-scope.json from observed traces
818947
attribution.py # session attribution (user, process ancestry, git context)
819948
dashboard.py # multi-session aggregate view and trend charts
820949
annotate.py # replay annotations (notes, labels, bookmarks)
821950
token_budget.py # token budget tracking and context window early warning
822-
watch.py # live session watcher with per-operation enforcement
951+
watch.py # live session watcher with rule-based kill switch
823952
share.py # self-contained HTML report export
953+
standup.py # standup report from session trace (no LLM)
954+
freshness.py # context freshness check vs last session
955+
oncall.py # on-call readiness for agent-modified files
956+
curve.py # personal agent cost-efficiency curve
957+
inflation.py # token inflation calculator across model versions
958+
a2a.py # A2A protocol support and cross-agent trace correlation
824959
cli.py # CLI entry point
825960
ADRs/ # Architecture Decision Records
826961
```

src/agent_trace/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""agent-trace: strace for AI agents."""
22

3-
__version__ = "0.22.0"
3+
__version__ = "0.32.0"

0 commit comments

Comments
 (0)