MCPcopy Create free account
hub / github.com/codehamr/codehamr / newestToolIndex

Function newestToolIndex

internal/ctx/ctx.go:287–294  ·  view source on GitHub ↗

newestToolIndex returns the index of the newest tool-result message in history, or -1. Everything after it can only be non-tool (a system nudge, an assistant summary), so it marks the current turn's newest tool exchange.

(history []Message)

Source from the content-addressed store, hash-verified

285 }
286 group := []Message{history[owner]}
287 for i := owner + 1; i < len(history); i++ {
288 if history[i].Role == RoleTool && ids[history[i].ToolCallID] {
289 group = append(group, history[i])
290 }
291 }
292 return group
293}
294
295// newestToolIndex returns the index of the newest tool-result message in
296// history, or -1. Everything after it can only be non-tool (a system nudge, an
297// assistant summary), so it marks the current turn's newest tool exchange.

Callers 1

PackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected