Metadata-Version: 2.5
Name: agent-strace
Version: 0.127.0
Summary: strace for AI agents. Capture and replay every tool call, LLM request, and decision point.
Project-URL: Homepage, https://github.com/Siddhant-K-code/agent-trace
Project-URL: Repository, https://github.com/Siddhant-K-code/agent-trace
Project-URL: Issues, https://github.com/Siddhant-K-code/agent-trace/issues
Project-URL: Documentation, https://github.com/Siddhant-K-code/agent-trace#readme
Author-email: Siddhant Khare <siddhantkhare2694@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,ai,llm,mcp,observability,tool-calls,tracing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.10
Provides-Extra: all-integrations
Requires-Dist: anthropic>=0.20.0; extra == 'all-integrations'
Requires-Dist: crewai>=0.28.0; extra == 'all-integrations'
Requires-Dist: langchain-core>=0.1.0; extra == 'all-integrations'
Requires-Dist: litellm>=1.0.0; extra == 'all-integrations'
Requires-Dist: openai-agents>=0.0.1; extra == 'all-integrations'
Requires-Dist: openai>=1.0.0; extra == 'all-integrations'
Requires-Dist: strands-agents>=0.1.0; extra == 'all-integrations'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.20.0; extra == 'anthropic'
Provides-Extra: crewai
Requires-Dist: crewai>=0.28.0; extra == 'crewai'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.1.0; extra == 'langchain'
Provides-Extra: litellm
Requires-Dist: litellm>=1.0.0; extra == 'litellm'
Provides-Extra: oidc
Requires-Dist: authlib>=1.3.0; extra == 'oidc'
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == 'openai'
Provides-Extra: openai-agents
Requires-Dist: openai-agents>=0.0.1; extra == 'openai-agents'
Provides-Extra: pdf
Requires-Dist: reportlab>=4.0.4; extra == 'pdf'
Provides-Extra: strands
Requires-Dist: strands-agents>=0.1.0; extra == 'strands'
Description-Content-Type: text/markdown

# agent-trace

