TurnResult: remove text field, simplify oneshot loop

- Remove TurnResult.text (was dead code - Agent::turn handles text internally)
- Simplify run_with_backend to just iterate over steps (Agent::turn loops
  for tool calls and handles empty responses internally)
- Change run/run_shared/run_forked_shared to return Result<(), String>
- Remove AgentResult.output field (no callers used it)
- Stub out legacy text-parsing code (audit, compare) that needs redesign
- Update digest.rs to not depend on text return
- Add level parameter to journal_new/journal_update for digest support

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-12 02:04:50 -04:00
commit f00532bdb7
11 changed files with 79 additions and 419 deletions

View file

@ -2,11 +2,12 @@
//
// Each batch of links gets reviewed by Sonnet, which returns per-link actions:
// KEEP, DELETE, RETARGET, WEAKEN, STRENGTHEN. Batches run in parallel via rayon.
//
// TODO: Redesign to use tool-based agent instead of text parsing.
use crate::store::{self, Store, new_relation};
use std::collections::HashSet;
use crate::store::Store;
#[allow(dead_code)]
struct LinkInfo {
rel_idx: usize,
source_key: String,
@ -26,6 +27,7 @@ pub struct AuditStats {
pub errors: usize,
}
#[allow(dead_code)]
fn build_audit_prompt(batch: &[LinkInfo], batch_num: usize, total_batches: usize) -> String {
let mut prompt = format!(
"You are auditing memory graph links for quality (batch {}/{}).\n\n\
@ -63,6 +65,7 @@ fn build_audit_prompt(batch: &[LinkInfo], batch_num: usize, total_batches: usize
prompt
}
#[allow(dead_code)]
fn parse_audit_response(response: &str, batch_size: usize) -> Vec<(usize, AuditAction)> {
let mut actions = Vec::new();
@ -109,6 +112,7 @@ fn parse_audit_response(response: &str, batch_size: usize) -> Vec<(usize, AuditA
actions
}
#[allow(dead_code)]
enum AuditAction {
Keep,
Delete,
@ -118,7 +122,11 @@ enum AuditAction {
}
/// Run a full link audit: walk every link, batch to Sonnet, apply results.
pub fn link_audit(store: &mut Store, apply: bool) -> Result<AuditStats, String> {
pub fn link_audit(_store: &mut Store, _apply: bool) -> Result<AuditStats, String> {
// TODO: Reimplement to use tool-based agent instead of text parsing
Err("link_audit disabled: needs redesign to use tool-based agent".to_string())
/*
// Collect all non-deleted relations with their info
let mut links: Vec<LinkInfo> = Vec::new();
@ -330,4 +338,5 @@ pub fn link_audit(store: &mut Store, apply: bool) -> Result<AuditStats, String>
}
Ok(stats)
*/
}