onlyNonSubstantive reports whether kept carries no substantive conversation: only system-role notes (soft nudges) and empty assistant messages (no text, no tool calls - the stall shape the empty-reply nudge answers, appended right before that nudge). Vacuously true for an empty slice.
(kept []Message)
| 298 | func newestToolIndex(history []Message) int { |
| 299 | for i := len(history) - 1; i >= 0; i-- { |
| 300 | if history[i].Role == RoleTool { |
| 301 | return i |
| 302 | } |
| 303 | } |
| 304 | return -1 |
| 305 | } |
| 306 | |
| 307 | // onlyNonSubstantive reports whether kept carries no substantive conversation: |
| 308 | // only system-role notes (soft nudges) and empty assistant messages (no text, |
| 309 | // no tool calls - the stall shape the empty-reply nudge answers, appended |
| 310 | // right before that nudge). TrimSpace matches tui.newestAssistantEmpty's |
| 311 | // definition of "empty", so a whitespace-only stall can't mask the recovery. |
| 312 | // Vacuously true for an empty slice. |
| 313 | func onlyNonSubstantive(kept []Message) bool { |
| 314 | for _, m := range kept { |