fix(#338): Add max concurrent agents limit
- Add MAX_CONCURRENT_AGENTS configuration (default: 20) - Check current agent count before spawning - Reject spawn requests with 429 Too Many Requests when limit reached - Add comprehensive tests for limit enforcement Refs #338
This commit is contained in:
@@ -83,4 +83,30 @@ describe("orchestratorConfig", () => {
|
||||
expect(config.valkey.url).toBe("redis://localhost:6379");
|
||||
});
|
||||
});
|
||||
|
||||
describe("spawner config", () => {
|
||||
it("should use default maxConcurrentAgents of 20 when not set", () => {
|
||||
delete process.env.MAX_CONCURRENT_AGENTS;
|
||||
|
||||
const config = orchestratorConfig();
|
||||
|
||||
expect(config.spawner.maxConcurrentAgents).toBe(20);
|
||||
});
|
||||
|
||||
it("should use provided maxConcurrentAgents when MAX_CONCURRENT_AGENTS is set", () => {
|
||||
process.env.MAX_CONCURRENT_AGENTS = "50";
|
||||
|
||||
const config = orchestratorConfig();
|
||||
|
||||
expect(config.spawner.maxConcurrentAgents).toBe(50);
|
||||
});
|
||||
|
||||
it("should handle MAX_CONCURRENT_AGENTS of 10", () => {
|
||||
process.env.MAX_CONCURRENT_AGENTS = "10";
|
||||
|
||||
const config = orchestratorConfig();
|
||||
|
||||
expect(config.spawner.maxConcurrentAgents).toBe(10);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,4 +37,7 @@ export const orchestratorConfig = registerAs("orchestrator", () => ({
|
||||
yolo: {
|
||||
enabled: process.env.YOLO_MODE === "true",
|
||||
},
|
||||
spawner: {
|
||||
maxConcurrentAgents: parseInt(process.env.MAX_CONCURRENT_AGENTS ?? "20", 10),
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user