Add concurrent agent limiting to kugetsu CLI

- Add MAX_CONCURRENT_AGENTS (default: 3) to limit concurrent agents
- Implement acquire_agent_slot() and release_agent_slot() with flock
- Wrap cmd_start, cmd_continue, and cmd_delegate with slot management
- cmd_delegate holds slot until background task completes (fire-and-forget + blocking)
- Add basic concurrency tests to test suite
This commit is contained in:
shokollm
2026-03-31 07:26:00 +00:00
parent dfc87e3da3
commit 3c15d8df1d
12 changed files with 652 additions and 4 deletions

View File

@@ -0,0 +1,107 @@
[
{
"agent_count": 1,
"total_duration": 1.0135109424591064,
"success_count": 0,
"failed_count": 1,
"timeout_count": 0,
"avg_response_time": 0.011479854583740234,
"stddev_response_time": 0,
"min_response_time": 0.011479854583740234,
"max_response_time": 0.011479854583740234,
"peak_cpu_percent": 0.0,
"avg_cpu_percent": 0.0,
"peak_memory_mb": 2177.1123046875,
"avg_memory_mb": 2177.10498046875,
"peak_memory_percent": 0.0,
"avg_memory_percent": 0.0,
"peak_opencode_procs": 0,
"baseline_memory_mb": 2177.1162109375,
"memory_per_agent_mb": -0.00390625,
"total_cost_score": 0
},
{
"agent_count": 2,
"total_duration": 1.0150294303894043,
"success_count": 0,
"failed_count": 2,
"timeout_count": 0,
"avg_response_time": 0.004192829132080078,
"stddev_response_time": 0.0006507473410082039,
"min_response_time": 0.0037326812744140625,
"max_response_time": 0.004652976989746094,
"peak_cpu_percent": 0.0,
"avg_cpu_percent": 0.0,
"peak_memory_mb": 2175.671875,
"avg_memory_mb": 2175.529296875,
"peak_memory_percent": 0.0,
"avg_memory_percent": 0.0,
"peak_opencode_procs": 0,
"baseline_memory_mb": 2175.13671875,
"memory_per_agent_mb": 0.267578125,
"total_cost_score": 0.0005431993436068297
},
{
"agent_count": 3,
"total_duration": 1.0151348114013672,
"success_count": 0,
"failed_count": 3,
"timeout_count": 0,
"avg_response_time": 0.00410922368367513,
"stddev_response_time": 0.0005485598755713246,
"min_response_time": 0.0034792423248291016,
"max_response_time": 0.004481315612792969,
"peak_cpu_percent": 0.0,
"avg_cpu_percent": 0.0,
"peak_memory_mb": 2175.234375,
"avg_memory_mb": 2175.171875,
"peak_memory_percent": 0.0,
"avg_memory_percent": 0.0,
"peak_opencode_procs": 0,
"baseline_memory_mb": 2174.984375,
"memory_per_agent_mb": 0.08333333333333333,
"total_cost_score": 0.0002537837028503418
},
{
"agent_count": 5,
"total_duration": 1.0233359336853027,
"success_count": 0,
"failed_count": 5,
"timeout_count": 0,
"avg_response_time": 0.003859806060791016,
"stddev_response_time": 0.0005061271938518695,
"min_response_time": 0.003265857696533203,
"max_response_time": 0.004559516906738281,
"peak_cpu_percent": 0.0,
"avg_cpu_percent": 0.0,
"peak_memory_mb": 2174.8115234375,
"avg_memory_mb": 2174.765625,
"peak_memory_percent": 0.0,
"avg_memory_percent": 0.0,
"peak_opencode_procs": 0,
"baseline_memory_mb": 2174.7197265625,
"memory_per_agent_mb": 0.018359375,
"total_cost_score": 9.393904078751803e-05
},
{
"agent_count": 8,
"total_duration": 1.0180647373199463,
"success_count": 0,
"failed_count": 8,
"timeout_count": 0,
"avg_response_time": 0.0040419697761535645,
"stddev_response_time": 0.0005073540280823215,
"min_response_time": 0.0034415721893310547,
"max_response_time": 0.004962921142578125,
"peak_cpu_percent": 0.0,
"avg_cpu_percent": 0.0,
"peak_memory_mb": 2175.9697265625,
"avg_memory_mb": 2175.328125,
"peak_memory_percent": 0.0,
"avg_memory_percent": 0.0,
"peak_opencode_procs": 0,
"baseline_memory_mb": 2174.6826171875,
"memory_per_agent_mb": 0.160888671875,
"total_cost_score": 0.0013103606677614152
}
]