Metadata-Version: 2.4
Name: agentinsight
Version: 0.1.0a1
Summary: Python observability SDK for agentic systems
Author: AgentInsight Team
License-Expression: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: opentelemetry
Requires-Dist: opentelemetry-api>=1.24; extra == "opentelemetry"
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.25; extra == "anthropic"
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2; extra == "langchain"
Provides-Extra: all
Requires-Dist: opentelemetry-api>=1.24; extra == "all"
Requires-Dist: openai>=1.0; extra == "all"
Requires-Dist: anthropic>=0.25; extra == "all"
Requires-Dist: langchain-core>=0.2; extra == "all"

# AgentInsight Python SDK

Drop-in observability for agentic systems. The SDK records agent, LLM, tool,
retrieval, orchestration, and custom spans, then exports them locally or to an
AgentInsight backend.

## Install

```bash
pip install agentinsight
```

For local development from this repository:

```bash
pip install -e sdk
```

## Quick Start

```python
import agentinsight
import openai

agentinsight.init(
    service_name="support-agent",
    exporter="cloud",
    endpoint="https://your-agentinsight-app.vercel.app",
    api_key="ai_...",
)

client = openai.OpenAI()
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello"}],
)
```

OpenAI and Anthropic calls are automatically traced when those packages are
installed. Use `@observe` and `trace_context` for custom agent logic.

## Local Export

```python
import agentinsight
from agentinsight import observe

agentinsight.init(exporter="local", local_path="agentinsight-spans.jsonl")

@observe(kind="agent")
def run_agent(task: str):
    return {"answer": task.upper()}

run_agent("triage this incident")
```

## Manual Spans

```python
from agentinsight import trace_context

with trace_context("plan_trip", kind="agent", attributes={"agent.name": "planner"}) as span:
    span.set_attribute("agent.step", "plan")
```

## LangChain / LangGraph

```python
from agentinsight.integrations.langchain import AgentInsightCallbackHandler

handler = AgentInsightCallbackHandler()
chain.invoke({"input": "hello"}, config={"callbacks": [handler]})
```

LangGraph uses LangChain callbacks, so the same handler works for many LangGraph
apps.
