Metadata-Version: 2.4
Name: agentwatch-observe
Version: 0.1.1
Summary: Lightweight observability SDK for AI agents — wrap any agent framework, get anomaly detection, guardrails, and cost tracking.
Author-email: AgentWatch <hello@agentwatch.in>
License-Expression: MIT
Project-URL: Homepage, https://www.agentwatch.in
Project-URL: Documentation, https://www.agentwatch.in
Keywords: ai,agents,observability,llm,monitoring,guardrails
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
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 :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28
Requires-Dist: httpx>=0.27
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2; extra == "langchain"
Dynamic: license-file

# agentwatch-observe

Lightweight observability for AI agents. Wrap any local or cloud model call, stream
steps to AgentWatch, and get cost tracking, anomaly detection, and guardrails on
the dashboard at [agentwatch.in](https://www.agentwatch.in).

**Privacy:** Your model credentials (OpenAI, Gemini, Ollama, etc.) stay on your
machine. AgentWatch only receives telemetry — tokens, cost estimates, tool names,
timing, and step metadata — never your API keys or raw model weights.

## Install

```bash
pip install agentwatch-observe
```

Optional LangChain integration:

```bash
pip install "agentwatch-observe[langchain]"
```

## Quickstart (any agent, any model)

Add to your project `.env`:

```bash
AGENTWATCH_API_KEY=your_key_here
AGENTWATCH_BASE_URL=https://api.agentwatch.in   # optional
```

Two lines in your agent code — works with Gemini, OpenAI, Ollama, LangChain, or custom logic:

```python
import agentwatch

agentwatch.bootstrap()  # reads AGENTWATCH_API_KEY from env

@agentwatch.track(agent_name="my-agent")
def handle_message(message: str):
    return your_existing_agent_logic(message)
```

Open the [AgentWatch dashboard](https://www.agentwatch.in) → **Runs** to see the trace.

### Optional: auto-capture provider SDK calls

If you call a provider SDK directly, wrap it once and every LLM call is logged:

```python
from google import genai
client = agentwatch.instrument_google_genai_client(genai.Client(api_key="..."))
# client.models.generate_content(...) is now auto-logged inside an active run

# Also: instrument_openai(OpenAI()), instrument_anthropic(Anthropic())
```

### Manual step logging (advanced)

```python
with agentwatch.run("my-agent") as run:
    run.log_llm(model="gpt-4o-mini", input_tokens=120, output_tokens=40, output="Hello!")
    run.log_tool("search", input_data={"q": "hello"}, output_data={"results": []})
```

## Framework-agnostic API

- `agentwatch.run(...)` — context manager
- `run.log_llm(...)` — LLM step with token/cost tracking
- `run.log_tool(...)` — tool call step
- `agentwatch.track(...)` — decorator
- `agentwatch.instrument_openai(client)` — auto-log OpenAI calls

See the full docs at [agentwatch.in](https://www.agentwatch.in).

## Releasing a new version

PyPI never allows re-uploading the same version number.

1. Bump `version` in `pyproject.toml` and `agentwatch/__init__.py`
2. `cd sdk && python -m build`
3. `twine check dist/*`
4. Upload to TestPyPI first: `twine upload --repository testpypi dist/*`
5. After verification, upload to PyPI: `twine upload dist/*`

See `CONTRIBUTING.md` for details.
