Debug: add context token count to parser log, fix compact() tool defs
compact() was clearing tool definitions from the system section on startup — now leaves system section untouched (set once by new()). Added context token count to parser done log for diagnosing the subconscious agent loop issue. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
fc75b181cf
commit
8bf6753949
1 changed files with 3 additions and 9 deletions
|
|
@ -491,13 +491,6 @@ impl ResponseParser {
|
|||
let handle = tokio::spawn(async move {
|
||||
let mut parser = self;
|
||||
let agent_name = agent.state.lock().await.provenance.clone();
|
||||
// One-shot debug: dump rendered prompt to file
|
||||
{
|
||||
let ctx = agent.context.lock().await;
|
||||
let rendered = ctx.render();
|
||||
let dump_path = format!("/tmp/poc-{}-prompt.txt", agent_name);
|
||||
let _ = std::fs::write(&dump_path, &rendered);
|
||||
}
|
||||
let log_path = format!("/tmp/poc-{}.log", agent_name);
|
||||
let mut log_file = std::fs::OpenOptions::new()
|
||||
.create(true).append(true).open(&log_path).ok();
|
||||
|
|
@ -524,8 +517,9 @@ impl ResponseParser {
|
|||
if let Some(ref mut f) = log_file {
|
||||
use std::io::Write;
|
||||
let tc_count = full_text.matches("<tool_call>").count();
|
||||
let _ = writeln!(f, "done: {} chars, {} <tool_call> tags",
|
||||
full_text.len(), tc_count);
|
||||
let ctx_tokens = agent.context.lock().await.tokens();
|
||||
let _ = writeln!(f, "done: {} chars, {} <tool_call> tags, ctx: {} tokens",
|
||||
full_text.len(), tc_count, ctx_tokens);
|
||||
if tc_count == 0 && full_text.len() > 0 {
|
||||
let _ = writeln!(f, "full text:\n{}", &full_text[..full_text.len().min(2000)]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue