pydantic-ai / pydantic_ai_pax
AGENTS.md21k starsChanged 5 days agoMITView on GitHub
Read this before touching src/pydantic_ai_pax/. The repository-level AGENTS.md still applies (no em-dashes, no Any, pyright strict, keyword-only arguments, 100% branch coverage). This file adds what is specific to the terminal shell. A thin terminal around any Pydantic AI agent. It reads a prompt, runs the agent, streams the answer, and repeats. Everything beyond that is a plugin, including the default coding tools. The three layers, and who owns what: If a change needs the agent loop to behave differently, propose…
- Reads credentials
Trending
More talk lately.about the whole repository
Who's talking about pydantic/pydantic-ai
- Cole Medin“Pydantic AI 2.0: The New Best Way to Build AI Agents is Composing Capabilities”YouTube · Jul 10, 2026 · 35k views
- YourTechBud Codes“Should You Adopt Pydantic AI? Deep Dive + Real Use Cases!”YouTube · Dec 30, 2024 · 19k views
- AI with Lena Hall“Python AI Agents with Pydantic AI: Example & Interview with Pydantic Creator”YouTube · Jul 3, 2025 · 13k views
- WorldofAI“Pydantic AI: Build Production Grade Applications - NEW AI Agent Builder Framework!”YouTube · Dec 5, 2024 · 11k views
- AAIF Live“Build a Slack Agent with Pydantic AI [Step-by-Step Tutorial]”YouTube · Apr 11, 2025 · 1.7k views
The biggest 5 of 85 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 85
Talked about on GitHub, YouTube, Bluesky and Hacker News (85 times).
On GitHub · 50
- Sep 19, 2025Add support for `gen_ai.system_instructions` gen-ai field — langfuse/langfuse7 reactions · 4 comments
- May 27, 2025Dockerise the MCP Run Python server — pydantic/mcp-run-python5 reactions · 6 comments
- Oct 16, 2025Inngest Durable execution with Pydantic-AI — inngest/inngest-py4 reactions · 9 comments
- May 23, 2025Handle `type[T]` for type variables — astral-sh/ty4 reactions · 3 comments
- Oct 11, 2026Pydantic AI integration: support TemporalDurability (TemporalAgent is deprecated, removed in v3) — temporal-community/temporal-agent-kit3 reactions · 1 comment
45 more on GitHub
- Mar 12, 2026Impossible to run the app due to Mistral import error — Denario-AI/Denario3 reactions · 3 comments
- Feb 27, 2026Anthropic cache tokens double-counted: usage.input already includes cache via OTel/genai-prices — langfuse/langfuse3 reactions · 6 comments
- May 25, 2025Misc. bug: Streaming with tools causes pydantic-ai to mess up tool name — ggml-org/llama.cpp3 reactions · 5 comments
- May 21, 2026chore(deps): bump pydantic-ai from 1.56.0 to 1.99.0 — dorel14/SoniqueBay2 reactions · 1 comment
- May 21, 2026chore(deps): bump pydantic-ai from 1.56.0 to 1.99.0 in /backend/api — dorel14/SoniqueBay2 reactions · 1 comment
- Apr 1, 2026chore(deps): bump pydantic-ai from 0.2.15 to 1.56.0 in /backend — cicero-im/meeting-minutes2 reactions · 1 comment
- Apr 1, 2026Bump pydantic-ai-slim from 1.0.1 to 1.56.0 — cicero-im/codantic-aidisplayagent2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai from 1.0.1 to 1.56.0 — cicero-im/codantic-aidisplayagent2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai-slim from 0.0.46 to 1.56.0 in /pydantic-ai-langfuse — cicero-im/ottomator-agents2 reactions · 1 comment
- Apr 1, 2026Bump pydantic-ai-slim from 0.6.2 to 1.56.0 — cicero-im/paigeant2 reactions · 2 comments
- Apr 1, 2026chore(deps): bump pydantic-ai from 0.2.6 to 1.56.0 — cicero-im/tunacode2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai-slim from 0.7.4 to 1.56.0 in /agent-backend — cicero-im/pydantic-ai-fastapi-react-vite-agent2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai from 1.0.10 to 1.56.0 in /examples/integrations/pydanticAI_researcher_example — cicero-im/memori2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai from 1.0.17 to 1.56.0 — cicero-im/github-issue-analysis2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai from 0.6.2 to 1.56.0 — cicero-im/paigeant2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai from 0.0.46 to 1.56.0 in /pydantic-ai-langfuse — cicero-im/ottomator-agents2 reactions · 1 comment
- Apr 1, 2026chore(deps): bump pydantic-ai-slim from 1.0.15 to 1.56.0 — cicero-im/pydantic_ai_claude_code2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai from 0.7.4 to 1.56.0 in /agent-backend — cicero-im/pydantic-ai-fastapi-react-vite-agent2 reactions · 1 comment
- Apr 1, 2026Bump pydantic-ai-slim from 0.0.30 to 1.56.0 — cicero-im/pydanticai_mcp_demo2 reactions · 1 comment
- Apr 1, 2026build(deps): bump pydantic-ai from 0.2.0 to 1.56.0 — cicero-im/lightblue-ai2 reactions · 1 comment
- Apr 1, 2026Bump pydantic-ai from 0.3.1 to 1.56.0 — cicero-im/pydantic_ai_editor2 reactions · 2 comments
- Apr 1, 2026chore(deps): bump pydantic-ai from 0.3.4 to 1.56.0 — cicero-im/mcp2 reactions · 2 comments
- Apr 1, 2026chore(deps): bump pydantic-ai-slim from 0.3.4 to 1.56.0 — cicero-im/mcp2 reactions · 3 comments
- Apr 1, 2026chore(deps): bump pydantic-ai-slim from 0.2.12 to 1.56.0 — cicero-im/pydantic-ai-mcp-experiment2 reactions · 1 comment
- Apr 1, 2026build(deps): bump pydantic-ai-slim from 0.2.18 to 1.56.0 — cicero-im/me-pydanticai-2 reactions · 1 comment
- Apr 1, 2026Bump pydantic-ai from 0.0.30 to 1.56.0 — cicero-im/pydanticai_mcp_demo2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai-slim from 0.3.1 to 1.56.0 — cicero-im/pydantic_ai_editor2 reactions · 2 comments
- Apr 1, 2026build(deps): bump pydantic-ai from 0.2.18 to 1.56.0 — cicero-im/me-pydanticai-2 reactions · 2 comments
- Apr 1, 2026build(deps): bump pydantic-ai-slim from 0.0.52 to 1.56.0 — cicero-im/wa_llm2 reactions · 1 comment
- Apr 1, 2026build(deps): bump pydantic-ai-slim from 0.2.0 to 1.56.0 — cicero-im/lightblue-ai2 reactions · 1 comment
- Apr 1, 2026Bump pydantic-ai-slim from 0.0.43 to 1.56.0 — cicero-im/Ai_Tutor2 reactions · 1 comment
- Apr 1, 2026chore(deps): bump pydantic-ai from 0.0.42 to 1.56.0 — cicero-im/automagik-agents2 reactions · 2 comments
- Apr 1, 2026Bump pydantic-ai from 0.0.43 to 1.56.0 — cicero-im/Ai_Tutor2 reactions · 2 comments
- Apr 1, 2026build(deps): bump pydantic-ai from 0.0.52 to 1.56.0 — cicero-im/wa_llm2 reactions · 1 comment
- Mar 26, 2026build(deps): bump the pip group across 5 directories with 4 updates — GoldenEagle-23/oss-fuzz2 reactions · 1 comment
- Feb 28, 2026Error because `thoughtSignature` missing from Gemini 3 function call — Arjun-Vashistha/Test-Repo-22 reactions
- Nov 21, 2025Run generator.__anext__ in the same task to avoid anyio RuntimeError — langfuse/langfuse-python2 reactions · 2 comments
- Nov 14, 2025Dockerise MCP-run-python server + add git workflows to publish images — pydantic/mcp-run-python2 reactions · 5 comments
- Aug 4, 2025Tracking: Contribute FastMCP Toolset to Pydantic AI — PrefectHQ/fastmcp2 reactions · 1 comment
- Jul 12, 2025Tool context kwarg detection not compatible with string-valued/__future__ annotations — modelcontextprotocol/python-sdk2 reactions · 3 comments
- May 23, 2025Sequence of types — python/mypy2 reactions · 2 comments
- Nov 11, 2026Protected session capture: `Parse agent logs for step summary` fails when the engine step never ran — github/gh-aw1 reaction
- May 29, 2026Consider automation to close duplicate PRs? — jupyterlab/jupyterlab1 reaction · 1 comment
- May 7, 2026chore: port pydantic-ai v1.91.0 changes — a7ul/vibes1 reaction
- May 5, 2026chore: port pydantic-ai v1.90.0 changes — a7ul/vibes1 reaction
On YouTube · 23
- Jul 10, 2026Pydantic AI 2.0: The New Best Way to Build AI Agents is Composing Capabilities — Cole Medin35k views · 73 comments
- Dec 30, 2024Should You Adopt Pydantic AI? Deep Dive + Real Use Cases! — YourTechBud Codes19k views · 61 comments
- Jul 3, 2025Python AI Agents with Pydantic AI: Example & Interview with Pydantic Creator — AI with Lena Hall13k views · 1 comment
- Dec 5, 2024Pydantic AI: Build Production Grade Applications - NEW AI Agent Builder Framework! — WorldofAI11k views · 4 comments
- Apr 11, 2025Build a Slack Agent with Pydantic AI [Step-by-Step Tutorial] — AAIF Live1.7k views · 2 comments
18 more on YouTube
- Oct 11, 2026Pydantic AI: Python's AI SDK — RepoBytes | Find It. Understand It. Build With It.569 views · 2 comments
- Sep 28, 2026💸 [Repos That Shouldn't Be Free] pydantic-ai: The Free Tool Taking Over GitHub! #shorts — githubrepo_cloud488 views · 2 comments
- Oct 31, 2026Set Up Typed AI Agents in Python With Pydantic AI — CodeGlade177 views · 1 comment
- Dec 5, 2024GitHub - pydantic/pydantic-ai: Agent Framework / shim to use Pydantic with LLMs — GitHub Daily Trend AI Podcast114 views
- Aug 25, 202619K ⭐ AI Agents With Types, Not Just Chat — Github God Eng79 views
- Nov 7, 2026pydantic-ai - free open source tool — RepoDrop78 views
- Oct 21, 2026Pydantic Explained for AI Engineers + Pydantic AI Agents — Imad 4 Automation66 views · 1 comment
- Apr 17, 2025pydantic-ai/mcp-run-python at main · pydantic/pydantic-ai — GitHub Daily Trend AI Podcast63 views
- Aug 2, 2026PydanticAI: Build Production-Grade AI Agents with Type-Safe LLMs (Python) — Solopreneurs hub54 views
- Jul 30, 2026Pydantic AI Can Cap Every Agent Request — prompt cache44 views
- May 4, 2026Build a Working AI Agent in 60 Seconds (PydanticAI Tutorial) — AI Stack Daily43 views
- Aug 26, 2026Pydantic AI Passed Install Checks—Then Anthropic 1.0 Broke the Provider — Fluid Coding & AI40 views
- Sep 18, 2026This Framework Makes Your AI Agent's Output Actually Type-Checked — Agents on My Machine31 views
- Apr 11, 2026Pydantic AI : Building Type-Safe LLM Agents in Python — Blueprint Bytes23 views
- Apr 29, 2026Pydantic AI Full Setup: Build a Type-Safe Agent With Tools, Tests, and Evals — TechWealth Hub22 views
- Nov 21, 2026Pydantic AI — How Python Does AI Agents, Free & Open Source! — DailyDev AI17 views
- Oct 22, 2026Users find your agent's bugs first? Pydantic AI flags them — The AI Toolbox6 views
- May 12, 2026⭐ pydantic-ai — 17,025 GitHub Stars — Observe AI6 views
On Bluesky · 7
- Dec 11, 2024PydanticAI PydanticAI is a Python Agent Framework designed to make it less painful to build production grade applications with Generative… — @pythonhub.dev8 likes and reposts
- Aug 9, 2025I use 'llm' now for my cli explorations with genai. Will i move to `clai` for that "FastAPI feeling" they promise? i do love pydantic! see:… — @paulkarayan.bsky.social2 likes and reposts
- Dec 4, 2024🚀 Skyrocketing! 🚀 (200+ new stars) 📦 pydantic / pydantic-ai ⭐ 1,319 (+429) 🗒 Python Agent Framework / shim to use Pydantic with LLMs — @github-trending.bsky.social2 likes and reposts · 1 reply
- Sep 3, 2025https://github.com/pydantic/pydantic-ai — @tom-doerr.bsky.social1 likes and repost
- Jul 18, 2025📦 pydantic / pydantic-ai ⭐ 10,912 (+49) 🗒 Python Agent Framework / shim to use Pydantic with LLMs — @github-trending.bsky.social1 likes and repost
2 more on Bluesky
- Dec 6, 2024PydanticAI: Build production-grade Agentic AI apps in pure Python! PydanticAI offers the same elegance and ease of use as FastAPI, now… — @akshay-pachaar.bsky.social1 likes and repost · 1 reply
- Dec 4, 2024github.com/pydantic/pyd... — @presidentlin.bsky.social0 likes and reposts · 1 reply
On Hacker News · 5
- Apr 15, 2025MCP Run Python173 points · 66 comments
- Dec 2, 2024Agent Framework / shim to use Pydantic with LLMs7 points · 3 comments
- Dec 3, 2024Pydantic AI3 points
- Dec 6, 2024PydanticAI using Ollama (llama3.2) running locally2 points · 3 comments
- Dec 5, 2024PydanticAI1 point
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,196 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository48 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/AGENTS.mdAGENTS.md
- docs/harness/AGENTS.mdAGENTS.md
- docs/model_aliases/AGENTS.mdAGENTS.md
- docs/realtime/AGENTS.mdAGENTS.md
- .github/workflows/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/capabilities/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/durable_exec/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/models/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/models/anthropic/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/models/openai/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/native_tools/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/profiles/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/providers/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/realtime/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/toolsets/AGENTS.mdAGENTS.md
- pydantic_ai_slim/pydantic_ai/ui/AGENTS.mdAGENTS.md
- src/pydantic_ai_harness/AGENTS.mdAGENTS.md
- tests/AGENTS.mdAGENTS.md
- tests/benchmarks/AGENTS.mdAGENTS.md
- tests/harness/AGENTS.mdAGENTS.md
- adding-a-provider-api-featureSkill
- add-new-modelSkill
- adopt-prSkill
- branch-contextSkill
- complete-partial-prSkill
- docs-parity-reviewerSkill
- file-followup-issueSkill
- i-have-adhdSkill
- initialize-worktreeSkill
- poweruser-feature-auditSkill
- pre-push-reviewSkill
- pushing-commits-to-the-repoSkill
- refresh-issue-briefSkill
- testing-skillSkill
- building-pydantic-ai-agentsSkill
- migrating-agno-to-pydantic-aiSkill
- migrating-claude-agent-sdk-to-pydantic-aiSkill
- migrating-google-adk-to-pydantic-aiSkill
- migrating-langchain-to-pydantic-aiSkill
- migrating-mastra-to-pydantic-aiSkill
- migrating-openai-agents-sdk-to-pydantic-aiSkill
- migrating-pi-to-pydantic-aiSkill
- migrating-vercel-ai-sdk-and-eve-to-pydantic-aiSkill
- migrating-deep-agents-to-pydantic-ai-harnessSkill
- pydantic-ai-harnessSkill
- reviewerSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
28 rules. About 0 are common, 9 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 3
Read this before touching src/pydantic_ai_pax/.
- Distinctive: line 21
If a change needs the agent loop to behave differently, propose it in core.
- Very specific: line 200
Integrations are deferred: Only the coding loop and run plumbing are eager.
- Very specific: line 254
Default-on CLI .env loading is a deliberate exception to this repository-content trust rule: it assumes trusted launch and parent …
- Very specific: line 258
A load failure leaves the session as it was: Import, construction, or get_* errors are reported and the plugin stays unloaded.
- Very specific: line 305
Add the event dataclass and an on_* method (or a get_* method with a no-op default) to Plugin, and route it in _HANDLERS or collect.
- Very specific: line 308
Document it in PLUGINS.md in the table it belongs to, and in docs/declarative-plugins.md if it changes the design.
- Very specific: line 323
Every key mutates immediately and replace_items redraws.
- Very specific: line 349
Keep searchable field lists without eligible rows on type-to-filter with uppercase R reset.
- Very specific: line 350
Keep nonsearchable field lists without search and with lowercase r reset.
- Very specific: line 396
Do not define new palettes.
- Very specific: line 440
Do not add broad backwards-compatibility shim modules for internal file moves.
- Very specific: line 441
Keep documented plugin-author paths (pydantic_ai_pax.plugins and pydantic_ai_pax.commands) intact.
- Distinctive: line 459
Keep files concise - we don't need any 10,000 line files.
- Distinctive: line 463
Check whether an existing interactive command already completes the operation on Windows.
- Distinctive: line 464
If a new non-interactive path cannot observe completion because Pax must exit first, fail early with a non-zero status and name the working …
- Very specific: line 467
Add Windows-specific orchestration only when a concrete requirement cannot use the existing path.
- Very specific: line 472
When adding or modifying a Pax CLI UX feature, test every affected UX feature with your changes in a fresh tmux window before opening a PR.
- Very specific: line 478
Test a moment by loading the plugin with load_plugin and firing the event from the shell path that owns it (or LoadedPlugin.dispatch).
- Distinctive: line 486
Before adding, removing, or renaming a setting, changing its type, meaning, or default, or changing the SQL schema, consider upgrades, …
- Very specific: line 493
Add regression cases to tests/test_settings_compatibility.py and affected CLI tests using the previous stored format.
- Distinctive: line 496
Verify older databases load with documented defaults for missing settings and preserve existing preferences, plugin declarations, and model …
- Distinctive: line 501
Keep validation strict for known values, new writes, and plugin declarations.
- Distinctive: line 505
Verify rejected values and unsupported schema versions leave stored data intact.
- Distinctive: line 506
If a change introduces a migration, test failure rollback as well as success.
- Very specific: line 507
When a plugin setting's valid values or meaning depend on code other builds may lack, add a feature name to SUPPORTED_FEATURES in …
- Very specific: line 520
Run from the repository root.
- Very specific: line 627
Keep composer question state on its SessionRuntime, not on the shared terminal.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 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.
Files
Pax guide for AI code assistants
Read this before touching src/pydantic_ai_pax/. The repository-level AGENTS.md
still applies (no em-dashes, no Any, pyright strict, keyword-only arguments,
100% branch coverage). This file adds what is specific to the terminal shell.
What Pax is
A thin terminal around any Pydantic AI agent. It reads a prompt, runs the agent, streams the answer, and repeats. Everything beyond that is a plugin, including the default coding tools.
The three layers, and who owns what:
| Layer | Owns | Never does |
| Pydantic AI core | the agent loop, hooks, events, toolsets | know Pax exists |
pydantic_ai_harness | reusable capabilities (Coder, Shell, ...) | print to a terminal |
pydantic_ai_pax | the prompt loop, rendering, /commands, plugin loading | reimplement a core hook |
If a change needs the agent loop to behave differently, propose it in core. If it is a reusable behavior with no terminal in it, it belongs in harness. Only the shell itself lives here.
The plugin model
A plugin is a Plugin subclass, or a bare capability class. It is declarative
in the same way core's AbstractCapability is: every contribution is a method
with a default that contributes nothing, and a plugin overrides only what it
needs. get_capabilities for tools, instructions, and agent-run hooks (a Hooks
capability, or @on_event on your own capability); get_commands for
/commands; render for custom output; get_status_segments, get_spinners,
get_model_providers, and get_side_panels (pages the web UI shows beside the
chat); configure for a settings menu; on_session_start,
on_session_end, on_turn_start, on_turn_end, on_conversation_changed, on_command_end, on_plugin_load_failed, on_task_progress, on_fork_end, and on_install_progress for Pax's own moments;
prepare for async reads the get_* methods depend on. The
settings model is the class's type parameter (Plugin[Settings]), validated into
self.settings. self.host is a PluginHost, the plugin's runtime context
(console, conversation, session_id, status, full screen, saved settings, the
prompt through send_input/interrupt/complete, the saved sessions, the
delegated tasks, and read-only setting(KEY)); it
registers nothing. docs/declarative-plugins.md records the design.
PLUGINS.md is the user contract. If code and PLUGINS.md disagree, fix one so
they agree in the same PR.
Rules for the plugin API
- Declare, do not register. A plugin returns what it offers from
get_*methods, which the loader calls once per load (collect), after awaitingprepare(). No registration calls, no module-level dicts, no import-time side effects. Tests callload_plugin(PluginClass, host); it raisesTypeErrorfor a plugin that overridesprepare, whose tests callfrom_host, thenawait plugin.prepare(), thencollect. - One method per moment, one typed event per method. A handler never receives
*args,**kwargs,dict, orcontext: object = None. - No string sub-dispatch. A handler does not receive
event_type: strand switch on it. Use the event class as the key. - One async spelling. No
_syncor_asyncpairs. - Observers return
None. Deciders mutate the event (event.text = ...,event.cancel()). Nothing collects a list of return values. - Fail closed, one way. A raising handler on a decidable moment cancels the action and reports the error. No per-registration "fail open" flag.
- Sign in only when the user asks. Loading waits for every plugin and a run
waits for its tools, so neither may open a browser or wait on a sign-in. Use
plugins/sign_in.py: aSignInMethod(mcp.OAuthSignInfor MCP OAuth),sign_in_nowfrom a menu or/NAME login, and no tools while signed out. - A built-in's per-run capability is a
WorkspacelessCapability. A bare capability function might return a sandbox, solocal_workspace()attaches the launch directory only after everyfor_run, and harnessSkills(which reads its libraries infor_run) fails the turn. Wrap a function that never returns a workspace inruntime/session.py'sWorkspacelessCapability. The one exception is a built-in that moves some conversations elsewhere, assandboxdoes: subclassConversationWorkspaceand answersuppliesfrom the run's own history, the same historyget_workspaceresolves from. Answershell_line_workspacefrom that history too, so!lines run where the runs do. - Pax moments are
on_<subject>_<moment>(on_turn_start). Core hooks stay core's, reached through aHookscapability. Do not wrap a core hook in a plugin method. - Payloads are kw-only dataclasses. Not
BaseModel. Pydantic is for the settings JSON boundary only. - No
getattr/hasattron a plugin to discover what it supports. It returned the thing from aget_*method or it did not;has_configureandhas_rendercompare against the base-class default. - Only shell-owned moments.
on_session_start,on_session_end,on_turn_start,on_turn_end,on_conversation_changed,on_command_end,on_plugin_load_failed,on_task_progress,on_fork_end,on_install_progress. Startup load failures happen before an agent run, so core'sbefore_runcannot observe them. The loader reports them after trying every enabled plugin so observability can receive failures that preceded its own load. Which conversation the shell holds, and its title, change between runs (/new,/resume, background naming); core only sees aconversation_idper run.Session._publishis the one placeConversationChangedis fired from./commandsnever reach the agent, so no core hook sees them; the shell firesCommandEndaround_execute_command, outside the scope Esc cancels: a refused/pluginsfires its refusal instead, and a cancelled command fires nothing. A delegated task's own events never enter the parent run's stream, and a background task outlives that run, so no hook of the parent sees them;Tasks.observe, the harness owner's one observer, firesTaskProgress. A/forkruns a separate session in the background, so its run's hooks belong to that session and nothing of the parent sees it end;Forks._runfiresForkEnd./update nowis a command, so no core hook sees its install either, andCommandEndcomes only once uv has finished;Updates.commandfiresInstallProgressas it goes. Additional moments need the same justification: say which core hook you checked and why it does not fit.
Loading and unloading
Plugins load and unload while Pax runs. The rules that make that safe:
- One
LoadedPluginper plugin. It holds the instance and what itsget_*methods returned, so unloading is "discard thisLoadedPlugin". Nocallback -> ownermap, no scanning registries for a plugin's name. - A running agent run never changes its plugins. Core binds capabilities once
per run, so
/plugins(anargs_during_turncommand) may load and unload mid-turn, but the run keeps the snapshotrun_turnbound.SessionPlugins.turn()deferson_session_endof plugins unloaded meanwhile until the run is over, shielded from cancellation. Do not swap capabilities inside a run; that needs core support. - Plugins are per live session; declarations are per process. Each live
session's
SessionPlugins(plugins/loader.py) holds its loaded instances, guards, and deferred ends, and is itshost.plugins. They all join the process'sProcessPlugins(plugins/process_plugins.py, held byClaiProcess): declarations, staged/plugins addsettings, open settings menus, the change lock, and imports.enable,disable,remove, andreloadrun in the session they came from under that lock (ProcessPlugins.change), then every other live sessionfollows them, also when the origin failed;/plugins addand settings edits are followed once saved. Each session follows under theturn()rule above.PluginLoaderis the former name ofSessionPlugins, kept for tests; built withstore=and noprocess=, it gets a process of its own, as one-session hosts do. Plugin.scope = 'process'builds a plugin once per process.observability,workspaces, andwebare. The first session to load one builds it and fireson_session_start; it then joins every live session (capabilities, commands, and each moment, dispatched per session withhost.live.current()naming it). It ends once, when unloaded (after every running turn that bound it) or when the last session closes; sessions load a name one at a time, so it is built once. Its host'ssession_id,workspace,tasks,plugins,setting,send_input,submit_prompt,interrupt, andask_in_composerfollow the session being handled (moments, commands, and runs set it); its other attributes are the loading session's.restartkeeps it. A process plugin that includes a session plugin (webandask_user) keeps it off in every session.Plugin.scope,host.live, and theLiveSession/LiveSessionsprotocols are public:PLUGINS.md's "Several live sessions" is their contract, with the six rules every plugin follows. Change them as public API, and update that section in the same PR.- A process holds many live sessions; a conversation is live in one.
ClaiProcess.live(runtime/live_runtimes.py) ishost.live.create_shelladds eachSessionRuntimeandSessionRuntime.closeremoves it; close a runtime withclose, never withloader.closealone.openreturns the session already holding a conversation, andSession.resumerefuses one another session holds or is resuming (LiveRuntimes.claim). Sessionsopenandnewstart run as tasks ofserving, in their own directory, withInterrupts(signals=False), refuse/reloadand/update nowunless the terminal shows them (only that session, or the one Pax started with, restarts it, never from another folder or while another session runs a turn, and a failed/reloadcontinues the shown session's conversation), and close afterIDLE_AFTER(an hour) with no turn, command, queued input, fork, task, watcher, or terminal focus./setof anything butmodelandrun.*reaches every live session (CommandContext.adopt) unless its project file sets it. There is no turn cap. - Per session on
SessionRuntime, per process onClaiProcess; never the other way.ClaiProcess(runtime/process.py) holds what exists once: the stores,ProcessPlugins, the task owner and router, the namer, the Codex providers, andlive.SessionRuntime(runtime/session_runtime.py) holds what each live session has: itsSession, commands,SessionPlugins, status, interrupts, input queue, forks, and folder (Session.workspace, which plugins read ashost.workspace).Terminalholds what only the terminal has, whichever session it shows. A per-session value onClaiProcessleaks between sessions; a process value on a runtime is built twice or closes with one session. Module-level mutable state is process state too, so keep it off modules. Never callos.chdiror readPath.cwd()for a session's folder after startup: passSession.workspace(orhost.workspace).Path.cwdstays only as the default of hosts built outside the shell, and for--worktreesetup and cleanup around the session. - The terminal shows one live session at a time.
Terminal(ui/prompt/terminal.py) owns the terminal console, theLivePrompt, the line prompt, the transcript, input history, and pasted images. Only the session shown (SessionRuntime.terminal,LiveRuntimes.focused) reads the editor, prints to the console, and takes Ctrl+C (Interrupts.focus); the others print nowhere (Terminal.session_console) and read their inbox.chatsetslive.build, so the web UI opens sessions beside the terminal's./resumeof a conversation another live session holds shows that one (Sessions.show_live), mid-turn too, and never forks it; the one shown before stays live, and the session Pax started with is closed for idleness like any other while hidden. Prompts queued for a session stay its own when the terminal shows another.pax --webkeeps its terminal on the session it started with. With one live session nothing changes, and the toolbar addsN liveonly for more. - Load runs
on_session_startfor that plugin; unload runson_session_end. A plugin cannot tell whether it was loaded at startup or later, and must not need to. reloadis unload, re-import, load. Drop-in entry modules use fresh source. Installed modules useimportlib.reload, which retains globals absent from the new source. Plugins keep their state on the instance, set up in__init__.- Instruction order is capability order. Placement is a core
CapabilityOrdering(position,wraps,wrapped_by), not a Pax list. - Registration is idempotent per name. "Active for the next prompt" is the
natural unit. Stock agents are rebuilt when the capability snapshot or Pax's
unchosen default model changes. Plugins are bound at construction so
self-delegation carries their tools, instructions, and guardrails, and the
default model is bound as the agent's own so a capability can replace it.
Supplied agents still receive plugins per run (
agent.run(capabilities=...)) and are never rebuilt. - Shipped plugins register first, in declared order. The menu's alphabetical
order is for scanning only. Registration order is the order instructions,
renderers, and status segments are consulted in, so
coder's guidance leads the prompt. - Integrations are deferred. Only the coding loop and run plumbing are eager.
The agent docs capability (
pax_customization) and every hosted integration plugin passdefer_loading=Trueon the capability they build (on the one afor_runfunction returns, never on theDynamicCapability), so each costs one catalog line until the model callsload_capability. A new integration does the same. - Built-ins are declarations, not code paths.
DEFAULT_PLUGINSinconfig/builtins.pylists the library's built-ins (re-exported byapp.py, kept apart sopax pluginscan toggle one without importing the shell);STOCK_PLUGINSopts the CLI-owned agent into delegation without changing supplied-agent defaults. Pax ships enabled (coder,ask_user,repo_context,compaction,persistence,observability,hooks). The loader treats them like drop-ins with the lowest precedence: a store declaration with the same id replaces one,disablepersists an override,removeresets it. Do not special-caseCoderanywhere else; the agent fromcreate_agent()has no coding tools of its own.coderis declared withrepo_context: falsebecauserepo_contextbinds harnessRepoContextitself; keep it that way orAGENTS.mdreaches the model twice. When a built-in takes the id of a row the former harness catalog offered, add that old row toRETIRED_BUILTINSinplugins/process_plugins.py, so a user's saved toggle of it maps to the built-in instead of outranking it. open_stock_agentloadscoder,repo_context, andcompactiononly. Add a built-in to that list only when it needs no terminal and reads nothing from the user's Pax configuration directory. Hosts rely on a configuration that the user's saved settings cannot change.- Project declarations rank just above built-ins and start off.
.clai/settings.json(project_settings.py) may declare plugins; the loader takes them asproject=, every oneenabled=False, because a repository must not run code as the user on launch./plugins enableis the approval and persists the approved declaration in the store. Precedence is store, drop-in folder, project, built-in. Pax never writes the project file. The exception is a factory inAPPROVED_AS_WRITTEN(plugins/process_plugins.py), such as thehookstable'sproject_hooks: its declaration is what runs, so a stored approval with the same id and factory that differs from the project's is stale and the project's, off, replaces it. A drop-in or a user's own plugin under that id is never replaced./plugins enablealso records the SHA-256 of each repository file the declaration runs (ProcessPlugins.project_files: a file plugin's own file, and the programs inside the project ahookstable runs) in the store'sapproved_filestable, besidepluginsso older builds never read it. AnAPPROVED_AS_WRITTENapproval whose files differ is stale too, andimport_modulerefuses a project file whose bytes differ, executing the bytes it checked.HooksPlugincompares each program at spawn with the approved contents (read throughhost.settings_database), stopping abefore_toolcall on a mismatch.approverefuses a file it cannot read, so an empty digest never matches. - Project settings beyond display wait for approval.
.clai/settings.jsonkeys inSAFE_PROJECT_KEYS(display.*) apply at once; every other key ispendinguntil/project approvestores that exact value for the project root in the store'sapproved_project_settingstable, so a changed value waits again. A newSettingsfield waits too unless added there on purpose. Arun.permissionsno wider than the user's own applies at once, since it cannot widen anything.update_channelis user-only, rejected in a project file. Approval is a/commandonly, never apaxsubcommand, because the agent can runpaxfrom its shell. For the same reasonpax configrefuses a changewidens(refuse_widening), andpax pluginsonly lists. Unapprovedinstructionsgo to the model asProjectInstructionsuser-channel data, never asSession.instructions. Default-on CLI.envloading is a deliberate exception to this repository-content trust rule: it assumes trusted launch and parent directories, without plugin approval. Environment variables documents the scope and opt-out. - A load failure leaves the session as it was. Import, construction, or
get_*errors are reported and the plugin stays unloaded; nothing it declared is kept. When construction succeeded,on_session_endruns withreason='error'under a shield with a five-second cooperative timeout before a failed/cancelled load drops the plugin. Cleanup must tolerate an incompleteon_session_start.
Overlapping plugins go in the compatibility matrix. plugins/compatibility.py
maps a plugin's factory to the factories it already includes, each with the
capability classes it must bind for that to hold (coder includes harness
SubAgents while it binds one, which it does with sub_agents on, and
compaction only while it binds a history compaction, which it does not, so
both run by default). While the including plugin is loaded, the
loader keeps the included ones unloaded and refuses to enable or configure them, and /plugins
greys their rows out. Their saved enabled flag is untouched, so turning the
including plugin off loads them again. Add a row there; do not special-case ids.
Compaction registers harness FallbackCompaction directly with max_fraction
and context_window for both strategies. Harness owns the trigger; do not add
threshold math or an orchestrator in Pax. Register the usage gauge after the
chain so yellow means the compacted request still exceeds the threshold.
/compact drives the same chain regardless of threshold, keeps the result only
when harness estimate_message_tokens (provider-reported usage) says it shrank,
reports the saving out of the status row's estimate_context_tokens figure (capped at the per-message sum), and passes runtime/agent_instrumentation.tracer() so it is traced. Only ModelAPIError,
FallbackExceptionGroup, and UsageLimitExceeded select truncation after a
summary failure; other exceptions propagate. Its configure is a FieldMenu
over CompactionSettings; the loader's reload builds the new chain. Background
compaction is harness FallbackCompaction(background_start=...), not Pax code: the plugin
only passes the setting, closes the chain in on_session_end, discards the summaries of
conversations other than the shown one and its running tasks at each turn end and conversation
change (not per task event, which would build one for every streamed event), and has /compact try the
chain's take_background_compaction (without a focus) or discard_background_compaction
(with one) before the capped chain. The status
row's window does not depend on it: Session.on_context_window reports each
streamed request model's window, and the shell fills it in when no gauge has.
Until a turn on the selected model runs in the conversation, show_model sets
Status.model_window from the window /model settings saved for it, else its profile
(infer_model_profile; a plugin model's from
its settings_from provider's), which the row and web UI show while context_window
is None; after one, an unresolved window stays ?. A window /model settings saved for a model
reaches compaction and the row through SavedContextWindows, an outermost capability that wraps each
step's model in ContextWindowModel; never apply it in ModelResolver, where building the model would
skip the run's other resolvers. A conversation without a figure
yet, such as a resumed one, reads its last response's context_tokens.
Adding or changing a Pax moment or contribution
- Add the event dataclass and an
on_*method (or aget_*method with a no-op default) toPlugin, and route it in_HANDLERSorcollect. - Fire it, or read the collected value, from exactly one place in the shell.
- Document it in
PLUGINS.mdin the table it belongs to, and indocs/declarative-plugins.mdif it changes the design.
The /plugins, /set, /theme, /model, and /model add menus
Built on termflow's MenuBuilder (and TextInputBuilder for typed values),
exactly like Code Puppy's /agent, /mcp, /set, and /model menus:
alternate screen, a .preview panel on the right, markdown_style() for
colours. Single-key actions and the key legend go through slash_search's
hotkeys and footer in a searchable menu, .on_key and .footer_hint in
one that is not.
- Split it in two: a pure
build_plugins_menu(...)that returns the menu (so tests drive it headless, no terminal), and a thin async runner that owns the screen and callsmenu.runin a thread. - Every key mutates immediately and
replace_itemsredraws. No pending-changes state, no save/cancel pair. Settings menus still end with a Save & close row (save_and_close_item(), recognized bypicked(result)) that only leaves;FieldMenu,/keys, and/pluginsadd it for you. - Turning a plugin on opens its
configuremenu. A widget cannot open from inside another menu's key handler, soPluginMenucloses with aConfigureresult andopen_plugins_menuruns the settings menu, then reopens the list. - Enter performs the highlighted row's primary action (
/pluginstoggles, like Space) and never silently closes a list menu. Termflow's default Enter selects the row and closes, so where that is not the row's action, bindenteras a hotkey that does the action, or nothing; Esc closes. - Footer hints separate actions with
-and capitalize named keys (Enter,Esc,Space); letter hotkeys stay as typed (c configure,R reset). Modifier keys join with+(Ctrl+C,Ctrl+X Ctrl+S,Cmd+Shift+Z) in footers, dialogs, help text, and docs alike;ctrl-cis only a key name in code. - Nothing prints to the console while the menu is open; the alternate screen would hide it. Show empty states and errors inside the menu as disabled rows.
- Esc and Ctrl+C close cleanly. They are not errors.
- Make a new or changed menu searchable with
slash_search(ui/menus/slash_search.py), not a bare.searchable(): plain letters stay hotkeys,/starts a search, Esc leaves it. Pass single-key actions as itshotkeysso they type into the search instead of firing while the user searches. For searchableFieldMenulists, useslash_searchonly when a row offers Space cycling. Eligible rows have multiple declared choices and no action/submenu mapping. Cycle choices in declaration order and wrap. Start at the first choice when the current value is absent or unlisted. Keep searchable field lists without eligible rows on type-to-filter with uppercaseRreset. Keep nonsearchable field lists without search and with lowercaserreset. - A widget opened mid-run (including the standalone inline
ask_userpicker) goes insideasync with host.full_screen(), which flushes streamed text and suspends the editor's input reader first, preserving its draft. Slash-command handlers already run with the editor suspended. Composer questions and approvals use its existing reader throughPromptQuestions. Do not start a second input reader alongside the live editor. - Adding a plugin is not in the menu. It needs free text, so it stays
/plugins add ID MODULE[:ATTR] [JSON]or/plugins add GIT_URL. Git installs use the existing file loader, with HTTPS/SSH for network sources; seePLUGINS.mdfor the repository layout, trust boundary, and checkout management. - Anything that is "edit named, validated fields" uses
field_menu.py: aFieldSourcesupplies rows, current values, validation, apply, and reset;FieldMenubuilds the widgets;run_flowis the loop./setand per-model settings are two sources, not two editors. Do not write a third editor. /setedits go throughCommandContext.set_setting/reset_setting, the same path as the typed command, so validation lives in one place.- Multi-line text goes through
text_editor.edit_text:$VISUALor$EDITORon a temporary file, else (on Windows, unset, or failing to start) a built-in prompt_toolkit editor, since termflow has no multi-line input. Call it from a menu worker between widgets, or ask withDialogs.text(multiline=True)from a settings menu action, which the web UI shows as a text area. Do not write another editor. - Widget runners are a
Runnersvalue passed into the loops; tests pass scripted ones (tests/menu_script.py). Only the realwidget.run()one-liners areno cover. Code that asks throughDialogs(settings menu actions,plugins/keys.py,plugins/sign_in.py) is tested withtests/pax/dialog_script.py'sScriptedDialogsinstead. - Model sources live in
model_catalog.py. To add one (models.dev, a provider API), write a function returningCatalogModels and merge it incatalog(). The menu never talks to a source directly. - Per-model settings are the editable subset of core's
ModelSettings, declared once asModelSettingsFormwith descriptions and bounds. Extend the form, not the menu, to expose another setting.
Rendering
StreamRenderer owns text and thinking. It knows nothing about any specific
tool. Tool-specific output (shell previews, diffs, grep) comes from render on
the plugin that owns the event. Match on event classes, never on tool_name
strings. Always flush the stream before printing anything else; the shell does
this for renderers, so do not call console.print from an event hook when a
renderer would do.
Colours
/theme offers the unchanged default appearance and termflow.themes.PALETTES.
Do not define new palettes. Resolve brand roles with theme.color(...) for Rich;
theme.sgr(...) resolves raw ANSI itself. A theme change repaints retained
transcript lines by translating these roles, so colour output through them,
and print logo branding inside theme.branded() so it keeps its colours.
theme.current() returns a Termflow palette or None for the original appearance. Termflow owns palette application
and reset; theme.use(...) leaves the terminal untouched in the default session.
Markdown keeps its original style by default and uses to_render_style() for a
selected palette. The preview renders a sample without OSC changes or persistence.
Heavy imports in theme.py stay lazy for the splash. Code uses the terminal
foreground and ANSI syntax colours through theme.syntax_theme(), shared by
streamed fences, shell command headers, and theme previews. Shell command headers
add dim and drop underlines over the lexed code (command_syntax._SECONDARY), so
a tool call reads as secondary; keep fences unchanged. The default theme's diff lines use a dark green and red;
bundled palettes get diff lines from theme.diff_renderer(), tinted
from the palette until their lightness differs, so colour-blind readers can tell them apart.
On a light terminal (app.chat asks for the background once, ui/terminal_background.py, and
passes it to theme.use(background=...)), default paints brand roles in the fixed theme._ON_LIGHT
shades and diffs on pale lines with Pygments' xcode style; code fences keep the terminal's ANSI
colours. On a dark or unknown background it is unchanged.
theme.color() and theme.syntax_theme() raise a palette colour to WCAG AA contrast
(or the palette's own text contrast); test_theme_preview.py checks both for every palette.
Echo the user's own text through rendering.prompt_line, which paints it on
theme.prompt_background(): under a palette, its background moved towards its text, on a truecolor
terminal only (theme.truecolor(), as theme.sgr decides). The default theme has no tint, on a light
terminal background as on a dark one.
Source layout
The package root composes the shell (app.py, __main__.py) and keeps the
plugin-author imports pydantic_ai_pax.plugins and pydantic_ai_pax.commands
stable. Other code is grouped by responsibility:
cli/owns argument handling, command context, headless output, and shell passthrough.config/owns settings, credential storage, and project declarations.config/__init__.pyprovides the existingpydantic_ai_pax.configsettings API.runtime/owns sessions, forks, worktrees, reload, and speculative turns.models/owns model discovery, settings validation, and optional provider adapters. Pure model parameter expansion belongs here, not in a menu.ui/prompt/owns editing, terminal input, surface painting, and resize.ui/menus/owns widgets and command-specific pickers;ui/rendering/owns themes, streaming, status, and output formatting.plugins/owns the host API, loading, and credential picker helpers.builtin_plugins/andmcp/retain their plugin and server boundaries.
Move a capability to core or harness if it does not need a terminal. Keep UI
imports out of reusable validation code. The CLI and app may compose these
packages; new package initializers should not eagerly import the app or heavy UI.
Do not add broad backwards-compatibility shim modules for internal file moves.
Keep documented plugin-author paths (pydantic_ai_pax.plugins and
pydantic_ai_pax.commands) intact; update example imports when moving UI helpers.
The package was pydantic-clai2 until it became pydantic-ai-pax. The pydantic-clai2 shim in
src/pydantic_clai2/ depends on it and alone owns pydantic_clai2/, which aliases
pydantic_clai2.X to pydantic_ai_pax.X and holds the deprecated clai2 command. PluginSettings renames a pydantic_clai2
factory as it validates, and SettingsStore.save_plugin stores factories under pydantic_clai2,
which older builds sharing the database still import. The clai2-bleeding release keeps the old
name so existing installs keep updating. The keyring service is pydantic-ai-pax: credential_store copies an
encryption key saved under pydantic-clai2 and keeps the old entry for older builds, and older per-entry logins are
still read from pydantic-clai2. The config and state folders moved to pydantic-ai-pax: paths.py moves a
pydantic-clai2 folder on first use and leaves a symlink, so older builds still share it.
File map
FILE_MAP.md lists what each module holds. Read it to find where a change belongs,
and update its row when you add, move, or change the responsibility of a module. It
is kept out of this file because this file is sent with every request.
Keep files concise - we don't need any 10,000 line files. Single responsibility.
Windows-only CLI operations
Check whether an existing interactive command already completes the operation on Windows.
If a new non-interactive path cannot observe completion because Pax must exit first,
fail early with a non-zero status and name the working command. Do not report success
for a detached operation or add a process trampoline just to make the new path work.
Add Windows-specific orchestration only when a concrete requirement cannot use the
existing path. For updates, /update now is the working interactive path.
Testing
- When adding or modifying a Pax CLI UX feature, test every affected UX feature
with your changes in a fresh tmux window before opening a PR. Run Pax with
uv run pax. Verify the actual terminal behavior against the intention of the user's request, not just the implementation or automated tests. pytest-anyio; real model calls are blocked globally.- Drive the shell with
TestModeland aConsole(file=StringIO()). - Test a moment by loading the plugin with
load_pluginand firing the event from the shell path that owns it (orLoadedPlugin.dispatch). Assert the handler's effect (the cancelled turn, the rewritten text), not a mock call count. - Renderers get synthetic events. They must not need
Coderinstalled. - Cancellation: use a real
anyiocancel scope, order withEvents, no sleeps.
Settings and database compatibility
Before adding, removing, or renaming a setting, changing its type, meaning, or default, or changing the SQL schema, consider upgrades, downgrades, and branch switches. Different versions can share the same settings database.
- Adding a setting needs no API compatibility waiver:
SETTING_FIELDSandSTRING_SETTINGSaregrowing_collectionsin.github/api-compatibility-allowlist.json. Removing or renaming one still needs a deprecation and a waiver. - Add regression cases to
tests/test_settings_compatibility.pyand affected CLI tests using the previous stored format. Keep historical fixtures unchanged; do not regenerate them with current models or rewrite them to make a change pass. - Verify older databases load with documented defaults for missing settings and preserve existing preferences, plugin declarations, and model settings. Test migrations and repeated initialization for data preservation and idempotence.
- Preserve unknown saved setting names and their values when reading, editing other settings, resetting, and reopening. Unknown does not mean obsolete. Keep validation strict for known values, new writes, and plugin declarations.
- For renamed fields or changed types, meanings, or defaults, define the migration
or intentional behavior change and test it explicitly. Comparing only against
the current
Settings()defaults will not catch an unintended default change. - Verify rejected values and unsupported schema versions leave stored data intact. If a change introduces a migration, test failure rollback as well as success.
- When a plugin setting's valid values or meaning depend on code other builds may
lack, add a feature name to
SUPPORTED_FEATURESinconfig/features.pyand tag the setting (host.settings(Model, requires=...), orCAPABILITY_REQUIREMENTSfor amodule:Classcapability). Tags live in theplugin_requirementstable; never add a field toPluginSettings, a key to itssettings, or bumpuser_version, since older builds reject all three. A build lacking a feature drops only that setting and uses the default. Run setupUserErrors are caught only byPluginGuard, and only around a capability Pax built from amodule:Classdeclaration's settings with noHooksinside, so policy hooks and plugin-contributed capabilities always fail closed. See "Settings that need a feature" incustomization.md.
Local verification
Run from the repository root. Pax shares the root uv.lock, .venv, and
Pyright configuration with Harness.
uv sync --locked --all-packages --group lint
uv run --no-sync ruff format --check .
uv run --no-sync ruff check .
PYRIGHT_PYTHON_IGNORE_WARNINGS=1 uv run --no-sync pyright src/pydantic_ai_pax tests/pax
uv run --no-sync pytest -p no:cacheprovider tests/paxDocs parity
README.md is the product tour, docs/reference.md is the user reference,
PLUGINS.md is the plugin contract, and this file is for agents. A user-facing
change updates the reference (and the README when it changes what the tour shows)
and PLUGINS.md in the same PR. The README is the PyPI page, so its links and
images are absolute URLs on main; scripts/screenshots/capture.sh regenerates
the images in docs/images/. docs/harness/pax.md is the same story as the README on the docs site, not a copy of it:
edit both, keep code blocks identical, and see the "Pax front pages" section of
docs/AGENTS.md for which link and model styles each one takes. Plain
language, short sentences, no jargon a first-time plugin author would not know.
Agent-readable docs are indexed by pax_docs._PAX_DOCS. Docs outside
pydantic_ai_pax/ ship through pyproject.toml's wheel force-include and sdist
include. The catalog and packaging guards in tests/pax/test_pax_docs.py
reject new docs missing from either surface. If a new feature falls outside the
existing discovery triggers, update pax_docs._DESCRIPTION and _hint.
The resume browser is a focused exception to the single MenuBuilder convention:
it needs independently focused projects/sessions and two-line cards. Keep its
frame pure, inject keys/size/IO, use Termflow terminal ownership and layout, and
run through menu_worker. Metadata refreshes must preserve selection by ID.
/tasks is the other exception: a termflow.live app, because a transcript that
streams beside an input needs a frame loop. Its actions are Ctrl chords, since
letters type the message. Keep TaskView free of the terminal and the event loop:
snapshot, act and size are injected, and tests pass open_tasks a scripted run.
History-changing plugins use await conversation.commit_messages, not the legacy
in-memory replace_messages, so exiting immediately after /compact is durable.
The interactive editor owns its layout explicitly. Do not reintroduce a
PromptSession renderer. PromptSurface starts inline on the main screen, repainting
only the rows the terminal's scrollback lacks plus the editor, and switches to the
alternate screen for good once they would fill the terminal, the terminal narrows,
widens, or shrinks, or release(turn_running=True) hands the terminal over mid-turn.
Released between turns, it erases its rows and prints the transcript into scrollback
as it arrives (_print_released), keeping no rows, since a command may write to the
terminal directly; it cannot do that mid-turn, when a streamed part may still grow.
display.full_screen (LivePrompt(full_screen=True), PromptSurface.full_screen)
starts on the alternate screen; tests that need fixed frame rows use it. The inline
phase pushes only KEYS_ON, never mouse reporting, so the terminal keeps its own wheel
scrollback and selection; it shows every unprinted row, so it has nothing to scroll and
follows. It erases its rows by moving up the count it painted, which a terminal that
reflows text, or pushes rows into scrollback as it shrinks, or anything else writing to
the terminal would invalidate, hence the switches. Do not let anything but PromptSurface
write to the main screen while inline rows are up.
The rules below about scrolling, the mouse, and resizes are the alternate screen's.
On the alternate screen it composes a termflow.live ScreenBuffer,
TranscriptView draws its transcript region, and render_diff paints changed
cells. Do not invent a parallel canvas. The hardware cursor stays hidden;
the input cursor is a painted reverse-video cell. Keep terminal mutations in
PromptSurface, and detach the key reader before a menu owns the screen.
The prompt-toolkit decoder preserves paste, modified keys, and SGR mouse reports.
PageUp/PageDown and wheel input scroll the transcript, not the draft.
Wheel and drag reports arrive in bursts, so they paint once after the input
callback (PromptSurface._paint_soon), never once per report.
An idle session must cost next to no CPU, since users keep dozens open. The
editor's timed repaint (LivePrompt.tick) runs ten times a second only while a
turn runs or the panel animates, and once a second (IDLE_REPAINT) otherwise,
sleeping in between; a read wakes it, since the work it starts animates.
PromptSurface.paint skips a frame identical to the last one. Input, output,
and resizes paint at once; output inside a frame interval paints when it ends
(PromptSurface.changed), without waiting for a tick. Do not add a timer that
repaints unconditionally, or one that wakes an idle editor more than once a second.
Mouse reporting stops most terminals from selecting text, so a left-button drag,
double-click (a word) or triple-click (a line) selects painted cells in PromptSurface,
and its release copies them through text_clipboard.copy_text. Do not drop the drag modes
(?1002h) or copy-out breaks. Words, lines, and copies join rows only where
TranscriptView.joins says a row wraps on; rows Rich wrapped are separate lines.
Resize rebuilds from TranscriptBuffer, not guessed row coordinates or cursor
reports. Never send erase-scrollback (CSI 3 J). Preserve the draft and scroll
anchor. SIGWINCH invalidates the next frame; it must not perform terminal IO.
A MarkdownBlock shows its streamed rows until its writer calls end, and
renders its source again only after that: rendering a streaming part again per
frame costs the whole part every frame.
Full-screen menus leave the live panel temporarily. Composer questions keep its
reader and focus until the user explicitly focuses the question. Standalone
questions borrow the released panel with run_worker(inline=True) and pin the
question text in their rows, not the transcript, so output streamed meanwhile cannot push it away. Streamed text and thinking keep Markdown source,
a tool-call group its call names, and a shell call's header its command, for width/theme repaint
(syntax colours share hex values with brand roles under a palette, so translating them would guess;
a part still streaming is translated like tool output until it ends, then renders again);
tool output keeps styled lines, each tagged with the
theme that painted it, and recolor.py translates them role by role (theme.roles)
when the theme changes. On exit, restore
prints retained output into native scrollback once, skipping startup output
already printed there. Transcript memory is bounded, including Markdown parts.
Reload rebinds the retained transcript and its nested classes in place after a
successful shell rebuild, including migration from the pre-live Text-line buffer.
The suspended chat coroutine still holds that transcript; do not only replace
it on the new shell or mutate it before a rebuild that can fail.
The standalone ask_user picker, the default, borrows the released PromptSurface while the editor
is suspended. Keep its numbered choices and Enter toggles; do not switch screens inside the picker or
reintroduce Space-to-toggle. With input.questions=composer, the effective send binding toggles choices;
Ctrl+J inserts a newline in custom answers (it steers on Windows) and never confirms a choice.
Keep composer question state on its SessionRuntime, not on the shared terminal.
Generic send, steering, and remembered question routing never authorize tools.
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
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.

