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

Function InsertBeforeCurrentUserMessage

agent/message_injection.go:29–48  ·  view source on GitHub ↗
(state *AgentState, message map[string]any)

Source from the content-addressed store, hash-verified

27 if stringFromAny(candidate["role"]) != "user" {
28 continue
29 }
30 if isToolResultCarrierMessage(candidate) {
31 continue
32 }
33 idx = i
34 break
35 }
36 state.Messages = append(state.Messages, nil)
37 copy(state.Messages[idx+1:], state.Messages[idx:])
38 state.Messages[idx] = message
39}
40
41func StripMessageMetadata(messages []map[string]any) []map[string]any {
42 out := make([]map[string]any, 0, len(messages))
43 for _, msg := range messages {
44 cleaned := map[string]any{}
45 for key, value := range msg {
46 if key == "metadata" || key == "isMeta" {
47 continue
48 }
49 cleaned[key] = value
50 }
51 out = append(out, cleaned)

Calls 2

stringFromAnyFunction · 0.70