Metadata-Version: 2.4
Name: rapidagent
Version: 0.3.1
Summary: Plug-and-play agentic framework with multi-backend, guardrails, and Azure AD support
Author-email: RapidAgent <oss@rapidagent.dev>
License-Expression: MIT
Project-URL: Homepage, https://github.com/your-org/rapidagent
Project-URL: Documentation, https://github.com/your-org/rapidagent#readme
Project-URL: Source, https://github.com/your-org/rapidagent
Keywords: ai,agent,langgraph,llm,guardrails,react,multi-agent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
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: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: openai>=1.0.0
Provides-Extra: cli
Requires-Dist: click>=8.0; extra == "cli"
Provides-Extra: langgraph
Requires-Dist: langgraph>=1.0.0; extra == "langgraph"
Requires-Dist: langchain-openai>=0.3.0; extra == "langgraph"
Provides-Extra: azure
Requires-Dist: azure-identity>=1.15.0; extra == "azure"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.50.0; extra == "anthropic"
Provides-Extra: google
Requires-Dist: google-genai>=1.0.0; extra == "google"
Provides-Extra: litellm
Requires-Dist: litellm>=1.0.0; extra == "litellm"
Provides-Extra: all
Requires-Dist: rapidagent[anthropic,azure,cli,google,langgraph,litellm]; extra == "all"
Dynamic: license-file

# RapidAgent

Plug-and-play agentic framework with **multi-backend support**, **native multi-LLM support**, **Azure OpenAI + Azure AD auth**, and **built-in security guardrails** (PII/PHI redaction, prompt injection prevention, tool authorization).

## Installation

```bash
pip install rapidagent                  # Core (Direct backend — all Python 3.10+)
pip install rapidagent[langgraph]       # + LangGraph backend
pip install rapidagent[azure]           # + Azure AD auth
pip install rapidagent[anthropic]       # + Anthropic Claude SDK
pip install rapidagent[google]          # + Google Gemini SDK
pip install rapidagent[litellm]         # + LiteLLM (100+ providers — see note below)
pip install rapidagent[cli]             # + CLI commands
pip install rapidagent[all]             # Everything
```

## Quickstart

```python
from rapidagent import RapidAgent, tool

@tool
def get_weather(city: str) -> str:
    """Get current weather."""
    return f"Weather in {city}: 72F, sunny"

agent = RapidAgent(model="openai:gpt-4o-mini", tools=[get_weather])
result = agent.invoke("Weather in SF?")
print(result["content"])
```

Or from YAML:

```yaml
name: my-agent
model: openai:gpt-4o-mini
system_prompt: "You are helpful."
tools:
  - name: current_time
    description: Get the current time
    function: rapidagent.tools.builtins:current_time
```

```python
agent = RapidAgent.from_config("agent.yaml")
```

---

## LLM Provider Support

RapidAgent supports 40+ LLM providers **natively** using their official SDKs. No single point of compromise.

### Native providers (official SDKs — recommended)

| Provider | Model String | SDK | Auth Env Var |
|----------|-------------|-----|-------------|
| **OpenAI** | `openai:gpt-4o-mini` | `openai` (core) | `OPENAI_API_KEY` |
| **Azure OpenAI** | *(dict config)* | `openai` (core) | `AZURE_OPENAI_ENDPOINT` |
| **Anthropic Claude** | `anthropic:claude-3-5-sonnet-latest` | `anthropic` | `ANTHROPIC_API_KEY` |
| **Google Gemini** | `google:gemini-2.0-flash` | `google-genai` | `GEMINI_API_KEY` |

### OpenAI-compatible providers (no extra SDKs)

Uses the **same `openai` SDK** (already installed) with a custom `base_url`. Zero additional dependencies, zero additional risk.

| Provider | Config |
|----------|--------|
| **Groq** | `provider: openai_compatible`, `endpoint: https://api.groq.com/openai/v1` |
| **Together AI** | `provider: openai_compatible`, `endpoint: https://api.together.xyz/v1` |
| **Ollama** (local) | `provider: openai_compatible`, `endpoint: http://localhost:11434/v1` |
| **OpenRouter** | `provider: openai_compatible`, `endpoint: https://openrouter.ai/api/v1` |
| **DeepSeek** | `provider: openai_compatible`, `endpoint: https://api.deepseek.com` |
| **Perplexity** | `provider: openai_compatible`, `endpoint: https://api.perplexity.ai` |
| **Fireworks** | `provider: openai_compatible`, `endpoint: https://api.fireworks.ai/inference/v1` |
| **+ 30 more** | Any OpenAI-compatible endpoint |

```yaml
model:
  provider: openai_compatible
  model: llama-3.3-70b-versatile
  endpoint: https://api.groq.com/openai/v1
```

