feat: add multi-agent support with CLI and MCP integration (v0.5.0)#70
Closed
feat: add multi-agent support with CLI and MCP integration (v0.5.0)#70
Conversation
Introduce AgentProvider type, AgentAdapter/AgentRegistry interfaces, AGENT_NOT_FOUND/AGENT_MISCONFIGURED error codes, and agent field on Task/TaskRequest domain models. Default agent is 'claude' for backward compatibility. Co-Authored-By: Claude <noreply@anthropic.com>
Each adapter implements AgentAdapter with provider-specific CLI args, auto-accept flags, and environment variable stripping to prevent credential leakage between agent processes.
InMemoryAgentRegistry provides Map-based adapter lookup by provider. ProcessSpawnerAdapter wraps legacy ProcessSpawner as AgentAdapter for backward compatibility with existing test infrastructure.
Migration v7 adds 'agent TEXT' column to tasks table, defaulting existing tasks to 'claude'. Task repository updated with agent field in all SQL statements, Zod schema, and domain mapping.
Worker pool constructor now accepts AgentRegistry instead of ProcessSpawner. spawn() resolves the correct adapter via task.agent field (defaults to 'claude'). Bootstrap wiring updated to construct InMemoryAgentRegistry.
Ensures task.agent is carried forward when retrying or resuming tasks, maintaining agent affinity across task lifecycle operations.
Add createAgentRegistryFromSpawner helper for backward-compatible test setup. Update worker pool unit tests, handler-setup tests, and integration tests to construct EventDrivenWorkerPool with AgentRegistry instead of ProcessSpawner.
…e and ListAgents tool Add multi-agent support to the MCP surface: - DelegateTask: optional agent field (z.enum) selects which agent runs the task - ScheduleTask: optional agent field propagated to schedule template - CreatePipeline: per-step agent override + default agent field - ListAgents: new MCP tool returns all providers with registration status - TaskStatus: includes agent in single-task response (defaults to 'claude') - Domain: add agent field to ScheduleCreateRequest and PipelineStepRequest
…splay CLI surface for multi-agent support: - beat run: --agent/-a flag to select agent provider (claude, codex, gemini, aider) - beat agents list: new command showing all available agents with descriptions - beat status: shows agent field in task detail output (defaults to 'claude') - help: updated with agent flag docs, agent commands section, and usage example
…rough schedules - Bootstrap: register Claude, Codex, Gemini, Aider adapters in production - Bootstrap: pass AgentRegistry to MCPAdapter constructor - ScheduleManager: propagate agent field to taskTemplate in createSchedule - ScheduleManager: propagate per-step agent in createPipeline
New test files: - agents.test.ts: AGENT_PROVIDERS constant, DEFAULT_AGENT, isAgentProvider guard (10 tests) - agent-registry.test.ts: InMemoryAgentRegistry get/has/list/dispose (11 tests) - agent-adapters.test.ts: Claude/Codex/Gemini/Aider spawn args and env stripping (16 tests) Updated test files: - mcp-adapter.test.ts: DelegateTask agent field, ListAgents tool (5 tests) - cli.test.ts: agent flag parsing, agents list command, status display (7 tests) - domain.test.ts: createTask with agent field (4 tests) Total new tests: 53 | All suites passing: 1177 tests
Greptile SummaryThis PR adds comprehensive multi-agent support (v0.5.0) enabling task delegation to Claude, Codex, Gemini, and Aider through a clean abstraction layer. The implementation follows excellent architectural patterns with proper separation of concerns. Key Changes:
Architecture Highlights:
Confidence Score: 5/5
Important Files Changed
Class Diagram%%{init: {'theme': 'neutral'}}%%
classDiagram
class AgentRegistry {
<<interface>>
+get(provider) Result~AgentAdapter~
+has(provider) boolean
+list() AgentProvider[]
+dispose() void
}
class AgentAdapter {
<<interface>>
+provider: AgentProvider
+spawn(prompt, workingDir, taskId) Result
+kill(pid) Result
+dispose() void
}
class InMemoryAgentRegistry {
-adapters: Map
+get(provider)
+has(provider)
+list()
+dispose()
}
class ClaudeAdapter {
+provider: "claude"
+spawn()
+kill()
+dispose()
}
class CodexAdapter {
+provider: "codex"
+spawn()
+kill()
+dispose()
}
class GeminiAdapter {
+provider: "gemini"
+spawn()
+kill()
+dispose()
}
class AiderAdapter {
+provider: "aider"
+spawn()
+kill()
+dispose()
}
class EventDrivenWorkerPool {
-agentRegistry: AgentRegistry
+spawn(task)
+kill(workerId)
}
class Task {
+agent?: AgentProvider
+prompt: string
+status: TaskStatus
}
class MCPAdapter {
-agentRegistry?: AgentRegistry
+handleDelegateTask()
+handleListAgents()
}
AgentRegistry <|.. InMemoryAgentRegistry
AgentAdapter <|.. ClaudeAdapter
AgentAdapter <|.. CodexAdapter
AgentAdapter <|.. GeminiAdapter
AgentAdapter <|.. AiderAdapter
InMemoryAgentRegistry o-- AgentAdapter
EventDrivenWorkerPool --> AgentRegistry
EventDrivenWorkerPool --> Task
MCPAdapter --> AgentRegistry
Task --> AgentAdapter : routes via agent field
Last reviewed commit: d125b77 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds complete multi-agent support to Backbeat (v0.5.0), enabling task delegation to Claude, Codex, Gemini, and Aider through both the MCP protocol and CLI.
Phase 1: Core Agent Abstraction Layer
AgentProvidertype system withAGENT_PROVIDERSconstant andisAgentProvidertype guardAgentAdapterinterface with per-agent implementations (Claude, Codex, Gemini, Aider)InMemoryAgentRegistryfor adapter lifecycle managementProcessSpawnerAdapterfor backward compatibilityagentcolumn to tasks tableAgentRegistryinstead of direct spawningPhase 2: CLI/MCP Surface and Tests
agentfield onDelegateTask,ScheduleTask,CreatePipelineschemas; newListAgentstool--agent/-aflag onbeat run;beat agents listcommand; agent inbeat statusoutputAgentRegistrypassed to MCP adapterFiles Changed
src/core/agents.ts,src/core/domain.tssrc/implementations/claude-adapter.ts,codex-adapter.ts,gemini-adapter.ts,aider-adapter.tssrc/implementations/agent-registry.tssrc/adapters/mcp-adapter.tssrc/cli.ts,src/cli/commands/agents.ts,run.ts,status.ts,help.tssrc/services/schedule-manager.ts,src/bootstrap.tssrc/implementations/database.ts,task-repository.tssrc/implementations/event-driven-worker-pool.tssrc/services/task-manager.tsTest plan
npm run test:core-- 345 passed (includes agents.test.ts, domain.test.ts additions)npm run test:adapters-- 48 passed (includes MCP adapter agent tests)npm run test:implementations-- 284 passed, 3 skipped (includes agent-registry, agent-adapters)npm run test:cli-- 122 passed (includes agent flag parsing, agents list, status display)npm run test:handlers-- 84 passednpm run test:services-- 131 passednpm run test:repositories-- 109 passednpm run test:integration-- 54 passed