MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / BuildToolNameMap

Function BuildToolNameMap

agentContext/micro.go:46–71  ·  view source on GitHub ↗
(messages []map[string]any)

Source from the content-addressed store, hash-verified

44}
45
46func BuildToolNameMap(messages []map[string]any) map[string]string {
47 nameMap := make(map[string]string)
48 for _, msg := range messages {
49 if msg["role"] != "assistant" {
50 continue
51 }
52
53 content, ok := contentBlocks(msg["content"])
54 if !ok {
55 continue
56 }
57 for _, item := range content {
58 itemType, _ := item["type"].(string)
59
60 if itemType != "tool_use" {
61 continue
62 }
63 toolID := getValueFrom(item, "id")
64 toolName := getValueFrom(item, "name")
65 if toolID != "" {
66 nameMap[toolID] = toolName
67 }
68 }
69 }
70 return nameMap
71}
72
73func getValueFrom(item map[string]any, k string) string {
74 value, ok := item[k].(string)

Callers 1

MicroCompactMessagesFunction · 0.85

Calls 2

getValueFromFunction · 0.85
contentBlocksFunction · 0.70

Tested by

no test coverage detected