Metadata-Version: 2.4
Name: agentbase-autoheal
Version: 0.1.0
Summary: Deploy, observe, and auto-heal your AI agents
Home-page: https://agentbase.dev
Author: AgentBase
Author-email: hello@agentbase.dev
Project-URL: Documentation, https://agent-product.up.railway.app/docs
Project-URL: Source, https://github.com/agentbase/agentbase-sdk
Keywords: ai agents observability monitoring auto-heal llm langchain crewai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary 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: Topic :: Software Development :: Libraries
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: langchain
Requires-Dist: langchain>=0.1.0; extra == "langchain"
Provides-Extra: crewai
Requires-Dist: crewai>=0.1.0; extra == "crewai"
Provides-Extra: all
Requires-Dist: langchain>=0.1.0; extra == "all"
Requires-Dist: crewai>=0.1.0; extra == "all"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# agentbase-sdk

**Deploy. Observe. Heal.** The Python SDK for [AgentBase](https://agentbase.dev) - the operating system for AI agents.

## Install

```bash
pip install agentbase-sdk
```

## Quick Start (2 lines to instrument)

```python
import agentbase_sdk as ab

ab.init(api_key="ab_live_...", agent_name="my-agent")
ab.instrument_openai()  # auto-trace every LLM call

# That's it. Every OpenAI call is now traced with:
# - Token counts & costs
# - Latency
# - Error detection
# - Auto-heal on failures
```

## Manual Tracing

```python
import agentbase_sdk as ab

ab.init(api_key="ab_live_...", agent_name="support-bot")

with ab.trace("handle-ticket") as t:
    t.set_input(user_question)

    with ab.span("classify", span_type="llm") as s:
        s.set_model("gpt-4o")
        intent = classify(user_question)
        s.set_output(intent)
        s.set_tokens(prompt_tokens=200, completion_tokens=20)

    with ab.span("search-kb", span_type="tool") as s:
        s.set_tool("knowledge_base")
        results = search(intent)
        s.set_output(str(results))

    with ab.span("respond", span_type="llm") as s:
        s.set_model("gpt-4o")
        answer = generate(intent, results)
        s.set_output(answer)
        s.set_tokens(prompt_tokens=800, completion_tokens=200)

    t.set_output(answer)
```

## Decorators

```python
from agentbase_sdk import observe, heal

@observe(as_trace=True)
def handle_support_ticket(question: str) -> str:
    return my_agent.run(question)

@heal(retry=3, fallback=lambda: "Sorry, please try again.")
def risky_api_call(query: str) -> str:
    return external_api.search(query)
```

## Auto-Instrumentation

```python
ab.instrument_openai()      # OpenAI SDK
ab.instrument_anthropic()   # Anthropic SDK
ab.instrument_langchain()   # LangChain
ab.instrument_crewai()      # CrewAI
```

## Auto-Heal

When your agent encounters errors, AgentBase automatically:

| Error | Fix |
|---|---|
| Hallucination (404, missing endpoint) | Corrects endpoint, retries |
| Context overflow | Chunks input with sliding window |
| Infinite loop | Circuit breaker |
| Tool timeout | Retry with exponential backoff |
| Wrong tool selected | Re-routes with task context |
| JSON parse error | Retries with format hint |

## Dashboard

View all traces, costs, and heal events at your AgentBase dashboard.

## Links

- [API Documentation](https://agent-product.up.railway.app/docs)
- [Website](https://agentbase.dev)
