Metadata-Version: 2.4
Name: astro-agents
Version: 0.1.0
Summary: Typed async client for the Astro Agents control plane and runtime.
Author: 
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# astro-agents

`astro-agents` is a Python client library for the Astro Agents platform — a managed runtime for building, running, and observing LLM agent workloads. It provides typed clients for the Astro control plane and runtime so you can register agent definitions, stream inference and tool-call events, attach to live sessions, and ship traces to the Astro observability backend. It is aimed at teams deploying agent pipelines that need durable execution, multi-step tool calling, and per-session telemetry.

The SDK is published from the `python/` subdirectory of the `astro-agents-clients` monorepo and works with both hosted Astro tenants and self-hosted runtimes.

## Features

- Typed async client for the Astro control plane (`AgentClient`) with agents, sessions, runs, and trace endpoints.
- Stream agent responses token-by-token via `runs.stream()` and consume structured tool-call events (`ToolCall`, `ToolResult`).
- Register agent definitions (model, tools, system prompt) and pin them to a named version for reproducible runs.
- Attach middleware for guardrails, redaction, and retries before each model call.
- Export OpenTelemetry-compatible traces from every run to the Astro observability backend.
- Replay a finished run locally from its trace ID for debugging.
- Sync helpers (`to_dict`, `to_pandas`) for exporting run history to notebooks.

## Installation

```bash
pip install "astro-agents @ git+https://github.com/aidatatools-dev/astro-agents-clients#subdirectory=python"
```

## Quick start

```python
from astro_agents import AgentClient

client = AgentClient(api_key="astro_live_...")

agent = client.agents.create(
    name="support-triage",
    model="astro/gpt-4o-mini",
    tools=[{"type": "function", "function": {"name": "lookup_order"}}],
    system_prompt="Triage incoming support tickets and route by urgency.",
)

run = client.runs.start(
    agent_id=agent.id,
    input="Order #8842 was charged twice — please escalate.",
)

for event in client.runs.stream(run.id):
    if event.type == "tool_call":
        print("calling", event.tool, event.args)
    elif event.type == "text":
        print(event.delta, end="")
```

## API

- `AgentClient(api_key: str, *, base_url: str | None = None)` — entry point; exposes `.agents`, `.runs`, `.sessions`, and `.traces` namespaces.
- `AgentClient.agents.create(name, model, tools, system_prompt) -> Agent` — registers a versioned agent definition.
- `AgentClient.runs.start(agent_id, input, **kwargs) -> Run` — starts a run; pass `session_id` to continue a conversation.
- `AgentClient.runs.stream(run_id) -> AsyncIterator[AgentEvent]` — yields `text`, `tool_call`, `tool_result`, and `finish` events.

## Configuration

- `ASTRO_API_KEY` — default API key when `AgentClient` is constructed without arguments.
- `ASTRO_BASE_URL` — override the control-plane endpoint (default `https://api.astro-agent.dev`).
- `ASTRO_TRACE_EXPORT` — set to `otlp`, `stdout`, or `off` to control trace export from runs.

## License

MIT
