diff --git a/internal/csync/maps.go b/internal/csync/maps.go index c24968825140fe134a00e2f09c1df06781c96799..8151e4b6029c93196196dddfd501a21e5b2f2179 100644 --- a/internal/csync/maps.go +++ b/internal/csync/maps.go @@ -27,16 +27,6 @@ func NewMapFrom[K comparable, V any](m map[K]V) *Map[K, V] { } } -// NewMapFromSeq creates a new thread-safe map from an iter.Seq2 of key-value pairs. -func NewMapFromSeq[k comparable, v any](seq iter.Seq2[k, v]) *Map[k, v] { - m := make(map[k]v) - seq(func(kk k, vv v) bool { - m[kk] = vv - return true - }) - return NewMapFrom(m) -} - // NewLazyMap creates a new lazy-loaded map. The provided load function is // executed in a separate goroutine to populate the map. func NewLazyMap[K comparable, V any](load func() map[K]V) *Map[K, V] { diff --git a/internal/csync/maps_test.go b/internal/csync/maps_test.go index 4fd9d5bfbf06db4f2787de6bc8f55dc4e1df44ef..b2b2c979af47eb408666a6456c911b65086c03c2 100644 --- a/internal/csync/maps_test.go +++ b/internal/csync/maps_test.go @@ -37,31 +37,6 @@ func TestNewMapFrom(t *testing.T) { require.Equal(t, 1, value) } -func TestNewMapFromSeq(t *testing.T) { - t.Parallel() - - original := map[string]int{ - "key1": 1, - "key2": 2, - } - seq := func(f func(string, int) bool) { - for k, v := range original { - if !f(k, v) { - break - } - } - } - - m := NewMapFromSeq(seq) - require.NotNil(t, m) - require.Equal(t, original, m.inner) - require.Equal(t, 2, m.Len()) - - value, ok := m.Get("key2") - require.True(t, ok) - require.Equal(t, 2, value) -} - func TestNewLazyMap(t *testing.T) { t.Parallel() diff --git a/internal/llm/agent/agent.go b/internal/llm/agent/agent.go index 5e1716a74db8fb92aebcf1c442db6b1bcf431eed..b66427f0d66c7aecb3628f232e95b3a23ce980b1 100644 --- a/internal/llm/agent/agent.go +++ b/internal/llm/agent/agent.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "log/slog" + "maps" "slices" "strings" "time" @@ -1072,7 +1073,7 @@ func (a *agent) setupEvents() { tools := getTools(ctx, name, c) updateMcpTools(name, tools) // Update the lazy map with the new tools - a.mcpTools = csync.NewMapFromSeq(mcpTools.Seq2()) + a.mcpTools = csync.NewMapFrom(maps.Collect(mcpTools.Seq2())) updateMCPState(name, MCPStateConnected, nil, c, a.mcpTools.Len()) default: continue