(state *AgentState, memoryDir string)
| 17 | } |
| 18 | } |
| 19 | |
| 20 | func InsertBeforeCurrentUserMessage(state *AgentState, message map[string]any) { |
| 21 | if state == nil { |
| 22 | return |
| 23 | } |
| 24 | idx := len(state.Messages) |
| 25 | for i := len(state.Messages) - 1; i >= 0; i-- { |
| 26 | candidate := state.Messages[i] |
| 27 | if stringFromAny(candidate["role"]) != "user" { |
| 28 | continue |
| 29 | } |
| 30 | if isToolResultCarrierMessage(candidate) { |