mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-07-06 20:47:57 +02:00
Merge pull request #183 from flydreamsec/fix/mcp-execution-binder-race
fix(multiagent): guard MCPExecutionBinder map with RWMutex (concurrent tool callback race)
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package multiagent
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// MCPExecutionBinder maps ADK toolCallID → MCP monitor execution ID for a single agent run.
|
||||
type MCPExecutionBinder struct {
|
||||
mu sync.RWMutex
|
||||
byToolCall map[string]string
|
||||
}
|
||||
|
||||
@@ -20,12 +24,17 @@ func (b *MCPExecutionBinder) Bind(toolCallID, executionID string) {
|
||||
if tid == "" || eid == "" {
|
||||
return
|
||||
}
|
||||
b.mu.Lock()
|
||||
b.byToolCall[tid] = eid
|
||||
b.mu.Unlock()
|
||||
}
|
||||
|
||||
func (b *MCPExecutionBinder) ExecutionID(toolCallID string) string {
|
||||
if b == nil {
|
||||
return ""
|
||||
}
|
||||
return b.byToolCall[strings.TrimSpace(toolCallID)]
|
||||
tid := strings.TrimSpace(toolCallID)
|
||||
b.mu.RLock()
|
||||
defer b.mu.RUnlock()
|
||||
return b.byToolCall[tid]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user