```python
agent = RapidAgent(model="anthropic:claude-3-5-sonnet-latest")
agent = RapidAgent(model="google:gemini-2.0-flash")
```

### LiteLLM (explicit opt-in — for providers not covered above)

LiteLLM can route through 100+ providers via a single package. **Has had past security incidents** (supply-chain attacks exfiltrating credentials). Use only if your provider isn't covered by the native providers above.

```python
# Explicit opt-in — only works if you set this
agent = RapidAgent(model="litellm:bedrock/anthropic.claude-v2")
```

Installing `rapidagent[litellm]` shows a runtime warning every time it's used.

---

## Multi-Backend Architecture

| Python | Default Backend | Features |
|--------|----------------|----------|
| 3.10 – 3.13 | **LangGraph** | Full durability, checkpointing, HITL, multi-agent, LangSmith. |
| 3.14+ | **Direct** | Pure Python ReAct loop. Tools, streaming, memory, checkpointing included. |

```python
agent = RapidAgent(model="openai:gpt-4o-mini", backend="direct")
```

---

## Security Guardrails

Six built-in guardrails + audit trail. Enable via YAML or code.

```yaml
guardrails:
  input_filter:
    enabled: true
    block_patterns:
      - "ignore all instructions"
  tool_auth:
    enabled: true
    allowlist: [get_weather, current_time]
    denylist: [rm.*, exec.*]
  pii:
    enabled: true
    patterns:
      email: redact
      ssn: block
  phi:
    enabled: false           # HIPAA — opt-in
    include_pii: true
  output_filter:
    enabled: true
  audit_log:
    enabled: true
    path: ./audit/audit.jsonl
```

### What each guardrail does

| Guardrail | Hook Points | Default |
|-----------|------------|---------|
| **InputGuardrail** | Input → LLM | Blocks prompt injection, jailbreaks |
| **ToolAuthGuardrail** | Before tool exec | Denylist: exec, eval, rm, subprocess, drop table, shutdown |
| **PIIScanner** | All I/O points | Redacts email, phone, API keys. Blocks 9-digit SSNs |
| **PHIScanner** | Same as PII | 14 HIPAA patterns: MRN, Medicare IDs, VINs, IPs, health dates. Opt-in |
| **OutputGuardrail** | Response → user | Blocks hate speech, violent content |
| **RateLimiter** | Input | Sliding window (100 req / 60s) |

Every decision logged to JSONL audit file. Supports custom sinks (Datadog, Splunk).

```python
agent = RapidAgent(
    model="openai:gpt-4o-mini",
    guardrails={
        "input_filter": {"block_patterns": ["BADWORD"]},
        "phi": {"enabled": True},
    },
)
```

---

## CLI

```bash
rapidagent doctor              # Diagnose environment
rapidagent init my-project     # Interactive setup with prereq checks
rapidagent new my-project      # Quick scaffold
rapidagent run agent.yaml      # Interactive chat
rapidagent ask agent.yaml "Hi" # Single question
rapidagent list                # Available blueprints
```

---

## Features

| Feature | Description |
|---------|-------------|
| **Multi-backend** | LangGraph (3.10-3.13) or Direct (3.14+) — auto-selected |
| **40+ LLM providers** | OpenAI, Anthropic, Google, Groq, Together, Ollama, OpenRouter, DeepSeek, ... |
| **Azure OpenAI + AD** | API key, service principal, or DefaultAzureCredential |
| **Security guardrails** | PII/PHI redaction, prompt injection, tool auth, rate limiter, audit trail |
| **Crash recovery** | SQLite checkpointing after every LLM + tool step |
| **Structured output** | Pass any Pydantic model for JSON output |
| **Token/cost tracking** | Token counts and cost per invocation |
| **Retry with backoff** | Exponential backoff on API errors (rate limits, timeouts) |
| **`@tool` decorator** | Auto-generates LLM tool schemas from type hints |
| **Multi-agent** | Supervisor/worker, swarm, and sequential patterns |
| **CLI** | Scaffold, init, doctor, run, chat |
| **128 tests** | Completely covered |

---

## Configuration

```yaml
name: customer-support
model:
  provider: azure_openai
  deployment: gpt-4o
  endpoint: https://my-resource.openai.azure.com
  auth_type: default_credential
backend: direct
system_prompt: "You are a helpful support agent."
max_iterations: 10

tools:
  - name: lookup_order
    description: Look up an order
    function: tools.orders:lookup_order

guardrails:
  input_filter:
    enabled: true
  tool_auth:
    enabled: true
  pii:
    enabled: true
  audit_log:
    path: ./audit/audit.jsonl

human_in_the_loop:
  enabled: true
  require_approval_for:
    - process_refund
```

---

## Development

```bash
git clone https://github.com/your-org/rapidagent
cd rapidagent
pip install -e .[all]
python -m unittest discover tests/
```

## License

MIT
