Fix Thinking/Log panics: skip entries with empty token_ids
Entries with empty token_ids (Thinking, Log) are not part of the prompt and don't have messages. Skip them in streaming_index(), route_entry(), and sync_from_agent() instead of calling .message() which panics. Using token_ids.is_empty() as the guard in streaming_index means the check is tied to the data, not the type — any entry that doesn't produce tokens is safely skipped. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
cb64cdf5fe
commit
603d58e686
2 changed files with 8 additions and 3 deletions
|
|
@ -370,6 +370,7 @@ impl Agent {
|
|||
/// Find the index of the in-progress streaming entry (unstamped assistant message).
|
||||
fn streaming_index(&self) -> Option<usize> {
|
||||
self.context.conversation.entries().iter().rposition(|ce| {
|
||||
if ce.token_ids.is_empty() { return false; }
|
||||
let m = ce.entry.message();
|
||||
m.role == Role::Assistant && m.timestamp.is_none()
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue