Overview
This is a translation/summary of the Crush Agent system unification evolution roadmap, v2.0 (dated 2026-04-17, updated 2026-04-18 after a comprehensive codebase audit). It covers internal/agent, internal/agent/subagent, internal/agent/multiagent, internal/a2a, tool/UI integration layers, and infrastructure modules.
Key points
Problem statement
- Multiple agent systems evolved in parallel: the
agenttool (session delegation viaDelegator.DelegateSync()),subagent(async task engine with 6-state machine, 5 middlewares, SQLite/Memory persistence, WorkerPool),multiagent(role registry with 7 roles, MessageBus with 8 message types), anda2a(Google A2A protocol server). - Audit findings: duplicated delegation logic, dormant features (Worktree isolation fully implemented but not enabled;
send_messagetool defined but unregistered;TokenUsageMiddleware.RecordTokens()andLoopDetectionMiddleware.CheckState()never called, so CostUSD was always 0), fragmented observability (only 3 counters ininternal/metrics), and weak test coverage for multiagent components. - Stages 0–4 (complete): baseline observability; unified
Delegatorabstraction (DelegationRequest/DelegationResult/delegationstatus);agenttool v2 compatibility bridge (AgentParams = AgentToolV2Input); subagent engine hardening (30+ items: SQLite WAL config, idempotency, backpressure, middleware chain, failure attribution, migration registry); multiagentDelegationExecutorinterface with grayscale switch andexecuteDelegationWithSessionentry point. - Stage 5 (complete): multiagent
DelegationExecutornow routes through the subagent Executor; concurrency control migrated fromexecMu.TryLock()to the WorkerPool; middleware (RecordTokens,CheckState) and cost tracking actually wired in; Worktree isolation productized;send_messageregistration decision made;/subagentunified as the standard delegation entry point; A2A routing byagentTypestandardized. - Stage 6 (complete): >= 10 core Prometheus metrics (
tool_call_duration_seconds,active_sessions,token_cost_total_usd, etc.); subagentEventMetricspersisted (.crush/subagent_event_metrics.json); PostHog tool/cost events;trace_idpropagation session → task → tool_call; HotReloader and RecoveryManager enabled inapp.go; Registry consolidation; Store cleanup leak fix. - Stage 7 (in progress): experimental
distributed(leader election, distributed locks),scaling(AutoScaler callingExecutor.ResizeMaxWorkers),pool, andmarket(/marketslash command) behind flags likeCRUSH_SCALING_EXPERIMENTAL=true; PubSub upgraded toward cross-process persistence. - Task success rate >= 99%; cancellation success >= 99.5%; delegation P95 latency no worse than 10% over baseline; middleware chain E2E coverage 100%; >= 10 observable core metrics; multiagent test coverage >= 80%.
Target architecture (three layers)
1. Execution Core —SessionAgent as the single LLM execution kernel.
2. Task Orchestration — subagent Executor as the unified delegation engine (sync/async, state machine, middleware, rate limiting, cancellation, timeouts, optional Worktree isolation).
3. Organization / Teaming — multiagent Manager for role governance, message bus, and workspace management, reusing the unified delegation API.Progress status
Risk management
Key risks and mitigations include: behavior drift (replay benchmarks), concurrency/cancellation regressions (fault injection, state machine validation), inconsistent logging (mandatorytrace_id/session_id/task_id), worktree leaks (TTL cleanup), middleware dormancy (CI middleware-coverage checks), observability fragmentation (metrics dictionary), and config-runtime mismatch (feature-flag guards in app.go).Acceptance criteria
Backward compatibility & rollout
Old tool input fields are preserved and mapped internally; behavior changes ship behind feature flags with canary → grayscale → full rollout. Proposed ADRs document key decisions (three-layer architecture, single execution kernel, subagent as unified engine, agent-tool deprecation, middleware wiring spec,send_message disposition).