Align debug screen and budget with conversation-only messages
context.messages is conversation-only now — remove conv_start scanning. Memory counted from loaded_nodes (same as debug screen). No subtraction heuristics. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
5e781e9ae4
commit
acdfbeeac3
1 changed files with 3 additions and 7 deletions
|
|
@ -195,9 +195,8 @@ impl Agent {
|
|||
.map(|e| count(&e.content)).sum();
|
||||
let mem_tokens: usize = self.context.loaded_nodes.iter()
|
||||
.map(|node| count(&node.render())).sum();
|
||||
let total_conv: usize = self.context.messages.iter()
|
||||
let conv_tokens: usize = self.context.messages.iter()
|
||||
.map(|m| crate::agent::context::msg_token_count(&self.tokenizer, m)).sum();
|
||||
let conv_tokens = total_conv.saturating_sub(mem_tokens);
|
||||
|
||||
self.context_budget = ContextBudget {
|
||||
identity_tokens: id_tokens,
|
||||
|
|
@ -695,10 +694,7 @@ impl Agent {
|
|||
}
|
||||
|
||||
// Conversation — each message as a child
|
||||
let conv_start = self.context.messages.iter()
|
||||
.position(|m| m.role == Role::Assistant || m.role == Role::Tool)
|
||||
.unwrap_or(self.context.messages.len());
|
||||
let conv_messages = &self.context.messages[conv_start..];
|
||||
let conv_messages = &self.context.messages;
|
||||
let conv_children: Vec<ContextSection> = conv_messages.iter().enumerate()
|
||||
.map(|(i, msg)| {
|
||||
let text = msg.content.as_ref()
|
||||
|
|
@ -726,7 +722,7 @@ impl Agent {
|
|||
Role::System => "system",
|
||||
};
|
||||
ContextSection {
|
||||
name: format!("[{}] {}: {}", conv_start + i, role_name, label),
|
||||
name: format!("[{}] {}: {}", i, role_name, label),
|
||||
tokens,
|
||||
content: text,
|
||||
children: Vec::new(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue