Agent RT Documentation
Documentation menu
Getting started

Quickstart

The repository examples are deliberately incremental. Start with one agent call, then add the capabilities that matter to production behavior without introducing another framework layer.

Minimal Python agent

This is the smallest self-contained Python example: configure a model name, create an agent, create a user message, and run the loop.

import asyncio
import os

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

async def main():
    model = os.environ.get("OPENAI_MODEL") or os.environ.get("ANTHROPIC_MODEL")
    if not model:
        raise RuntimeError("Set OPENAI_MODEL or ANTHROPIC_MODEL")
    provider = load_model()

    agent = AgentConfig(
        name="assistant",
        instructions="Answer clearly and concisely.",
        model=ModelSettings(model=model),
    )
    message = ModelMessage(
        role="user",
        content=(ContentPart(type="text", text="What does Agent RT do?"),),
    )

    result = await AgentLoop(provider).run(agent, [message])
    print(result.termination_reason)

asyncio.run(main())

Minimal TypeScript agent

const { AgentLoop, loadModel } = require("agent-rt");

async function main() {
  const model = process.env.OPENAI_MODEL || process.env.ANTHROPIC_MODEL;
  if (!model) throw new Error("Set OPENAI_MODEL or ANTHROPIC_MODEL");

  const provider = await loadModel();
  const agent = {
    name: "assistant",
    instructions: "Answer clearly and concisely.",
    model: { model },
  };
  const messages = [{
    role: "user",
    content: [{ type: "text", text: "What does Agent RT do?" }],
  }];

  const result = await new AgentLoop(provider).run(agent, messages);
  console.log(result.terminationReason);
}

main();
Continue as a tutorialThe Features & defaults reference now includes copyable Python and TypeScript examples for tools, streaming, structured output, limits, guardrails, permissions, approvals, state/memory, sandboxing, retrieval, budgets, and observability.

Recommended path

ExampleWhat it adds
01_basic_agentA minimal run against a configured provider.
02_tool_callingA read-only tool and the model → tool → model continuation loop.
03_streamingProvider-neutral text delta consumption.
04_structured_outputSchema-validated JSON with a bounded repair attempt.
05_run_limitsTurn, tool-call, elapsed-time, and token limits.
06_tool_registryNamespaces, direct execution, and enable/disable controls without a model provider.
07_vector_dbEnvironment-driven Chroma, Milvus, Pinecone, Qdrant, or Weaviate retrieval without changing application code.

Run the Python examples

cd python
uv sync
uv run python examples/01_basic_agent.py
uv run python examples/02_tool_calling.py
uv run python examples/07_vector_db.py

Run the TypeScript examples

cd typescript
npm ci
npm run build
node examples/01_basic_agent.js
node examples/02_tool_calling.js
node examples/07_vector_db.js
Offline checkThe tool-registry example is fully offline in both implementations, so it is useful for validating local setup without model credentials.

What to learn next

Once the basic loop is clear, read the runtime model before adding more capabilities. It explains where Agent RT draws boundaries between model behavior, tool execution, workflow state, policy, and termination.