Skip to content

Latest commit

 

History

History
102 lines (75 loc) · 5.56 KB

README.md

File metadata and controls

102 lines (75 loc) · 5.56 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. OpenAI support is included; Anthropic, 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. Migration-compatible entry points for supported subsets of OpenAI, Anthropic, OpenRouter, LiteLLM, LangChain, Deep Agents, 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: anthropic, observability, api, cli, guardrails

Works with the openai (1.31+, including 2.x and 3.x) and anthropic (0.29+, including 1.x) SDK versions your project already pins — any release since mid-2024.

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 models and vector stores in agent-rt.yaml (current folder) or ~/.agent-rt/config.yaml, or pass any path with --config / load_config(path). Secrets are referenced as os.environ/NAME; nothing else is read from the environment. Bedrock Knowledge Bases uses the optional agent-rt[bedrock] extra and AWS IAM credentials. See Configuration and the example file.

model_list:
  - model_name: my-model
    agent_rt_params:
      model: openai/your-model        # or anthropic/..., add api_base for compatible endpoints
      api_key: os.environ/OPENAI_API_KEY
import asyncio

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


async def main() -> None:
    # validate=False skips the startup model-list check, so no extra network call.
    config = load_config()  # agent-rt.yaml, ~/.agent-rt/config.yaml, or an explicit path
    provider = load_model(config)
    agent = AgentConfig(
        name="assistant",
        instructions="Answer clearly and concisely.",
        model=ModelSettings(model="my-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 --config ./agent-rt.yaml -p "...". Reuse an existing agent CLI's models and API keys with agent-rt claude -p "...", agent-rt codex exec "...", agent-rt opencode run "...", or agent-rt copilot -p "..." (details).
  • Web UI (agent-rt[web]): run agent-rt-web in a project folder to chat in your browser, with sessions saved in the browser and in-page approval for file edits (details).

Learn more