System Overview
Goose follows a classic client-server architecture with pluggable components at each layer:Core Components
1. User Interfaces
Goose provides multiple ways to interact with the agent:- CLI (
goose-cli): Command-line interface for terminal users - Desktop App: Electron-based application with rich UI features
- Custom Interfaces: Build your own via REST API or Agent Client Protocol
2. Server Layer
The server layer provides two integration protocols:REST API (goose-server)
HTTP-based API suitable for web applications and simple integrations.Agent Client Protocol (ACP)
JSON-RPC protocol for richer integrations with bidirectional communication.3. Core Layer
The core layer (crates/goose/) contains the main business logic:
Agent
The central orchestrator that manages conversation flow, tool execution, and provider interaction.- Managing conversation context
- Coordinating tool execution
- Handling provider streaming
- Managing permissions and security
- Orchestrating subagents
Extension Manager
Manages MCP (Model Context Protocol) servers that provide tools and resources to the agent.- Dynamic extension loading/unloading
- Tool discovery and caching
- Resource management (MCP resources)
- OAuth flow handling for authenticated extensions
Provider Registry
Abstracts AI model providers behind a common interface.- 25+ AI providers (Anthropic, OpenAI, Ollama, etc.)
- Custom provider plugins
- Model capability detection
- Token counting and cost estimation
Session Manager
Handles persistent state, conversation history, and session metadata.4. Integration Layer
MCP Servers
Goose uses the Model Context Protocol to integrate external tools:- Built-in: Bundled with Goose
- Stdio: External processes communicating via stdin/stdout
- SSE: HTTP-based Server-Sent Events
AI Providers
Providers implement theProvider trait to connect to AI models:
Data Flow
A typical request flows through the system as follows:Configuration and Customization
Configuration Files
Goose uses a layered configuration system:Environment Variables
Configuration precedence: Environment > config.yaml > defaultsRecipes
YAML-based configuration for complete agent experiences:Security Model
Goose implements multiple security layers:Permission System
- Tool execution
- File system access
- Network requests
- Environment variable access
Extension Sandboxing
- Extensions run as separate processes
- Controlled environment variables (see
Envs::DISALLOWED_KEYS) - Malware scanning for downloaded extensions
- Resource limits and timeouts
Session Isolation
- Each session has isolated state
- Working directory restrictions
- Extension data partitioning
Extension Points
The architecture supports customization at multiple levels:| Layer | Customization | Difficulty |
|---|---|---|
| UI | Build custom interface using REST API or ACP | Medium-High |
| Provider | Add custom AI provider via declarative config or trait implementation | Low-Medium |
| Extensions | Create MCP server for custom tools | Low-Medium |
| Recipes | Define workflows and behaviors | Low |
| Prompts | Modify system prompts | Low |
| Core | Fork and modify core logic | High |
Build System
Goose uses a Rust workspace structure:Performance Considerations
Context Management
Goose implements automatic context compaction when messages approach token limits:Tool Call Parallelization
Multiple tool calls in a single model response execute in parallel:Caching
- Tool lists cached and versioned for quick access
- Provider capabilities cached per model
- Session data persisted to SQLite for fast retrieval
For custom distribution guidance, see the CUSTOM_DISTROS.md guide in the Goose repository.
Next Steps
Agents
Learn about agent orchestration and subagents
Providers
Explore AI provider integration
Extensions
Understand the MCP extension system
Sessions
Discover session management