2026-11-27 16:19 UTC

Traccia SDK pairs agent tracing with platform-dependent runtime policy checks

state: expiredheat: mediumuncertainty: mediumrelevance: mediumagent-governance agent-runtime observabilityTraccia

What is this?

Traccia is a Python SDK from the Traccia project, published on PyPI and open-sourced on GitHub under Apache 2.0. Its project documentation describes OpenTelemetry-based tracing, LLM token and cost tracking, evaluations, and integrations with agent frameworks. It also documents runtime policy checks—such as spend caps, model boundaries, and loop caps—through `@govern`; those checks require the Traccia platform, unlike tracing to a self-hosted OTLP backend. The supplied evidence supports runtime blocking and policy enforcement, but does not clearly substantiate the broader claim that calls can be reshaped. A Show HN post on Nov. 10, 2026 drew attention to the project; however, a web result dates the PyPI listing to Feb. 2, 2026, so this evidence does not establish that the SDK was newly released on Nov. 10.

Why it matters

The notable idea is combining agent observability with controls that can intervene during execution, rather than only audit behavior afterward. If the documented policies work reliably in production, teams could set operational limits on agent spending, model choice, and repeated loops while retaining traces and evaluation workflows. That may make deploying agents easier to govern, but enforcement is tied to Traccia’s platform, and the supplied sources provide project documentation rather than independent evidence of adoption or reliability.

Current assessment

The project’s GitHub documentation and PyPI search result support that a Traccia Python SDK is available and presents itself as an OpenTelemetry-based toolkit for tracing, evaluations, governance evidence, and runtime controls. The project says `@govern` checks agent status and applies per-call policies, including spend, model-boundary, and loop-cap controls; its documentation says a deny blocks the provider or tool call. These are first-party capability descriptions, not independently verified performance claims. The ordinary `@observe` tracing path can export to OTLP-compatible backends, while `@govern` requires a Traccia API key and platform endpoint. The evidence does not establish a new release date: the Show HN post is dated Nov. 10, 2026, but the web result reports a PyPI date of Feb. 2, 2026. Nor does it demonstrate adoption, production outcomes, or call reshaping. For tracking, distinguish the SDK’s open-source observability features from its platform-dependent enforcement and confirm release history and implementation details before treating the Show HN post as a launch.

Measured heat

now 0 pts/hpeak 0 pts/hcomments 0/hpeers p19momentum: steady2 platformsage 336h
points/hour across evidence · reading as of 2026-11-24 04:24:13.223466+11:00 · deterministic, not a model opinion

How the heat travelled

11-09 17:22 (minted)⭐ origin echo-reconstructedThe project presents a Python SDK for tracing, evaluating, and enforcing runtime policies on AI agents, with controls including spend caps,
Traccia on github (echo) · attributed from hn.story.50428375 · published time unknown
—
11-09 17:09first on hacker news · published · lag ?Show HN: Traccia – open-sourced AI agent runtime governance
vijaypoudel
—
11-09 17:09amplified on hacker news 👑hn.story.50428375
vijaypoudel
peak 5 · 0 comments · 101% of case engagement
11-09 17:20our radar first saw it · lag ?discovery anchor: hn.story.50428375—

Evidence (2) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hnShow HN: Traccia – open-sourced AI agent runtime governance
Retrieved article excerpt

Open article · Retrieved 2026-11-09T17:21:36.901375+00:00

# Traccia — The Open-Source Agent Control Plane

**AI agents can act. Traccia controls what they're allowed to do.**

Traccia is a production-ready Python SDK for **observing, evaluating, and enforcing policies on AI agents and LLM applications at runtime.**

Built on OpenTelemetry, Traccia provides distributed tracing, token and cost tracking, evaluation, governance evidence, and runtime policy enforcement across AI agents, agentic workflows, and multi-agent systems.

Framework-agnostic and built for **OpenAI Agents, LangGraph, CrewAI, and LLM applications in production.**