[![PyPI](https://img.shields.io/pypi/v/agent-strace)](https://pypi.org/project/agent-strace/)
[![Python](https://img.shields.io/pypi/pyversions/agent-strace)](https://pypi.org/project/agent-strace/)
[![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)
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-agent--trace%20eval-blue?logo=github)](https://github.com/marketplace/actions/agent-trace-eval)
[![Open VSX](https://img.shields.io/open-vsx/v/Siddhant-K-code/agent-strace)](https://open-vsx.org/extension/Siddhant-K-code/agent-strace)
[![VS Marketplace](https://img.shields.io/badge/VS%20Marketplace-v0.3.0-blue?logo=visual-studio-code)](https://marketplace.visualstudio.com/items?itemName=Siddhant-K-code.agent-strace)
[![License](https://img.shields.io/github/license/Siddhant-K-code/agent-trace)](LICENSE)
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/agent-strace?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/agent-strace)

**Before you merge an agent's pull request, see what its session did and did not prove.**
<p>Used by Meta, ByteDance, Zama.ai &amp; more<br><br><picture><source media="(prefers-color-scheme: dark)" srcset="assets/logos/meta-dark.svg"><img src="assets/logos/meta.svg" alt="Meta" height="26"></picture>&emsp;&emsp;&emsp;<picture><source media="(prefers-color-scheme: dark)" srcset="assets/logos/bytedance-dark.svg"><img src="assets/logos/bytedance.svg" alt="ByteDance" height="24"></picture>&emsp;&emsp;&emsp;<picture><source media="(prefers-color-scheme: dark)" srcset="assets/logos/zama-dark.svg"><img src="assets/logos/zama.svg" alt="Zama" height="18"></picture></p>

`agent-strace` is for the person reviewing a coding agent's pull request, and for the team lead who wants to know how much agent-written code merged without review. It records the agent's session (prompts, tool calls, file edits, commands, failures) as local files, then reads that evidence for the pull request:

- [`review`](docs/review.md) checks the sessions linked to the branch for rationale, scope, validation, stewardship, and evidence health, and names the evidence behind each finding.
- [`share`](docs/commands.md#share) writes a privacy-minimized HTML evidence packet to hand to the reviewer. `share --dry-run` previews what it would disclose.
- [`cognitive-debt`](docs/cognitive-debt.md) reports how much agent-written code has review evidence, by repository or branch.

All three read captured evidence only. They do not read CI results and do not call an LLM. A gap in the capture is reported as a gap, never guessed.

> [!WARNING]
> Experimental. Do not treat it as a production security boundary without your own threat model, controls, and testing.

## What the reviewer sees

With the GitHub Action, the pull request gets one comment. This is its reviewability table on a [demo pull request](https://github.com/Siddhant-K-code/agent-trace-demo/pull/1), trimmed:

| Finding | Status | Confidence | Evidence |
|---|---|---|---|
| Rationale | present | high | 1 prompt captured in 1 session. |
| Scope | present | medium | All 4 written files were named in a prompt or read in the session. |
| Validation | present | medium | Last run: unittest passed (runner summary in output, not exit code). |
| Stewardship | partial | medium | 1 human turn, 0 after the first tool call, 0 approval decisions. |
| Evidence health | partial | high | Health: 1 partial (copilot). Redaction: on. Linked by: branch. |

Below the table, the comment lists evidence from commit trailers, links the evidence packet and the cognitive debt result, and says whether the check passed. With no linked session, every finding is `inconclusive` at `low` confidence. [How to read the findings](docs/review.md#findings).

## Try it on one pull request

**1. Capture the agent's sessions.**

```bash
uv tool install agent-strace
agent-strace setup --cli copilot   # or claude, codex, gemini, cursor
```

`setup` registers the agent's hooks; for Claude Code it prints them for you to merge into `~/.claude/settings.json`. A [plugin](#agents-and-editors) installs the hooks instead; use one or the other, not both. Restart the agent, do one task on a branch, then check what was recorded:

```bash
agent-strace replay   # the latest session, in order
agent-strace health   # what the capture recorded and what it missed
```

<details>
<summary><a id="install-with-your-coding-agent"></a>Or let your coding agent install it</summary>

Paste this into Claude Code, Copilot CLI, Codex, Gemini CLI, or Cursor; it lists the commands before running them:

```text
Set up agent-strace (https://github.com/Siddhant-K-code/agent-trace) to record this coding agent's sessions as local traces. First, say which agent you are and list the commands you'll run. Never use sudo or hand-edit config files; if a step fails, stop and show me the error. 1. Install or upgrade the CLI: `uv tool install --upgrade agent-strace` (no uv: use pipx). If `agent-strace --version` fails, run `uv tool update-shell` (or `pipx ensurepath`), since the hooks call it from PATH. 2. Connect only this agent's capture path: Claude Code: `claude plugin marketplace add Siddhant-K-code/agent-trace`, then `claude plugin install agent-strace@agent-trace`. Copilot CLI: `copilot plugin marketplace add Siddhant-K-code/agent-trace`, then `copilot plugin install agent-strace@agent-trace`. Codex: `codex plugin marketplace add Siddhant-K-code/agent-trace`, then `codex plugin add agent-strace@agent-trace`. Gemini CLI: `agent-strace setup --cli gemini`. Cursor: `agent-strace setup --cli cursor`. Other agents: stop and point me to the agent-trace docs/setup.md guide. 3. Tell me to restart this agent from a new terminal (in Codex, trust the agent-strace hooks in /hooks), do one task, then run `agent-strace replay` and `agent-strace health`. Traces stay local in .agent-traces/; `agent-strace telemetry disable` turns off anonymous telemetry.
```

</details>

**2. Review the branch.** In CI, add this workflow. It posts the comment above and uploads the evidence packet as a workflow artifact:

```yaml
on: pull_request

permissions:
  contents: read
  pull-requests: write

jobs:
  reviewability:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - uses: Siddhant-K-code/agent-trace@v0.127.0
        with:
          run-eval: "false"
          review: "true"
          cognitive-debt: report
          post-pr-comment: "true"
          github-token: ${{ secrets.GITHUB_TOKEN }}
```

The job reads the traces in `.agent-traces/`, so the branch has to carry them. Without CI, run the check on the branch and paste its output into the pull request body:

```bash
agent-strace review --format markdown
```

A pasted table is the author's claim: the author supplies both the change and the evidence. The Action is the stronger path. See the [pull request evidence workflow](docs/ai-agent-pr-evidence.md) and the [Action reference](docs/review.md#github-action).

![Terminal output of agent-strace replay, health and review on a real GitHub Copilot CLI session that fixes a small bug: replay lists the prompt, tool calls and results; health reports the evidence status and the provider's capture gaps; review reports rationale, scope, validation, stewardship and evidence health for the branch.](assets/demo.svg)

## What review checks

Each finding has a status (`present`, `partial`, `missing`, or `inconclusive`) and a confidence (`low`, `medium`, or `high`):

- **Rationale:** the prompts that asked for the change.
- **Scope:** whether each file the agent wrote was named in a prompt or read in the session.
- **Validation:** test and build runs inside the session. Not CI results.
- **Stewardship:** human turns and approval decisions during the session.
- **Evidence health:** capture gaps, redaction, and how the session was linked to the branch.

A session linked by its git branch, or named on the command line, is a strong link. A session picked by commit time or as the latest one is a [weak link](docs/review.md#how-sessions-are-linked) and can be unrelated. By default the check fails only on `missing` at `medium` confidence or higher; see [Threshold](docs/review.md#threshold).

## Hand evidence to a reviewer

```bash
agent-strace share --dry-run   # category counts only; writes nothing
agent-strace share             # writes session-<id>.html
```

The packet omits prompts, responses, commands, paths, and tool values unless you pass `--include-content`. Do not commit it. With `review: "true"`, the Action builds it as `evidence-packet.html` in the `agent-trace-pr-evidence` artifact. See the [disclosure preview](docs/share-disclosure-preview.md).

## Team view: what merged without review

```bash
agent-strace cognitive-debt --since 30d --by repository
```

It counts agent-written lines with review evidence, such as a GitHub review or a `Reviewed-by:` trailer naming someone else, and keeps reviewed, unreviewed, and unknown lines apart. Unknown never counts as reviewed. In the Action, `cognitive-debt: report` adds the result to the comment, and `check` also fails the step when the result is above the threshold or unknown. It is a workflow metric: it does not measure code quality or rank people. See [cognitive debt](docs/cognitive-debt.md) and [review coverage](docs/cognitive-debt-review-coverage.md).

## Agents and editors

What each agent's hooks expose limits what a review can show. Details: [capture matrix](docs/capture-matrix.md).

- **Claude Code:** prompts, the final response, tool calls, and failed tools. No model name or token usage.
- **OpenAI Codex:** prompts, responses, and tool calls; token usage from Codex 0.164.0. A failed shell command is recorded as a result, not an error.
- **GitHub Copilot CLI:** prompts and tool calls. No response text, model name, or token usage.
- **Copilot cloud agent:** partial and unverified; only when streamed to a [collector](docs/copilot-cloud-agent.md).
- **Gemini CLI and Cursor:** hook setup is in [setup.md](docs/setup.md); neither is in the capture matrix yet.

Plugins install the hooks plus a skill that runs `review` before a pull request opens. The Claude Code and Copilot CLI plugins also add a trace analyst agent:

- Claude Code: `claude plugin marketplace add Siddhant-K-code/agent-trace`, then `claude plugin install agent-strace@agent-trace`. [Guide](docs/claude-code-plugin.md).
- Copilot CLI: `copilot plugin marketplace add Siddhant-K-code/agent-trace`, then `copilot plugin install agent-strace@agent-trace`. [Guide](docs/copilot-plugin.md).
- Codex: `codex plugin marketplace add Siddhant-K-code/agent-trace`, then `codex plugin add agent-strace@agent-trace`, and trust the hooks in `/hooks`. [Guide](docs/codex-plugin.md).

The [MCP server](docs/mcp.md) (`agent-strace mcp`) lets an agent run `review` and read sessions from its own chat. The [VS Code extension](docs/vscode.md) shows evidence review next to the code.

For your own Python agent, the library records tool and LLM calls without hooks:

```python
from agent_trace import trace_tool, start_session, end_session
```

See [setup.md](docs/setup.md) for every capture path, and [platform-install.md](docs/platform-install.md) for machine-wide installs.

## Privacy and telemetry

Traces stay local in `.agent-traces/`, and secret redaction is on by default. See [security](docs/security.md).

Anonymous CLI telemetry is on by default once its [one-time notice](docs/telemetry.md#when-sending-starts) is shown, and is off in CI. It never sends prompts, arguments, paths, repository data, or trace contents. Turn it off with `agent-strace telemetry disable` or `DO_NOT_TRACK=1`. See [telemetry](docs/telemetry.md).

## Labs

`agent-strace --help` shows the core commands: the three above, capture, session lookup, `mcp`, and `telemetry`. The other commands, experimental or for specialist uses, are in [labs](docs/labs.md): run `agent-strace labs` to list them, or `agent-strace --help-all` to list every command. They work as before. Labs includes [OpenTelemetry export](docs/production.md), the [collector server](docs/server.md), [auto-instrumentation](docs/integrations.md), `eval` gates in CI, the live `watch` monitor, and compliance reports. The Action still runs `eval` unless you set `run-eval: "false"`.

## Docs

[Docs index](docs/index.md) · [Review](docs/review.md) · [Command reference](docs/commands.md) · [Setup](docs/setup.md) · [Capture matrix](docs/capture-matrix.md) · [Action inputs](action.yml)

Run the tests with `python -m unittest discover -s tests -v`.

## License

MIT. Use it however you want.

---

<!-- mcp-name: io.github.Siddhant-K-code/agent-trace -->
[Sponsor](https://github.com/sponsors/Siddhant-K-code) · [ADRs](ADRs/) · [Security](SECURITY.md) · [Contributing](CONTRIBUTING.md) · [Share your use case](docs/index.md#share-your-use-case) · [Release guide](docs/releases.md) · [PyPI](https://pypi.org/project/agent-strace/)
