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 <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-08 12:10:54 -04:00
parent 603d58e686
commit 64157d8fd7

View file

@ -380,6 +380,8 @@ impl Agent {
/// assistant entry if needed). Called by collect_stream per token batch. /// assistant entry if needed). Called by collect_stream per token batch.
fn append_streaming(&mut self, text: &str) { fn append_streaming(&mut self, text: &str) {
if let Some(idx) = self.streaming_index() { 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(); let mut msg = self.context.conversation.entries()[idx].entry.message().clone();
msg.append_content(text); msg.append_content(text);
self.context.conversation.set_message(idx, msg); self.context.conversation.set_message(idx, msg);