[Traccia](https://pypi.org/project/traccia/) is available on PyPI.

## Features

### Runtime Control

- **Runtime Policies**: `@govern` can deny or reshape LLM or tool calls at runtime using policies such as Spend Cap, Model Boundary, and Loop Cap
- **Guardrail Detection**: Passive detection of AI safety controls, provider-native safeguards, and custom guardrails
- **Security Controls**: No secrets in logs and configurable data truncation

### Observability & Tracing

- **Automatic Instrumentation**: Auto-patch OpenAI, Anthropic, Gemini (google-genai), Groq (groq), requests, and HTTP libraries
- **Framework Integrations**: Support for LangChain, CrewAI, and OpenAI Agents SDK
- **LLM-Aware Tracing**: Track tokens, costs, prompts, completions, and latency automatically
- **OpenTelemetry Metrics**: Emit OTEL-compliant metrics for accurate token and cost tracking independent of sampling
- **Decorator-Based Tracing**: Trace any function with the `@observe` decorator
- **Multiple Exporters**: OTLP-compatible export to Grafana Tempo, Jaeger, Zipkin, SigNoz, Console, or File
- **Production-Ready Architecture**: Rate limiting, error handling, configuration validation, and reliable flushing
- **High Performance**: Efficient batching, async support, and low-overhead instrumentation

### Evaluation & Development

- **Offline Evaluation**: `evaluate()` runs a task and scorers over a dataset and saves an experiment you can open, compare, and attach on promote
- **Prompt Management**: `load_prompt` / `prefetch_prompts` with cache, stale-while-revalidate, fallback, and `traccia.prompt.*` span identity
- **Zero-Configuration Setup**: Simple `init()` call with automatic configuration discovery
- **Type-Safe Configuration**: Full Pydantic validation and configuration management

### Governance & Compliance

- **AI Governance and Compliance**: EU AI Act and HIPAA-oriented evidence, transparency records, integrity verification, and PII/PHI redaction helpers

---

## 🚀 Quick Start

### Installation

```
pip install traccia
```

### Basic Usage

```
from traccia import init, observe

# Initialize (auto-loads from traccia.toml if present)
init()

# Trace any function
@observe()
def my_function(x, y):
    return x + y

# That's it! Traces are automatically created and exported
result = my_function(2, 3)
```

### With LLM Calls

```
from traccia import init, observe
from openai import OpenAI

init()  # Auto-patches OpenAI

client = OpenAI()

@observe(as_type="llm")
def generate_text(prompt: str) -> str:
    response = client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": prompt}]
    )
    return response.choices[0].message.content

# Automatically tracks: model, tokens, cost, prompt, completion, latency
text = generate_text("Write a haiku about Python")
```

### Gemini (google-genai)

```
from traccia import init
from google import genai

init()  # Auto-patches google-genai

client = genai.Client()
response = client.interactions.create(
    model="models/gemini-flash-latest",
    input="Write a haiku about Python",
)
```

### Groq (groq)

```
from traccia import init
from groq import Groq

init()  # Auto-patches groq (sync and async clients)

client = Groq()
response = client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[{"role": "user", "content": "Write a haiku about Python"}],
)

# Streaming is traced too: the span stays open until the stream is read, closed, or dropped.
for chunk in client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[{"role": "user", "content": "Write a haiku about Python"}],
    stream=True,
):
    print(chunk.choices[0].delta.content or "", end="")
```

Each call gets an `llm.groq.chat.completions` span and goes through the Spend Cap. Settlement charges Groq's reported usage at Groq's own price (cached prompt tokens at the cached rate); a stream closed or failed partway is charged an estimate of what it produced; a stream dropped without `close()` has its request aborted and is charged its full reservation, as is a `with_streaming_response` call, whose body you read yourself. A call still open at `stop_tracing()` ends its span; when the Spend Cap reserved budget for it, it is also aborted and charged that reservation (unless Groq reported usage), and otherwise it is left running, so a stream another thread is reading keeps working. Groq reports usage only at the end of a stream, so a call without it records its estimated token counts on the span instead (`llm.usage.source` is `estimated`), the same counts an estimate is charged. `with_raw_response` works as before. Calls made to Groq through the OpenAI client (`base_url="https://api.groq.com/openai/v1"`) go through the OpenAI integration instead, so use the `groq` client for Groq.

### Load a versioned prompt

Fetch prompts from your Traccia prompt registry by name and deploy label. Compiling fills `{{variables}}` and stamps the active span with prompt identity.

```
from traccia import init, observe, load_prompt, prefetch_prompts

init(api_key="...", prompt_cache_ttl_s=60)
prefetch_prompts(["support-reply"])  # optional warm-up

@observe(as_type="llm")
def reply(question: str) -> str:
    prompt = load_prompt(
        "support-reply",
        label="production",
        fallback={
            "type": "chat",
            "messages": [{"role": "system", "content": "You are a helpful assistant."}],
        },
    )
    messages = prompt.compile(question=question)
    # pass messages to your LLM client
    return messages[-1]["content"]
```

Requires the [Traccia platform](https://app.traccia.ai): create a workspace API key under **Settings → API Keys**. Tracing and prompt fetch use the same key and default to `https://api.traccia.ai`. Pass an explicit `fallback` so agents can still run if a fetch fails. See [Prompts in the SDK](https://traccia.ai/docs/sdk/prompts).

### Run an experiment

`evaluate()` runs a task and scorers over a dataset. By default the run is saved as an experiment you can open in the app under **Evaluate → Experiments**, compare against other runs, and attach when you promote a prompt. Use the same workspace API key as tracing and `load_prompt`.

```
from traccia import init, evaluate, load_prompt

init(api_key="...")

prompt = load_prompt("support-reply", label="production")

def task(inp):
    messages = prompt.compile(**inp)
    return call_model(messages)

result = evaluate(
    "support-reply-v3",
    data="support-golden",     # platform dataset name or UUID
    task=task,
    scorers=["exact_match"],   # builtins, platform names/ids, or callables
    prompt="support-reply",    # labels the experiment cell with this prompt
)
print(result.summary())
print(result.url)
```

- **Persist is on by default.** Set `persist=False` for a local-only loop (no experiment URL).
- **Inline rows** work as `[{"input": {...}, "expected": "..."}]`. With persist on, Traccia still saves a full experiment (helper datasets named `sdk-eval/...` are hidden on **Evaluate → Datasets** unless you turn on **Show SDK-Created**).
- **Builtins** run in-process: `exact_match`, `contains`, `json_valid`. Mix in platform scorers (LLM-as-judge, Jev Decision, code) by name or UUID. Pass `provider_keys=` for judges (`typesafe` for Jev). A Jev score keeps each question on the experiment.
- **One throwing row does not abort the run.** That cell records `error`; other items still score. Configuration and API failures raise `EvaluateError`.
- If the first task argument is named `row`, `item`, `example`, or `case`, Python passes the full row. Any other name (including `input`) receives only the input dict.

See [Evaluate in the SDK](https://traccia.ai/docs/sdk/evaluate) and the walkthrough [Run Experiments From Code](https://traccia.ai/docs/guides/sdk-evaluate).

### Run evals in CI

`traccia eval` runs a task script, saves an experiment, and writes `summary.json`. The process exit code is the gate: 0 pass, 1 quality miss, 2 bad command or baseline, 3 untrustworthy evidence, 4 the experiment did not save, 5 the summary file was not written. With no pass-rate bar, a green check is **Execution Only**. Add `--min-pass-rate` or `--max-drop` for a **Quality Gate**. `--max-drop 0.05` is five percentage points. `--max-task-cost-increase 0.2` is 20 percent.

The script defines `task` and, for a function in the file, a `scorers` dict passed as `--scorer local:name`. A local scorer cannot pass `--max-drop`. Pass `--prompt` with `--prompt-version` or `--prompt-label` when the experiment should record a prompt version. Platform LLM-judge and Jev scorers read `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GEMINI_API_KEY` or `GOOGLE_API_KEY`, `GROQ_API_KEY`, and `TYPESAFE_API_KEY`, or a JSON object in `TRACCIA_PROVIDER_KEYS`. Those values are not written into the summary. Each Jev question is gated on its own pass rate. Execution Only means no pass-rate gate; cost and latency gates can still apply.

```
traccia eval experiments/support_agent.py \
  --output summary.json \
  --dataset support-golden \
  --scorer exact_match \
  --min-pass-rate 0.9 \
  --baseline-prompt support-reply \
  --max-drop 0.05
```

See [Run Evals In CI](https://traccia.ai/docs/guides/ci-evals).

### LangChain

Create a callback handler and pass it to `config={"callbacks": [traccia_handler]}`. Install the optional extra: `pip install traccia[langchain]`.

```
from traccia import init
from traccia.integrations.langchain import CallbackHandler  # or TracciaCallbackHandler
from langchain_openai import ChatOpenAI

init()

# Create Traccia handler (no args)
traccia_handler = CallbackHandler()

# Use with any LangChain runnable
llm = ChatOpenAI(model="gpt-4o-mini")
result = llm.invoke(
    "Tell me a joke",
    config={"callbacks": [traccia_handler]}
)
```

Spans for LLM/chat model runs are created automatically with the same attributes as direct OpenAI instrumentation (model, prompt, usage, cost).

**Note:** `pip install traccia[langchain]` installs traccia plus `langchain-core`; you need this extra to use the callback handler. If you already have `langchain-core` (e.g. from `langchain` or `langchain-openai`), base `pip install traccia` may be enough at runtime, but `traccia[langchain]` is the supported way to get a compatible dependency.

### OpenAI Agents SDK

Traccia **automatically** detects and instruments the OpenAI Agents SDK when installed. No extra code needed:

```
from traccia import init
from agents import Agent, Runner

init()  # Automatically enables Agents SDK tracing

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant"
)
result = Runner.run_sync(agent, "Write a haiku about recursion")
```

**Configuration**: Auto-enabled by default when `openai-agents` is installed. To disable:

```
init(openai_agents=False)  # Explicit parameter
# OR set environment variable: TRACCIA_OPENAI_AGENTS=false
# OR in traccia.toml under [instrumentation]: openai_agents = false
```

**Compatibility**: If you have `openai-agents` installed but don't use it (e.g., using LangChain or pure OpenAI instead), the integration is registered but never invoked—no overhead or extra spans.

### CrewAI

Traccia **automatically** instruments [CrewAI](https://docs.crewai.com/) when it is installed in your environment.

```
from traccia import init
from crewai import Agent, Task, Crew, Process

init()  # Auto
vijaypoudel50
🟧 echo.github ⭐The project presents a Python SDK for tracing, evaluating, and enforcing runtime policies on AI agents, with controls including spend caps, Traccia——

Interpretation history

Decision trace