Capture reasoning/thinking from API stream into Thinking entries
StreamResult now includes accumulated reasoning text. After each stream completes, if reasoning was produced, a Thinking entry is pushed to the conversation before the response message. Reasoning content is visible in the context tree UI but not sent back to the API and doesn't count against the token budget. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
e0ee441aec
commit
7ecc50d2e4
2 changed files with 12 additions and 4 deletions
|
|
@ -477,10 +477,16 @@ impl Agent {
|
|||
).await;
|
||||
let api::StreamResult {
|
||||
content, tool_calls, usage, finish_reason,
|
||||
error: stream_error, display_buf, in_tool_call,
|
||||
error: stream_error, display_buf, in_tool_call, reasoning,
|
||||
} = sr;
|
||||
// --- Stream complete ---
|
||||
|
||||
// Push thinking entry if model produced reasoning
|
||||
if !reasoning.is_empty() {
|
||||
let mut me = agent.lock().await;
|
||||
me.push_entry(context::ConversationEntry::Thinking(reasoning));
|
||||
}
|
||||
|
||||
// --- Lock 3: process results ---
|
||||
let (msg, pending) = {
|
||||
let mut me = agent.lock().await;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue