A general-purpose AI Agent framework in Rust, built on agent-base and agent-works.
phi-agent provides the infrastructure. You bring the tools.
Monorepo
This repository contains the full phi-agent ecosystem as a Cargo workspace:
Just need the runtime? cargo add agent-base. Need the full framework? cargo add phi-agent.
Architecture
┌─────────────────────┐
│ agent-base │
│ Tool trait · Runtime │
│ LLM clients · Events │
└──────────┬──────────┘
│
┌──────────────────────┼──────────────────────┐
│ │ │
┌─────────▼─────────┐ ┌────────▼────────┐ ┌──────────▼──────────┐
│ agent-works │ │ phi-tools │ │ your-tools │
│ MCP · Skills │ │ LocalShellTool │ │ Custom Tool impls │
│ Builtin tools │ │ │ │ │
└─────────┬─────────┘ └────────┬────────┘ └──────────┬──────────┘
│ │ │
└──────────────────────┼──────────────────────┘
│
┌──────────▼──────────┐
│ phi-agent │
│ Builder factory │
│ Renderers (3) │
│ Config · Session │
│ CLI (phi) │
└──────────┬──────────┘
│
┌────────────┼────────────┐
│ │ │
┌─────▼────┐ ┌────▼─────┐ ┌────▼─────┐
│ Terminal │ │ JSON │ │ Web │
│ REPL │ │ Stream │ │ Backend │
└───────────┘ └──────────┘ └──────────┘
Core principle: phi-agent itself does not bundle any tools. It provides the agent builder factory, renderers, config resolution, and session management — tools are injected by consumers.
Why phi-agent
Simple. A tool is 3 methods: name(), definition(), call(). No framework to learn, no abstractions to fight.
Rust. Single binary, no runtime dependency. cargo install and you're done. Memory-safe, crash-resistant, fast. Deploy anywhere — from cloud servers to edge devices.
Pure. No built-in memory, no vector database, no hidden state. The agent doesn't remember anything you don't tell it to. Predictable, debuggable, and you control where your data goes.
Your tools, your rules. phi-agent doesn't know what tools exist. You bring them, you own them. No vendor lock-in.
Features
- Builder factory —
base_agent_builder()with sensible defaults (thinking, recovery, limits) - Three renderers — Terminal (rich, colored, streaming), JSON stream (JSONL), Null (silent)
- CLI-ready — REPL and one-shot modes with 30+ configurable flags
- Session management — auto-cleanup, file locking, JSONL turn logging
- Tool-agnostic — no built-in tools; register your own via
AgentBuilder - Extensible — middleware, approval handlers, custom renderers
Quick Start
use ;
use Arc;
async
See examples/ for more complete examples.
CLI
# REPL mode
# JSON output for scripting
Custom Tool Example
use ;
use ;
use async_trait;
;
Full guide: guide/custom-tool.md
Documentation
📖 Full documentation: hibuka-labs.github.io/phi-agent
| Document | Description |
|---|---|
| Getting Started | 5-minute quick start |
| Custom Tools | How to write a Tool |
| Configuration | Config reference |
| Focus | Structured single-purpose LLM calls |
| Advanced | Middleware, sessions, event log |
FAQ
Q: What's the difference between phi-agent and agent-base?
agent-base is the runtime kernel (LLM calls, tool orchestration, event stream). phi-agent wraps it with a builder factory, renderers, config resolution, and session management — plus a CLI binary.
Q: Can I use phi-agent without the CLI?
Yes. Import it as a library (phi_agent) and use PhiAgent::build() programmatically. The CLI is just one consumer.
Q: How do I add my own tools?
Implement the Tool trait from agent-base and register with builder.register_tool(...). phi-agent has zero knowledge of what tools exist.
Q: Does phi-agent support Anthropic / other providers?
Yes. agent-base provides AnthropicClient and OpenAiClient. Any client implementing LlmClient works.
Contributing
This is a monorepo — clone once and you can work on all crates:
See CONTRIBUTING.md for detailed setup instructions and PR guidelines.
License
MIT — see LICENSE for details.