Metadata-Version: 2.4
Name: traceagent
Version: 0.1.0
Summary: Local-first observability for AI agents. Lightweight SDK — trace LangChain, LangGraph, and any Python code.
Project-URL: Homepage, https://github.com/agentlens/agentlens
Project-URL: Documentation, https://github.com/agentlens/agentlens#readme
Project-URL: Repository, https://github.com/agentlens/agentlens
Project-URL: Issues, https://github.com/agentlens/agentlens/issues
Author: AgentLens Contributors
License: MIT
Keywords: agents,ai,debugging,langchain,langgraph,llm,observability,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.9
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 :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Debuggers
Requires-Python: >=3.9
Requires-Dist: pydantic>=2.0
Provides-Extra: all
Requires-Dist: langchain-core>=0.1.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: httpx>=0.24; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.1.0; extra == 'langchain'
Description-Content-Type: text/markdown

# AgentLens SDK

**Local-first observability for AI agents.** Lightweight Python SDK — trace LangChain, LangGraph, and any Python code.

## Install

```bash
pip install agentlens
```

## Quick Start

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

```bash
export AGENTLENS_ENABLED=true
export AGENTLENS_ENDPOINT=http://localhost:6832   # your AgentLens server
```

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

result = graph.invoke({"messages": [HumanMessage(content="Hello!")]})
```

### Option 2: Explicit Callback

```python
from agentlens import AgentLens

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

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

### Option 3: Decorators & Context Managers

```python
from agentlens import AgentLens

lens = AgentLens()

@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 |
|---|---|---|
| `AGENTLENS_ENABLED` | Enable tracing | `false` |
| `AGENTLENS_ENDPOINT` | Server URL | `http://localhost:6832` |
| `AGENTLENS_PROJECT` | Project name | `default` |
| `AGENTLENS_TAGS` | Comma-separated tags | |
| `AGENTLENS_AUTO_TRACE` | Auto-attach to LangChain | `true` when enabled |

## Server

The SDK sends traces to an AgentLens server. See [agentlens-server](../server/) for setup.
