Pyagent is an open source, multi-provider LLM agent framework — a terminal chat assistant and an embeddable Python library, built around an agent loop you can actually read. It is available under the MIT license.
Why I Built It
I wanted to understand how agent loops, tool calling, and orchestration actually
work — not by reading a large framework’s source, but by building the pieces
myself. Pyagent is the result: an explicit Agent.run() loop with no LangChain
and no agent-DSL, where every part is small enough to read top to bottom.
It works two ways. pyagent launches a terminal chat that can read files, run
shell commands, search the web, and call any tool you add. Or
from pyagent import Agent embeds the same loop in your own app, notebook, or
service. Bring your own model — Anthropic, OpenAI, Gemini, or a local Ollama.
What’s Inside
- Tools are plain Python functions. Type hints and docstrings become the tool schema — no hand-written JSON schemas.
- Cache-aware prompts. The system prompt is split into stable and volatile halves so provider caches stay warm across turns.
- Plugins, skills, and subagents. Plugins register tools and prompt sections; skills are lazy-loaded “how do I” docs the agent reads on demand; subagents are focused child agents with bidirectional communication and parallel dispatch.
- Memory. A user ledger plus a memory index with semantic recall, auto-loaded into the prompt.
- Multi-model. Switch models mid-session, or assign named model roles per subagent.
Tech Stack
- Python 3.11+ — core language
- Anthropic, OpenAI, Google Gemini, and Ollama — pluggable model providers
- fastembed — local embeddings for memory recall
- Rich — terminal REPL rendering
Check out the repo for installation, docs, and architecture diagrams.
