Architecture

April 28, 2026 · View on GitHub

How Agent CLI works under the hood.

System Overview

Agent CLI is built around a modular service architecture where different AI capabilities are provided by interchangeable backends.

For usage and flags, see Commands Reference and Configuration.

┌────────────────────────────────────────────────────────────────┐
│                          Agent CLI                             │
│  ┌──────────┐ ┌───────────┐ ┌──────┐ ┌───────────┐ ┌────────┐  │
│  │transcribe│ │voice-edit │ │ chat │ │ assistant │ │  ...   │  │
│  └────┬─────┘ └─────┬─────┘ └──┬───┘ └─────┬─────┘ └────────┘  │
└───────┼─────────────┼──────────┼───────────┼───────────────────┘
        │             │          │           │
        ▼             ▼          ▼           ▼
┌────────────────────────────────────────────────────────────────┐
│                     Provider Abstraction                       │
│     ┌─────────────┐   ┌─────────────┐   ┌─────────────┐        │
│     │ ASR Provider│   │ LLM Provider│   │ TTS Provider│        │
│     └──────┬──────┘   └──────┬──────┘   └──────┬──────┘        │
└────────────┼─────────────────┼─────────────────┼───────────────┘
             │                 │                 │
      ┌──────┼──────┐    ┌─────┼─────┐    ┌───────┼───────┐
      ▼      ▼      ▼    ▼     ▼     ▼    ▼   ▼   ▼   ▼   ▼
 ┌───────┐┌──────┐┌──────┐┌──────┐┌──────┐┌─────┐┌──────┐┌──────┐┌──────┐
 │Wyoming││OpenAI││Gemini││Ollama││OpenAI││Piper││OpenAI││Kokoro││Gemini│
 │Whisper││Whispr││ ASR  ││      ││Gemini││     ││ TTS  ││      ││ TTS  │
 └───────┘└──────┘└──────┘└──────┘└──────┘└─────┘└──────┘└──────┘└──────┘

Provider System

Each AI capability (ASR, LLM, TTS) has multiple backend providers:

ASR (Automatic Speech Recognition)

ProviderImplementationGPU SupportLatency
wyomingWyoming Whisper (faster-whisper/MLX)CUDA/MetalLow
openaiOpenAI-compatible Whisper APICloudMedium
geminiGoogle Gemini APICloudMedium

LLM (Large Language Model)

ProviderImplementationGPU SupportPrivacy
ollamaOllama (local)CUDA/MetalFull
openaiOpenAI-compatible APICloudPartial
geminiGoogle Gemini APICloudPartial

TTS (Text-to-Speech)

ProviderImplementationQualitySpeed
wyomingWyoming PiperGoodFast
openaiOpenAI-compatible TTSExcellentMedium
kokoroKokoro TTSGoodFast
geminiGoogle Gemini TTSGoodMedium

Wyoming Protocol

Agent CLI uses the Wyoming Protocol for local AI services. Wyoming provides a simple TCP-based protocol for:

  • Speech-to-text (ASR)
  • Text-to-speech (TTS)
  • Wake word detection

Default Ports

ServicePortProtocol
Whisper (ASR)10300Wyoming
Piper (TTS)10200Wyoming
OpenWakeWord10400Wyoming
Ollama (LLM)11434HTTP
RAG Proxy8000HTTP
Memory Proxy8100HTTP

Audio Pipeline

┌───────────┐    ┌───────────┐    ┌───────────┐    ┌───────────┐
│ Microphone│───▶│sounddevice│───▶│    WAV    │───▶│  Wyoming  │
│           │    │  capture  │    │   buffer  │    │    ASR    │
└───────────┘    └───────────┘    └───────────┘    └─────┬─────┘


┌───────────┐    ┌───────────┐    ┌───────────┐    ┌───────────┐
│  Speakers │◀───│sounddevice│◀───│    WAV    │◀───│  Wyoming  │
│           │    │  playback │    │   buffer  │    │    TTS    │
└───────────┘    └───────────┘    └───────────┘    └───────────┘

Configuration Loading

Configuration is loaded from multiple sources with the following precedence:

  1. Command-line arguments (highest priority)
  2. Environment variables (OPENAI_API_KEY, etc.)
  3. Config file (--config/--path, $AGENT_CLI_CONFIG_HOME/config.toml, ./agent-cli-config.toml, $XDG_CONFIG_HOME/agent-cli/config.toml, or ~/.config/agent-cli/config.toml)
  4. Default values (lowest priority)

Process Management

Commands that run as background processes use a PID file system:

~/.cache/agent-cli/
├── assistant.pid
├── chat.pid
├── speak.pid
├── transcribe.pid
├── transcribe-live.pid
└── voice-edit.pid

~/.config/agent-cli/
├── config.toml              # Configuration
├── audio/                   # Saved recordings (transcribe-live)
├── history/                 # Chat history
├── transcriptions/          # Saved WAV files
└── transcriptions.jsonl     # Transcription log

Memory System

See Memory System Architecture for details on the long-term memory implementation. Usage: memory command.

RAG System

See RAG System Architecture for details on the document retrieval system. Usage: rag-proxy command.

Dependencies

Agent CLI uses a modular dependency structure. The base package is lightweight, with features installed as optional extras.

Core Dependencies

Always installed:

  • typer - CLI framework
  • pydantic - Data validation
  • rich - Terminal formatting
  • pyperclip - Clipboard access
  • httpx - HTTP client

Provider Extras

Install with agent-cli install-extras <name> or pip install agent-cli[name]:

ExtraPurposeKey Packages
audioVoice featuressounddevice, wyoming, numpy
llmAI processingpydantic-ai-slim (OpenAI, Gemini)

Feature Extras

ExtraPurposeKey Packages
vadVoice activity detectiononnxruntime
ragDocument chatchromadb, markitdown
memoryLong-term memorychromadb
serverLocal ASR/TTS serversfastapi
faster-whisperWhisper (CUDA/CPU)faster-whisper
mlx-whisperWhisper (Apple Silicon)mlx-whisper

See install-extras for the full list and installation instructions.

Platform Support

PlatformStatusNotes
macOS (Apple Silicon)FullMetal GPU acceleration
macOS (Intel)FullCPU-only
Linux (x86_64)FullNVIDIA GPU support
Linux (ARM)PartialCPU-only
Windows (WSL2)FullVia WSL2
Windows (Native)ExperimentalLimited testing