semvec/pypi-packages huggingface dataset:
traceagent 0.1.1
TraceAgent — Local-first AI agent observability SDK. Trace LangChain, LangGraph, and any Python code. Open-source alternative to LangSmith.
License: MIT
Requires Python: >=3.9
Keywords: agents, ai, debugging, langchain, langgraph, llm, observability, tracing

# TraceAgent

**Local-first observability for AI agents.** Open-source alternative to LangSmith. Trace LangChain, LangGraph, and any Python code with zero config.

## Install

```bash
pip install traceagent
```

## Quick Start

### Option 1: Environment Variables (zero code changes, like LangSmith)

```bash
export TraceAgent_ENABLED=true
export TraceAgent_ENDPOINT=http://localhost:6832   # your TraceAgent server
```

```python
import traceagent  # auto-traces all LangChain/LangGraph calls

result = graph.invoke({"messages": [HumanMessage(content="Hello!")]})
# traces appear at http://localhost:6832
```

### Option 2: Explicit Callback

```python
from traceagent import TraceAgent

lens = TraceAgent(server_url="http://localhost:6832")

result = graph.invoke(
    {"messages": [HumanMessage(content="Hello!")]},
    config={"callbacks": [lens.callback()]}
)
```

### Option 3: Decorators & Context Managers

```python
from traceagent import TraceAgent

lens = TraceAgent()

@lens.observe(name="search", kind="tool")
def search(query: str):
    return results

with lens.trace("My Pipeline") as t:
    result = search("hello")
    t.outputs = {"result": result}
```

## Configuration

| Env Variable | Description | Default |
|---|---|---|
| `TraceAgent_ENABLED` | Enable tracing | `false` |
| `TraceAgent_ENDPOINT` | Server URL | `http://localhost:6832` |
| `TraceAgent_PROJECT` | Project name | `default` |
| `TraceAgent_TAGS` | Comma-separated tags | |
| `TraceAgent_AUTO_TRACE` | Auto-attach to LangChain | `true` when enabled |

## Server

The SDK sends traces to a TraceAgent server. Run it with Docker:

```bash
docker run -d -p 6832:6832 ashishgituser/TraceAgent-server:latest
```

Then open **http://localhost:6832** for the dashboard.

See the full project at [github.com/ashishgituser/TraceAgent](https://github.com/ashishgituser/TraceAgent).