diff --git a/internal/multiagent/mcp_execution_binder.go b/internal/multiagent/mcp_execution_binder.go index 3e33b724..79fec45b 100644 --- a/internal/multiagent/mcp_execution_binder.go +++ b/internal/multiagent/mcp_execution_binder.go @@ -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] }