Skip to content

Latest commit

 

History

History
97 lines (70 loc) · 4.27 KB

File metadata and controls

97 lines (70 loc) · 4.27 KB

Agent RT for Python

A lightweight, provider-neutral runtime for building AI agents with explicit control over tools, safety, state, and orchestration.

🌐 Website · Documentation · GitHub

Start with an OpenAI-compatible endpoint, then add tools, approvals, memory, sandboxing, retrieval, and multi-agent orchestration without replacing your runtime. asyncio-native, with an optional API server and terminal CLI.

Why Agent RT?

  • Provider-neutral. OpenAI-compatible endpoints, OpenAI, Anthropic, or your own ModelProvider.
  • Safe by construction. Tool validation, permissions, composable action blockers, approvals, deterministic PII morphing, guardrails, budgets, and deadlines are runtime primitives.
  • Scales large tool catalogs. Toolbase combines local/deferred and MCP tools, safety-screens them, sends only the relevant subset per turn, and keeps tool_search available for fallback discovery.
  • Small core. Provider SDKs, guardrails, API serving, CLI, and sandboxes are opt-in extras.
  • Production-ready. Checkpoints, event streams, queues, tracing, cost ledgers, retrieval with post-retrieval reranking, and multi-agent patterns.
  • Easy to adopt. Drop-in compatibility for OpenAI, Anthropic, LangChain, LlamaIndex, OpenAI Agents, AutoGen, and CrewAI code; across Agent RT's ongoing migration field testing, 69 third-party repositories pass before and after migration.

Install

Python 3.10–3.14.

pip install agent-rt
pip install 'agent-rt[all]'   # or pick extras: openai, anthropic, observability, api, cli, guardrails

OpenLLMetry/Traceloop export is optional. Install agent-rt[observability] only when TRACELOOP-based telemetry is needed; the core runtime does not require it.

Quick start

Configure a model:

export OPENAI_MODEL="your-model"
export OPENAI_API_KEY="..."

For an OpenAI-compatible endpoint, also set OPENAI_BASE_URL. If multiple provider configurations are present, set MODEL_PROVIDER=openai or MODEL_PROVIDER=anthropic.

import asyncio
import os

from agent_rt import (
    AgentConfig,
    AgentLoop,
    ContentPart,
    ModelMessage,
    ModelSettings,
    load_model,
)


async def main() -> None:
    # validate=False skips the startup model-list check, so no extra network call.
    provider = load_model(validate=False)
    agent = AgentConfig(
        name="assistant",
        instructions="Answer clearly and concisely.",
        model=ModelSettings(model=os.environ["OPENAI_MODEL"]),
    )
    message = ModelMessage(
        role="user",
        content=(ContentPart(type="text", text="What can Agent RT do?"),),
    )

    result = await AgentLoop(provider).run(agent, [message])
    if result.final_response:
        print(
            "".join(
                part.text or ""
                for part in result.final_response.message.content
                if part.type == "text"
            )
        )


asyncio.run(main())

More examples: examples/.

Migrate in one line

Prepend agent_rt. to a supported import, for example from agent_rt.langchain_openai import ChatOpenAI or from agent_rt.openai import OpenAI. See Migration.

Also included

  • API server (agent-rt[api]): OpenAI-compatible Chat Completions/Responses and Anthropic-compatible Messages endpoints.
  • Terminal CLI (agent-rt[cli]): agent-rt -p "explain this stack trace" or agent-rt --env-file=./.env -p "...".

Learn more