From f8bee4b4ad7600a7362dc3c82d585c221e3faabe Mon Sep 17 00:00:00 2001 From: Snider Date: Sun, 15 Mar 2026 19:00:19 +0000 Subject: [PATCH] fix(agentic): match concurrency limits on base agent type gemini:flash, gemini:pro now match the "gemini" concurrency limit. Strips model variant before checking config. Prevents unlimited spawning when using model variants. Co-Authored-By: Virgil --- pkg/mcp/agentic/queue.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/mcp/agentic/queue.go b/pkg/mcp/agentic/queue.go index 4d2b1d7..76d7868 100644 --- a/pkg/mcp/agentic/queue.go +++ b/pkg/mcp/agentic/queue.go @@ -7,6 +7,7 @@ import ( "os" "os/exec" "path/filepath" + "strings" "syscall" "time" @@ -118,7 +119,12 @@ func (s *PrepSubsystem) countRunningByAgent(agent string) int { } st, err := readStatus(filepath.Join(wsRoot, entry.Name())) - if err != nil || st.Status != "running" || st.Agent != agent { + if err != nil || st.Status != "running" { + continue + } + // Match on base agent type (gemini:flash matches gemini) + stBase := strings.SplitN(st.Agent, ":", 2)[0] + if stBase != agent { continue } @@ -133,14 +139,20 @@ func (s *PrepSubsystem) countRunningByAgent(agent string) int { return count } +// baseAgent strips the model variant (gemini:flash → gemini). +func baseAgent(agent string) string { + return strings.SplitN(agent, ":", 2)[0] +} + // canDispatchAgent checks if we're under the concurrency limit for a specific agent type. func (s *PrepSubsystem) canDispatchAgent(agent string) bool { cfg := s.loadAgentsConfig() - limit, ok := cfg.Concurrency[agent] + base := baseAgent(agent) + limit, ok := cfg.Concurrency[base] if !ok || limit <= 0 { return true } - return s.countRunningByAgent(agent) < limit + return s.countRunningByAgent(base) < limit } // canDispatch is kept for backwards compat.