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 | // only system-role notes (soft nudges) and empty assistant messages (no text, |
| 299 | // no tool calls - the stall shape the empty-reply nudge answers, appended |
| 300 | // right before that nudge). TrimSpace matches tui.newestAssistantEmpty's |
| 301 | // definition of "empty", so a whitespace-only stall can't mask the recovery. |
| 302 | // Vacuously true for an empty slice. |
| 303 | func onlyNonSubstantive(kept []Message) bool { |
| 304 | for _, m := range kept { |
| 305 | if m.Role == RoleSystem { |
| 306 | continue |
| 307 | } |
| 308 | if m.Role == RoleAssistant && strings.TrimSpace(m.Content) == "" && len(m.ToolCalls) == 0 { |
| 309 | continue |
| 310 | } |
| 311 | return false |
| 312 | } |
| 313 | return true |
| 314 | } |