Kill log callback — use ConversationEntry::Log for debug traces

Add Log variant to ConversationEntry that serializes to the
conversation log but is filtered out on read-back and API calls.
AutoAgent writes debug/status info (turns, tokens, tool calls)
through the conversation log instead of a callback parameter.

Removes the log callback from run_one_agent, call_api_with_tools,
and all callers.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-07 01:23:22 -04:00
parent 7c0d8b79d9
commit b37b6d7495
8 changed files with 74 additions and 73 deletions

View file

@ -211,7 +211,7 @@ pub fn link_audit(store: &mut Store, apply: bool) -> Result<AuditStats, String>
let batch_results: Vec<_> = batch_data.par_iter()
.map(|(batch_idx, batch_infos, prompt)| {
let response = crate::agent::oneshot::call_api_with_tools_sync(
"audit", &[prompt.clone()], &[], None, 10, &[], None, &|_| {});
"audit", &[prompt.clone()], &[], None, 10, &[], None);
let completed = done.fetch_add(1, Ordering::Relaxed) + 1;
eprint!("\r Batches: {}/{} done", completed, total_batches);
(*batch_idx, batch_infos, response)

View file

@ -74,7 +74,7 @@ pub fn consolidate_full_with_progress(
*store = Store::load()?;
}
match oneshot::run_one_agent(store, agent_type, *count, None, &|_| {}) {
match oneshot::run_one_agent(store, agent_type, *count, None) {
Ok(_) => {
let msg = " Done".to_string();
log_line(&mut log_buf, &msg);

View file

@ -119,12 +119,8 @@ fn job_targeted_agent(
run_job(ctx, &job_name, || {
let mut store = crate::store::Store::load()?;
ctx.log_line(format!("targeting: {}", key));
let log = |msg: &str| {
ctx.log_line(msg);
log_event(&job_name, "progress", msg);
};
crate::agent::oneshot::run_one_agent(
&mut store, &agent, 5, Some(std::slice::from_ref(&key)), &log,
&mut store, &agent, 5, Some(std::slice::from_ref(&key)),
)?;
ctx.log_line("done");
Ok(())
@ -202,14 +198,10 @@ fn job_consolidation_agent(
}
// in_flight lock released — run LLM without holding it
let log = |msg: &str| {
ctx.log_line(msg);
log_event(&job_name, "progress", msg);
};
// Use run_one_agent_with_keys — we already selected seeds above,
// no need to re-run the query.
let result = crate::agent::oneshot::run_one_agent(
&mut store, &agent, batch, Some(&claimed_keys), &log,
&mut store, &agent, batch, Some(&claimed_keys),
).map(|_| ());
// Release all claimed keys (seeds + neighbors)
@ -238,8 +230,7 @@ fn job_rename_agent(
let batch = if batch_size == 0 { 10 } else { batch_size };
ctx.log_line(format!("running rename agent (batch={})", batch));
let log = |msg: &str| ctx.log_line(msg);
let result = crate::agent::oneshot::run_one_agent(&mut store, "rename", batch, None, &log)?;
let result = crate::agent::oneshot::run_one_agent(&mut store, "rename", batch, None)?;
// Parse RENAME actions from response (rename uses its own format, not WRITE_NODE/LINK/REFINE)
let mut applied = 0;

View file

@ -286,7 +286,7 @@ fn generate_digest(
};
let digest = crate::agent::oneshot::call_api_with_tools_sync(
&def.agent, &prompts, &phases, def.temperature, def.priority,
&tools, None, &log)?;
&tools, None)?;
let key = digest_node_key(level.name, label);
store.upsert_provenance(&key, &digest, "digest:write")?;