Summary
Proposes a six-layer foundation architecture for AgentPool v1.0 that achieves full orthogonality between config, infrastructure, agent compilation, execution lifecycle, agent core, and protocol serving. Unifies and supersedes RFC-0042's lifecycle dimensions within a broader architectural context.
Architecture Overview
Layer 1: ConfigRegistry → Store, version, serve YAML configs
Layer 2: AgentHost → Own mutable runtime infrastructure per (config_id, tenant_id)
Layer 3: AgentFactory → Compile AgentManifest + HostContext into runnable agents
Layer 4: RunLoop → Drive idle → running → idle | done cycle (RFC-0042 six dimensions)
Layer 5: Agent Core → MessageNode, NativeAgent/ACPAgent, pydantic-ai Capability/Toolset
Layer 6: ProtocolServer → Translate between wire protocols and RunLoop operations
RunScope (config_id, tenant_id, user_id, session_id) is the cross-cutting router that enables multi-tenancy without structural changes — each layer becomes a registry keyed by RunScope.
Key Design Decisions
1. Config Split: HostConfig + AgentManifest
| Section |
Owner |
Change Cost |
Example |
host: (HostConfig) |
AgentHost (L2) |
High (restart MCP, reconnect DB) |
mcp_servers, storage, models, observability |
agents: + teams: + graph: (AgentManifest) |
AgentFactory (L3) |
Low (recompile agents, diff-based) |
agent defs, team topology, response schemas |
Reference, not definition: MCP servers and model providers are DEFINED in HostConfig; agents REFERENCE them by name. This separates "what infrastructure IS" from "which agent uses WHICH infrastructure."
Deferred to Phase 3 per Oracle analysis — Phase 1 extracts only runtime structures (HostContext + AgentFactory) without modifying config model. Flat AgentsManifest works throughout Phase 1-2.
2. Model Config Three-Layer
| Layer |
Concern |
Location |
| Provider config |
API keys, base URLs, proxies |
host.models.providers |
| Model aliases |
Name resolution, fallback chains |
host.models.aliases |
| Agent selection |
Which alias, temperature, max_tokens |
agent.model, agent.temperature |
ModelCache shares pydantic-ai Model instances across agents in the same host (connection pooling). Alias enables model migration in one place.
3. Delete ResourceProvider, Adopt pydantic-ai Capability/Toolset
ResourceProvider is already deprecated. pydantic-ai's AbstractCapability + AbstractToolset system is richer, native, and eliminates the as_capability() bridge layer. 7 provider migration mappings >90% clear.
Change notification: Extend AbstractCapability.on_change() — delegated to Capability, not centralized. Avoids recreating ResourceProvider signal pattern under a new name.
Knowledge management: Starts as Capability (Layer 5), promoted to Layer 2 KnowledgeProvider when cross-agent sharing is demonstrated (YAGNI).
4. ResourceSource — Orthogonal Data Abstraction
pydantic-ai has tools (behavior) and instructions (directives) but no data concept. ResourceSource fills this gap:
- Orthogonal to Capability — not parallel (which would recreate ResourceProvider)
MCPCapability implements BOTH AbstractCapability (tools) AND ResourceSource (resources) — two interfaces, two concerns, same object
AggregatedResourceSource composes multiple sources at compile time
AgentContext.resources: ResourceSource | None — optional, compile-time scoped
5. AgentContext + DelegationService
@dataclass(frozen=True)
class AgentContext:
agent_registry: AgentRegistry # read-only, from AgentFactory (L3)
delegation: DelegationService # interface from RunLoop (L4)
session: SessionState # from RunLoop (L4)
scope: RunScope # cross-cutting
resources: ResourceSource | None # from Factory, compile-time scoped
host: HostContext | None # rarely needed, for advanced tools
DelegationService is a limited interface exposed by RunLoop — tools know WHAT they can do (spawn subagent), not HOW RunLoop implements it. Preserves Layer 4→5 boundary.
6. HostContext Replaces agent_pool Backdoor
MessageNode.agent_pool is a direct reference to the full AgentPool on every agent — spans Layers 2-5. HostContext is a frozen dataclass carrying only dependency handles, enforcing layer boundaries and enabling tenant isolation. Single highest-priority refactor in Phase 1.
7. Storage Three-Layer (Complementary, Not Conflicting)
| Store |
Role |
Owner |
Retention |
| StorageProvider |
DB tables (analytical history) |
AgentHost (L2) |
Permanent |
| Journal |
WAL / transaction log (event persistence) |
CommChannel (L4) |
Compactible |
| SnapshotStore |
Checkpoint file (Turn boundary state) |
RunLoop (L4) |
Turn-scoped |
Tiered consistency: Turn-level events strong (synchronous dual-write), Delta events eventual (async batch journal). Avoids write amplification while preserving crash recovery.
8. Concurrency Model
- asyncio at all layers (single-process)
- Multi-process: AgentHost MCP subprocesses + EventTransport IPC (gRPC)
- Distributed: ConfigStore (etcd) + MessageQueueTransport + HostRegistry routing
Invariant: One RunLoop = one process = one session. Distribution happens AROUND RunLoop, not within it.
EventTransport evolution: InProcess (default) → gRPC (multi-process) → MessageQueue (distributed polyglot). Each step opt-in.
Implementation Plan (Oracle-Revised)
Critical path: Phase 1a (14d) → Phase 2 (30d) = 44 days to RunLoop
| Phase |
Deliverable |
Duration |
Dependencies |
| 1a |
Runtime extraction: HostContext + AgentFactory from AgentPool |
14d |
— |
| 1b |
Backdoor removal: replace agent_pool with HostContext (25 call sites) |
21d |
1a (parallel with Phase 2) |
| 1c |
Capability bridge: 7 ToolsetFactory equivalents + AdapterToolsetFactory |
21d |
1a (parallel with Phase 2) |
| 1d |
Delete ResourceProvider after all call sites migrated |
7d |
1c |
| 2 |
RFC-0041 (Run/Turn separation) + RFC-0042 (six dimensions) |
30d+45d |
1a |
| 3 |
Config split + ConfigRegistry versioning + HostRegistry + RunScope routing |
14d+21d+21d+14d |
Phase 2 |
| 4 |
Multi-tenant: tenant isolation + StorageProvider filtering |
21d+14d |
Phase 3 |
| 5 |
Polyglot: gRPCTransport + MessageQueueTransport |
21d+30d |
Phase 2 |
Config split deferred to Phase 3 — Oracle analysis confirmed Phase 1b/1c/Phase 2 depend on 1a-runtime only (HostContext + AgentFactory extraction), NOT on config schema split.
Related Documents
- 📄 RFC-0050:
docs/rfcs/draft/RFC-0050-agentwolf-v1-foundation-architecture.md (2484 lines, revision 5, Oracle-revised)
- 📄 RFC-0042:
docs/rfcs/draft/RFC-0042-unified-lifecycle-architecture.md (~3060 lines, revision 4.4, Oracle-reviewed PASS) — Layer 4 detail
- 📄 RFC-0041:
docs/rfcs/draft/RFC-0041-run-turn-separation.md — Phase 2 prerequisite
- 📊 Lifecycle Analysis:
docs/design/lifecycle-analysis.md (cross-framework survey)
- 🔗 Appendix A: Oracle architecture feasibility assessment (MEDIUM RISK, conditional GO)
- 🔗 Appendix B: Codebase migration cost (9-15 dev-weeks, 151 importers, 85 test files)
- 🔗 Appendix C: DeerFlow architecture reference (~228K LOC)
- 🔗 Appendix D: Zed editor architecture reference (~15 Rust crates)
Review Requested
- Six-layer separation — are the layer boundaries correct? Should any layers merge or split?
- Config split deferral — is deferring HostConfig/AgentManifest to Phase 3 safe?
- ResourceSource orthogonality — is the data-vs-behavior axis distinction clear enough to avoid confusion with deleted ResourceProvider?
- AgentContext design — is DelegationService the right abstraction for Layer 4→5 bridging?
- Tiered consistency — is the Turn-level strong / Delta-level eventual split acceptable?
- Migration sequencing — is the Oracle-revised critical path (44d to RunLoop) realistic?
Summary
Proposes a six-layer foundation architecture for AgentPool v1.0 that achieves full orthogonality between config, infrastructure, agent compilation, execution lifecycle, agent core, and protocol serving. Unifies and supersedes RFC-0042's lifecycle dimensions within a broader architectural context.
Architecture Overview
RunScope (config_id, tenant_id, user_id, session_id) is the cross-cutting router that enables multi-tenancy without structural changes — each layer becomes a registry keyed by RunScope.
Key Design Decisions
1. Config Split: HostConfig + AgentManifest
host:(HostConfig)agents:+teams:+graph:(AgentManifest)Reference, not definition: MCP servers and model providers are DEFINED in HostConfig; agents REFERENCE them by name. This separates "what infrastructure IS" from "which agent uses WHICH infrastructure."
Deferred to Phase 3 per Oracle analysis — Phase 1 extracts only runtime structures (HostContext + AgentFactory) without modifying config model. Flat
AgentsManifestworks throughout Phase 1-2.2. Model Config Three-Layer
host.models.providershost.models.aliasesagent.model,agent.temperatureModelCacheshares pydantic-ai Model instances across agents in the same host (connection pooling). Alias enables model migration in one place.3. Delete ResourceProvider, Adopt pydantic-ai Capability/Toolset
ResourceProvider is already deprecated. pydantic-ai's
AbstractCapability+AbstractToolsetsystem is richer, native, and eliminates theas_capability()bridge layer. 7 provider migration mappings >90% clear.Change notification: Extend
AbstractCapability.on_change()— delegated to Capability, not centralized. Avoids recreating ResourceProvider signal pattern under a new name.Knowledge management: Starts as Capability (Layer 5), promoted to Layer 2
KnowledgeProviderwhen cross-agent sharing is demonstrated (YAGNI).4. ResourceSource — Orthogonal Data Abstraction
pydantic-ai has tools (behavior) and instructions (directives) but no data concept.
ResourceSourcefills this gap:MCPCapabilityimplements BOTHAbstractCapability(tools) ANDResourceSource(resources) — two interfaces, two concerns, same objectAggregatedResourceSourcecomposes multiple sources at compile timeAgentContext.resources: ResourceSource | None— optional, compile-time scoped5. AgentContext + DelegationService
DelegationServiceis a limited interface exposed by RunLoop — tools know WHAT they can do (spawn subagent), not HOW RunLoop implements it. Preserves Layer 4→5 boundary.6. HostContext Replaces
agent_poolBackdoorMessageNode.agent_poolis a direct reference to the fullAgentPoolon every agent — spans Layers 2-5.HostContextis a frozen dataclass carrying only dependency handles, enforcing layer boundaries and enabling tenant isolation. Single highest-priority refactor in Phase 1.7. Storage Three-Layer (Complementary, Not Conflicting)
Tiered consistency: Turn-level events strong (synchronous dual-write), Delta events eventual (async batch journal). Avoids write amplification while preserving crash recovery.
8. Concurrency Model
Invariant: One RunLoop = one process = one session. Distribution happens AROUND RunLoop, not within it.
EventTransport evolution: InProcess (default) → gRPC (multi-process) → MessageQueue (distributed polyglot). Each step opt-in.
Implementation Plan (Oracle-Revised)
agent_poolwith HostContext (25 call sites)Config split deferred to Phase 3 — Oracle analysis confirmed Phase 1b/1c/Phase 2 depend on 1a-runtime only (HostContext + AgentFactory extraction), NOT on config schema split.
Related Documents
docs/rfcs/draft/RFC-0050-agentwolf-v1-foundation-architecture.md(2484 lines, revision 5, Oracle-revised)docs/rfcs/draft/RFC-0042-unified-lifecycle-architecture.md(~3060 lines, revision 4.4, Oracle-reviewed PASS) — Layer 4 detaildocs/rfcs/draft/RFC-0041-run-turn-separation.md— Phase 2 prerequisitedocs/design/lifecycle-analysis.md(cross-framework survey)Review Requested