From 64157d8fd7951771c166c9c5f70b18d27287b007 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 8 Apr 2026 12:10:54 -0400 Subject: [PATCH] Add assert in append_streaming to catch impossible Thinking entry Debug assertion to help trace the remaining Thinking/Log panic. Co-Authored-By: Proof of Concept --- src/agent/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/agent/mod.rs b/src/agent/mod.rs index 449c2eb..305721a 100644 --- a/src/agent/mod.rs +++ b/src/agent/mod.rs @@ -380,6 +380,8 @@ impl Agent { /// assistant entry if needed). Called by collect_stream per token batch. fn append_streaming(&mut self, text: &str) { if let Some(idx) = self.streaming_index() { + assert!(!self.context.conversation.entries()[idx].token_ids.is_empty(), + "streaming_index returned entry with empty token_ids at {}", idx); let mut msg = self.context.conversation.entries()[idx].entry.message().clone(); msg.append_content(text); self.context.conversation.set_message(idx, msg);