Skip to main content

Local version control for AI agent behavior.

Project description

trace-sdk

Local observability for multi-agent AI systems. Capture every model call, tool call, and decision your agent makes — then diff any two runs to see exactly where behavior changed.

Install

pip install trace-sdk

Quick start

import trace_sdk as trace

@trace.track(agent="planner", config={"model": "gemini-2.5-flash", "prompt_id": "v1"})
def run(request):
    llm   = trace.wrap(your_llm_client)        # intercept model calls
    tools = trace.wrap_tools(your_tools)        # intercept tool calls
    trace.decision("route_selected", dest=city) # log branching logic
    return your_existing_code(llm, tools, request)

Runs are written to .trace/runs/ as JSON. Nothing leaves the machine.

CLI

trace log                 # list captured runs
trace show <run_id>       # pretty-print a run
trace diff <id_a> <id_b>  # behavioral diff between two runs
trace snapshot <run_id>   # per-agent input/output snapshot
trace serve               # launch TraceHub at http://localhost:7000
trace clear               # wipe captured runs

API

@trace.track(agent, config)

Decorator that creates a Run record around the decorated function. Supports sync and async functions.

@trace.track(agent="my_agent", config={"model": "gpt-4o", "prompt_id": "v2"})
async def run(input): ...

trace.wrap(client)

Wraps any LLM client so every call is captured as a model_call step.

llm = trace.wrap(openai_client)

trace.wrap_tools(tools_dict)

Wraps a {name: callable} dict so every invocation is captured as a tool_call step.

tools = trace.wrap_tools({"search": search_fn, "lookup": lookup_fn})

trace.span(name)

Context manager that groups steps under a named sub-agent span.

with trace.span("retrieval_agent"):
    ...

trace.decision(label, **meta)

Records a branching decision with arbitrary metadata.

trace.decision("budget_check", passed=True, limit=500)

trace.load_config(agent)

Reads the config last written by trace diff / trace revert from .trace/config.json.

config = trace.load_config("planner")

TraceHub

trace serve launches a local web dashboard with:

  • Run list with live updates (SSE)
  • Multi-agent column view with per-step detail
  • Run diff — step-aligned comparison with inferred cause

Data & privacy

  • Inputs and outputs are stored as type + length + SHA-256 hash + capped 1 000-character preview — not verbatim.
  • All data is local. No telemetry, no cloud dependency.

Requirements

Python 3.9+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trace_sdk-0.3.8.tar.gz (69.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trace_sdk-0.3.8-py3-none-any.whl (70.2 kB view details)

Uploaded Python 3

File details

Details for the file trace_sdk-0.3.8.tar.gz.

File metadata

  • Download URL: trace_sdk-0.3.8.tar.gz
  • Upload date:
  • Size: 69.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for trace_sdk-0.3.8.tar.gz
Algorithm Hash digest
SHA256 fa9415e3a50e501d67885d735395450f30775b0cf9142dc0562831a3c9c507e0
MD5 380b8524e966cc062f3d9fb7b24654f3
BLAKE2b-256 395366803e03c766385fb9004caceea59a5dcc976823b3d9ec87381a2012a6a7

See more details on using hashes here.

File details

Details for the file trace_sdk-0.3.8-py3-none-any.whl.

File metadata

  • Download URL: trace_sdk-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 70.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for trace_sdk-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d5b6684d3a956d75fe64d4bd3de79a845b85850db36bfc9a6f3f845e92eb454b
MD5 d3bcd06d2d3ca2093a6b3b9324c1637f
BLAKE2b-256 0dab0d24b8edb5131fd8febf17dcf1157b1bd2ea1a88317871eb08d65db0c152

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page