Examples from How to Build a Custom Agent Framework.
Built with the @mariozechner/pi-ai and @mariozechner/pi-agent-core libraries.
| File | Description |
|---|---|
basics.tsx |
Simple LLM completion with completeSimple |
stream.tsx |
Streaming LLM response with streamSimple |
weather.tsx |
Agent with a custom tool (mock weather lookup) |
session.tsx |
Agent session via createAgentSession with in-memory SessionManager |
assistant.ts |
Interactive REPL assistant with session persistence, a custom web search tool, and auto context compaction |
Files are run with tsx:
npx tsx <filename>Examples:
npx tsx basics.tsx
npx tsx stream.tsx
npx tsx weather.tsx
npx tsx session.tsx
npx tsx assistant.tsInstall dependencies:
npm install