Skip to main content

AgentTracer

Run agentic tasks against any OpenAI-compatible LLM endpoint (vLLM first) and record structured trajectories, exportable as SFT/RL training datasets.

Built on Stirrup (agent loop, code-exec sandbox, MCP client) — see NOTICE for attribution.

Overview

agent-tracer is a Python framework for collecting agent execution traces for model training and evaluation. It connects an OpenAI-compatible model endpoint to task datasets, tools, and execution environments, then records the model's reasoning, responses, and tool calls as structured events.

  • Run tasks with Docker isolation and configurable MCP tools.
  • Configure models, datasets, and runs through YAML and CLI overrides.
  • Resume interrupted runs by skipping completed samples.
  • Export trajectories as ShareGPT, Hugging Face, or GRPO datasets for supervised fine-tuning (SFT) and reinforcement learning (RL).

How it works

One task, end to end

A task gets its own sandbox, and two things reach into it. code_exec runs inside it. The sandbox-bound MCP servers — filesystem, sqlite, pdf, xlsx, soffice — are separate processes on the host that attach() in for the seconds a call takes, rather than living inside and holding a session open for the life of the agent. Which sandbox is this task's reaches them as AGENT_TRACER_* environment variables: a manifest is read once at startup and cannot name a sandbox that does not exist yet.

The reasoning loop

One model turn emits a sequence of blocks — reasoning, text, tool calls — and the recorder writes each of them as a trajectory event. A turn that calls no tool does not end the run: the loop appends the message and asks the model to continue. Neither that turn nor the request to continue is recorded; the trajectory picks up at the next model turn. It ends on a submit that succeeded, or when max_turns runs out and the trajectory is closed with exit_status: max_turns.

Both diagrams are pages of resource/agent-tracer.drawio, with English SVG renderings beside it for the README.

The trajectory file format the recorder writes — envelope, the twelve event types and their payloads, and how the exporters read them — is specified in docs/trajectory-schema.md. What the framework is required to do, as verifiable requirements mapped to the modules that satisfy them, is docs/requirements.md.

Install

pip install motif-agent-tracer

Python 3.13 or later. The distribution is named motif-agent-tracer; the command is agent-tracer and the import is agent_tracer. To work on the code itself, clone the repository and use uv sync as below.

Quick start

uv sync
cp .env.sample .env      # then fill in the keys it lists
uv run agent-tracer run -f config/example.yaml
uv run agent-tracer export -F sharegpt   # or: -F hf | -F grpo
  • Config: YAML + -c key.path=value overrides. api_key accepts env:VAR references or literals; reasoning_key is required per model (fail-fast).
  • MCP servers: drop a folder with an mcp.json manifest under src/agent_tracer/mcp_servers/ — auto-discovered, default all, narrowed via mcp.include/mcp.exclude. See src/agent_tracer/mcp_servers/README.md.
  • Sandbox: environment.type: docker runs code in an isolated container (no network, memory/pids caps).
  • Web tools: tools.web: true adds stirrup's web_fetch and web_search. web_search needs a Brave Search key — tools.brave_api_key or BRAVE_API_KEY. Without one the run refuses to start, because upstream would otherwise drop web_search and hand the agent web_fetch alone.

After an interrupted run

Containers are torn down, and images a task brought are released, when a run ends normally. A run that is killed does neither, so both are left behind — after a set whose tasks ship their own images, that is easily 100 GB.

docker ps -aq --filter status=exited | xargs -r docker rm
docker images --format '{{.Repository}}:{{.Tag}}' | grep '^swerebenchv2/' | xargs -r docker rmi

Filter rather than pruning: docker system prune -a also removes the sandbox base image and anything else on the host that is not currently running.

Re-running the same command resumes — finished samples are skipped — so cleaning up first costs nothing.

Development

uv run pytest tests/

Contributing

See the contributing guide for setup, issue reporting, the pull request workflow, and required checks, and GOVERNANCE.md for how decisions are made. Questions and ideas go to Discussions. All participants are expected to follow the Code of Conduct.

Use the issue templates to report a bug or request a feature. For vulnerabilities, follow the private reporting instructions in the security policy.

License

The Security workflow generates a CycloneDX SBOM and license policy report for the Python runtime, development dependencies and packaged stdio MCP servers. The guide explains how to download the reports, reproduce the checks and maintain dependency locks. License policy acceptance still requires preserving the notices that apply when distributing dependencies.

Apache License 2.0 — see LICENSE.

src/agent_tracer/models/client.py adapts code from Stirrup and remains under the MIT License; NOTICE carries that attribution.

Plain-answer SFT augmentation

To mix original submit endings with ordinary assistant answers without model calls, see the offline SFT v2 builder.

Official Support channel

motif support discord

Metadata

Release files for motif-agent-tracer 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for motif-agent-tracer 1.0.1
File Size Uploaded Provenance Actions
motif_agent_tracer-1.0.1.tar.gz 424.3 kB With provenance Details for motif_agent_tracer-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for motif-agent-tracer 1.0.1
File Interpreter ABI Platform Actions
motif_agent_tracer-1.0.1-py3-none-any.whl Python 3 none any Details for motif_agent_tracer-1.0.1-py3-none-any.whl

Total release size: 860.2 kB

Release files / motif_agent_tracer-1.0.1.tar.gz

Download URL motif_agent_tracer-1.0.1.tar.gz
Size 424.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2fee40596a7e17285c0851ed993c09f174df31cebf0a9a17692ce6cd37e86154
BLAKE2b-256 checksum
How to use checksums
1d2b83d4caf170c7c5b3bf71dd5d31a5382c0b75cc4d311b69079e850c4c2d09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / motif_agent_tracer-1.0.1-py3-none-any.whl

Download URL motif_agent_tracer-1.0.1-py3-none-any.whl
Size 435.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
566469a8022470f397aba55472c64cf409ce39d5e63bc355926e7bb14c7aa5b9
BLAKE2b-256 checksum
How to use checksums
3087531b0ef0ac5776feed79179449a24be196b0c1b762cc97d8079842a4d309
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for motif-agent-tracer 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for motif_agent_tracer-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page