agentleFS
PydanticKnown publisherpydantic/pydantic-ai/pydantic_ai_slim/pydantic_ai/realtime/AGENTS.md

pydantic-ai / realtime

AGENTS.md20k starsChanged 2 months agoMITView on GitHub

Start with the architecture walkthrough in docs/api/realtime.md and the user-facing guides under docs/realtime/: a RealtimeModel.connect() opens a provider-specific RealtimeConnection (the codec, vocabulary in codec.py), and RealtimeSession (_session.py) wraps it — translating codec events into the shared message/part vocabulary from pydantic_ai.messages, building ordinary ModelMessage history, and running the tool loop. The provider-agnostic layout mirrors the request-response side: model.py holds the RealtimeModel ABC and infer_realtime_model, settings.py the settings vocabulary, profiles.py the RealtimeModelProfile type (per-provider tables live in pydantic_ai/profiles/{google,openai,grok}.py as *_realtime_model_profile helpers), and…

  • Reads credentials

Trending

Quiet since October.about the whole repository

Jan 2026: 0 mentionsFeb 2026: 2 mentionsMar 2026: 2 mentionsApr 2026: 29 mentionsMay 2026: 2 mentionsJun 2026: 2 mentionsJul 2026: 3 mentionsAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentionsDec 2026: 0 mentions
Jan 2026Jul 2026Dec 2026
Mentions a month of the pydantic/pydantic-ai repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about pydantic/pydantic-ai

The biggest 5 of 64 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 64

Talked about on GitHub, Bluesky, Hacker News and the web (64 times).

On GitHub · 50

45 more on GitHub

On Bluesky · 7

2 more on Bluesky

On Hacker News · 5

On the web · 2

The file

We split this AGENTS.md into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Start with the architecture walkthrough in docs/api/realtime.md and the user-facing guides under docs/realtime/: a RealtimeModel.connect() …

    line 3
  2. Very specific:

    When behavior differs from a standard run (no graph nodes, no before_model_request, deferred results resolved inline), the difference must …

    line 25

≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

pydantic_ai_slim/pydantic_ai/realtime/ Guidelines

Start with the architecture walkthrough in docs/api/realtime.md and the user-facing guides under docs/realtime/: a RealtimeModel.connect() opens a provider-specific RealtimeConnection (the codec, vocabulary in codec.py), and RealtimeSession (_session.py) wraps it — translating codec events into the shared message/part vocabulary from pydantic_ai.messages, building ordinary ModelMessage history, and running the tool loop. The provider-agnostic layout mirrors the request-response side: model.py holds the RealtimeModel ABC and infer_realtime_model, settings.py the settings vocabulary, profiles.py the RealtimeModelProfile type (per-provider tables live in pydantic_ai/profiles/{google,openai,grok}.py as *_realtime_model_profile helpers), and codec.py the connection layer; concrete providers live in openai.py / azure.py / google.py / xai.py / openai_live.py (OpenAI GPT-Live, a different protocol from the Realtime API rather than another model on it, which is why infer_realtime_model routes it by model name inside the openai prefix). The models/ guidelines apply in spirit throughout.

Policy lives in the shared core, never in the session

  • The session executes tools through the same ToolManager core as the agent graph (validate_tool_call / execute_tool_call / build_tool_return_part), so hooks, retries, and usage behave identically by construction. Any policy the graph applies before dispatch (declarative tool kinds: 'unapproved' → ApprovalRequired, 'external' → CallDeferred) is enforced inside ToolManager.handle_call — do not reimplement or filter above it. A reimplemented policy layer that drifts is a security bug, not a style problem: the realtime approval-bypass was exactly this.
  • When behavior differs from a standard run (no graph nodes, no before_model_request, deferred results resolved inline), the difference must be deliberate, documented in docs/realtime/, and covered by a parity test in tests/realtime/.

Provider adapters

  • Parse provider frames through typed SDK models, never ad-hoc dict access. OpenAI-protocol event types come from the OpenAI SDK; Gemini's from google-genai.
  • Azure and xAI reuse the OpenAI codec (_openai_protocol.py). Fix protocol bugs there so all three benefit; put genuinely provider-specific divergence in the provider's own module.
  • Capability differences go through RealtimeModelProfile flags (resolved defaults → provider → user profile=), never isinstance/provider-name checks at use sites. A change that branches on a profile flag needs a test pinning each side of the flag.
  • One event means one thing on every provider. If providers disagree about what a frame implies (speech start, turn end), normalize in the codec — the session must not branch per provider. RealtimeTurnCompleteEvent is synthesized by the session, never read off the wire. Where a protocol has no end-of-turn frame at all (GPT-Live), the connection synthesizes ResponseDone from output timing and the profile says so via synthesizes_turn_boundary, so the session still sees one vocabulary.
  • Wrap connect/handshake failures in ModelAPIError/ModelHTTPError; recoverable in-session provider errors become RealtimeSessionErrorEvent and leave the session usable.

History fidelity

Session history must always be a valid input for Agent.run(message_history=...): settle everything on close/reconnect-loss (partial replies recorded as interrupted responses, running tools given cancelled returns) so history never ends on a dangling ToolCallPart.

Testing

  • Realtime WebSocket cassettes live in tests/realtime/cassettes/ (raw frames, secrets scrubbed, audio truncated); record with uv run --env-file .env pytest --record-mode=rewrite <test>. The cross-provider matrix test is the parity net — extend it when adding provider behavior.
  • Docs examples run against the scripted MockRealtimeConnection in tests/test_examples.py; an agent defining a check_availability tool triggers the scripted conversation reserved for the quickstart, so don't use that tool name elsewhere.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.