mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-07-07 04:58:03 +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
|
package multiagent
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
// MCPExecutionBinder maps ADK toolCallID → MCP monitor execution ID for a single agent run.
|
// MCPExecutionBinder maps ADK toolCallID → MCP monitor execution ID for a single agent run.
|
||||||
type MCPExecutionBinder struct {
|
type MCPExecutionBinder struct {
|
||||||
|
mu sync.RWMutex
|
||||||
byToolCall map[string]string
|
byToolCall map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,12 +24,17 @@ func (b *MCPExecutionBinder) Bind(toolCallID, executionID string) {
|
|||||||
if tid == "" || eid == "" {
|
if tid == "" || eid == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
b.mu.Lock()
|
||||||
b.byToolCall[tid] = eid
|
b.byToolCall[tid] = eid
|
||||||
|
b.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *MCPExecutionBinder) ExecutionID(toolCallID string) string {
|
func (b *MCPExecutionBinder) ExecutionID(toolCallID string) string {
|
||||||
if b == nil {
|
if b == nil {
|
||||||
return ""
|
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