Skip to main content
A backend is the AI engine that processes each incoming message and decides what to reply. All three backends share the same Nuggets memory stack — FHRR facts, graph notes, and the daily reflection pass — but they differ in how they are invoked, what tools they can use, and how skills are delivered. You select the backend by setting the AGENT_BACKEND environment variable before starting the gateway.
# .env
AGENT_BACKEND=pi   # pi | codex | local

Backend comparison

FeaturePiCodexLocal
Tool useFull (native Pi tools)Full (shell and file tools via Codex)None — conversational only
Nuggets memory toolsnuggets, createNote, addLink, editNote, searchNotesPrompted via nuggets recall / nuggets remember CLINot available
Schedulingschedule tool (Pi extension)Writes to .gateway/cron/requests.jsonlNot available
Memory reflectionreflectAndCleanMemory tool (Pi extension)Prompted via Codex shell toolsNot available
Skills deliveryPassed as real Pi --skill filesSkills catalog in prompt; files read on demandSkill contents inlined into system prompt
Session persistencePi session files (JSONL, per conversation)Codex thread ID (per conversation)Chat history JSON (last 40 messages)
Provider selectionAGENT_PROVIDER + AGENT_MODELModel via AGENT_MODEL, optional OSS flagLOCAL_MODEL_PROVIDER + LOCAL_MODEL_BASE_URL
Conversational onlyNoNoYes

Environment variables

Selecting the backend

AGENT_BACKEND=pi   # Default. Also accepts: codex, local

Selecting the provider and model (Pi and Codex)

AGENT_PROVIDER=anthropic   # anthropic | openai | openai-codex
AGENT_MODEL=               # Leave empty to use the provider default
AGENT_PROVIDER and AGENT_MODEL are read by the Pi backend directly. The Codex backend uses AGENT_MODEL when you want to pass a specific model to codex exec. The Local backend ignores AGENT_PROVIDER entirely and uses LOCAL_MODEL_PROVIDER instead.
PI_PROVIDER and PI_MODEL are kept for legacy compatibility. When set, they are used as fallbacks for AGENT_PROVIDER and AGENT_MODEL respectively.

When to choose each backend

Choose Pi when you want the richest memory and tool experience. Pi runs as a persistent subprocess per conversation, with the full Nuggets extension loaded. The agent can directly call nuggets, createNote, addLink, editNote, searchNotes, schedule, and reflectAndCleanMemory as structured tools. Sessions resume across restarts.Best for: personal assistants, long-running projects, anyone who wants deep memory integration and scheduling.
Choose Codex when you want a code-oriented agent that can read, write, and execute files. Codex receives the Nuggets recall-first behavior as prompt instructions and can invoke the nuggets CLI directly. The skills catalog is included in the prompt so Codex can read any SKILL.md file on demand.Best for: software development tasks, automation, users who are already familiar with Codex.
Choose Local when you want to run everything on-device with no cloud API keys. The backend connects directly to an OpenAI-compatible server such as Ollama or MLX. There are no tool calls — the model converses naturally, and active skill contents are inlined into the system prompt.Best for: privacy-first setups, offline use, experimentation with local models.

Backend pages

Pi

Full tool use with native Nuggets memory extensions, session pools, and Pi skill files.

Codex

Shell and file access via Codex CLI with recall-first memory prompting.

Local

Conversational-only backend for Ollama, MLX, or any OpenAI-compatible local server.

Build docs developers (and LLMs) love