Skip to content

Developer guide

Language: 简体中文 | 日本語 | 四川话 | English

For contributors and anyone hacking the library. End users should start at the documentation home or Quick start.

Layout

text
src/pagent/     v1 library
src/pagentv4/   v4 library (core, runtime, sandbox, skills)
src/app/        application layer (REPL, CLI) on top of pagentv4
examples/       runnable demos grouped by category (see examples/pagentv4/)
tests/          pytest
docs/           documentation

Core: agent.py, session.py, llm.py, tool.py, tokens.py, events.py.

Capability map

ModuleNotes
SessionOpenAI-shaped messages; SlidingWindowSession trims by tokens; CompactingSession LLM-compresses history
LLMinvoke / invoke_stream; returns RunEnd
Agentrun / arun / arun_events / arun_wire
tokenscount_tokens, count_tokens_detail, format_context
events / wireUI timeline — events.md, wire.md

中文完整表:开发指南

Out of scope

Parallel tools, RAG, MCP, built-in file/shell tools, multimodal, checkpoints — build in your app.

Planned: Hooks support plan (lifecycle hooks for tool approval, cancel, context injection; distinct from Event/Wire).

Local development

Uses uv for env management. New to uv? See the official docs.

bash
uv sync --group dev --extra search
pip install -e ".[search]"
pre-commit install
pytest -q

Documentation site

Built with VitePress. Config: docs/.vitepress/config.mts, content: docs/*.md. Mermaid diagrams use vitepress-plugin-mermaid (fenced ```mermaid blocks).

For coding agents / LLMs: agent-reference, repo AGENTS.md, llms.txt, llms-full.txt (npm run build:llms in docs/ regenerates the bundle).

bash
cd docs
npm install
npm run dev            # http://localhost:5173/pagent/
npm run build          # output in docs/.vitepress/dist/

Node tooling lives under docs/ (package.json, package-lock.json) so the repo root stays Python-only.

Do not commit docs/.vitepress/dist/ or site/ — they are in .gitignore. Only Markdown sources under docs/ live on main.

On push to main, docs.yml runs npm run build in docs/ and publishes docs/.vitepress/dist/ to the gh-pages branch. Enable in repo Settings → Pages → Deploy from branch → gh-pages / root.

Publishing

.github/workflows/publish.yml — PyPI via Trusted Publishing on release.

See also

Released under the MIT License.