Architecture
Repository Overview
Sage is structured as a layered repository rather than a single binary. The main top-level subsystems are:
sagents/: core runtime and orchestrationapp/server/: main FastAPI application and web clientapp/desktop/: desktop-local application stackexamples/: lightweight runnable examplesmcp_servers/: built-in MCP server implementationsrelease_notes/: release-specific notes outside the main docs set
High-Level Dependency Shape
flowchart TD
User[User Interfaces] --> Web[Web App]
User --> Desktop[Desktop App]
User --> Examples[Examples]
Web --> Server[app/server]
Desktop --> DesktopCore[app/desktop/core]
Server --> Runtime[sagents]
DesktopCore --> Runtime
Examples --> Runtime
Runtime --> Tools[Tool System]
Runtime --> Skills[Skill System]
Runtime --> Sandbox[Sandbox]
Runtime --> Obs[Observability]
Tools --> MCP[mcp_servers]
Core Runtime: sagents/
sagents/sagents.py:SAgentruntime entry and stream orchestrationsagents/agent/: agent implementations such as simple, planning, execution, routing, and fibre agentssagents/flow/: flow schema, conditions, and executorsagents/tool/: tool abstractions, built-ins, managers, and MCP supportsagents/skill/: skill management and proxiessagents/context/: session and state handlingsagents/utils/sandbox/: sandbox configuration and providerssagents/observability/: runtime tracing and telemetry hooks
Main Application: app/server/
app/server/main.py: primary FastAPI startup pathapp/server/routers/: HTTP route registrationapp/server/services/: business and integration servicesapp/server/schemas/: request and response modelsapp/server/web/: Vue 3 frontend
This is the main multi-user application surface and the default place to understand the productized server behavior.
Desktop Application: app/desktop/
app/desktop/entry.py: desktop bootstrapapp/desktop/core/main.py: desktop-local FastAPI appapp/desktop/ui/: desktop frontendapp/desktop/scripts/: packaging and development scripts
The desktop app reuses core platform concepts while packaging a local-first application flow.
Example Surfaces: examples/
The examples/ directory is intentionally lighter weight than app/server/ and is useful for:
- local experimentation
- simple runtime validation
- isolated demos
- packaging experiments
MCP Servers: mcp_servers/
Built-in MCP implementations are versioned in the repository and can be wired into the runtime through the tool layer.
Architectural Notes
app/server/is the primary application boundary.examples/are useful, but they are not the canonical application stack.sagents/is the runtime engine and extension substrate.mcp_servers/and app-facing tool registration are separate concerns: implementation vs exposure.