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

Function StripInternalElementsWithErrors

agent/normalize.go:88–121  ·  view source on GitHub ↗
(messages []map[string]any, errorBlockMap map[string][]string)

Source from the content-addressed store, hash-verified

86}
87
88func StripInternalElementsWithErrors(messages []map[string]any, errorBlockMap map[string][]string) []map[string]any {
89 stripTypes := map[string]struct{}{}
90 for _, blockTypes := range errorBlockMap {
91 for _, blockType := range blockTypes {
92 stripTypes[blockType] = struct{}{}
93 }
94 }
95 out := make([]map[string]any, 0, len(messages))
96 for _, msg := range messages {
97 blocks := contentBlocks(msg["content"])
98 if blocks == nil {
99 out = append(out, msg)
100 continue
101 }
102 filtered := make([]map[string]any, 0, len(blocks))
103 for _, block := range blocks {
104 blockType := stringFromAny(block["type"])
105 if _, ok := internalBlockTypes[blockType]; ok {
106 continue
107 }
108 if _, ok := stripTypes[blockType]; ok {
109 continue
110 }
111 filtered = append(filtered, block)
112 }
113 if len(filtered) == 0 {
114 continue
115 }
116 cp := copyMap(msg)
117 cp["content"] = filtered
118 out = append(out, cp)
119 }
120 return out
121}
122
123func HandleThinkingBlocks(messages []map[string]any, modelFamily string, recentErrors []string) []map[string]any {
124 supports := modelSupportsThinking(modelFamily)

Callers 2

StripInternalElementsFunction · 0.85
NormalizeMessagesFunction · 0.85

Calls 3

contentBlocksFunction · 0.70
stringFromAnyFunction · 0.70
copyMapFunction · 0.70

Tested by

no test coverage detected