Fully Automated - 100% Backpressure - Pipeline runner 🏃 for AI workflows. 🚀

Commit 47d0574f

47d0574f5e12Merged

Scott Nixon <[email protected]> · 7 months ago · 18 files · ~18 modified

Description

fix: address correctness and robustness issues across 7 crates

  • Add GoalGateUnsatisfied, NoRetryTarget, RetriesExhausted to is_terminal()
  • Fix strip_comments leaking chars from unclosed block comments at EOF
  • Fix offset_to_line_col misleading parameter name and doc comment
  • Fix truncation warning reporting bytes as "characters"
  • Preserve system prompt in Truncate fidelity mode
  • Kill process group (-pid) in codergen_handler to match tool_handler
  • Add missing #[cfg(unix)] guard on libc::kill in tool_handler
  • Concatenate multiple Anthropic thinking blocks instead of overwriting
  • Add ContentFiltered variant to FinishReason for Gemini SAFETY
  • Add tracing::warn on silent edge selection fallback
  • Fix FNV-1a hash to XOR-then-multiply per spec
  • Fix boolean parser accepting prefixes like "truefoo"
  • Move edge chain node creation outside windows(2) loop
  • Fix undirected graph rejection for "graph[" edge case
  • Use spawn_blocking for stdin in ConsoleInterviewer
  • Check fallback_retry_target in GoalGateHasRetryRule
  • Fix extract_label substring false matches with word boundaries
  • Preserve step_count/total_cost in checkpoint with_session_id
  • Fix truncation reporting byte counts as character counts
  • Use char-safe truncation in CLI debug output

Details

Commit
47d0574f5e12
Parent
059c568480ad

crates/attractor-agent/src/fidelity.rsmodifiedView file

@@ -38,14 +38,24 @@
3838
3939 /// Apply fidelity mode to a message history.
4040 /// Returns the processed messages (does NOT modify in place).
41+///
42+/// The first message (typically the system prompt) is always preserved
43+/// by `Truncate` mode to avoid losing LLM persona/instructions.
4144 pub fn apply_fidelity<T: Clone>(messages: &[T], mode: &FidelityMode) -> Vec<T> {
4245 match mode {
4346 FidelityMode::Full => messages.to_vec(),
4447 FidelityMode::Truncate { keep_last } => {
4548 if messages.len() <= *keep_last {
4649 messages.to_vec()
50+ } else if *keep_last == 0 {
51+ Vec::new()
4752 } else {
48- messages[messages.len() - keep_last..].to_vec()
53+ // Always preserve the first message (system prompt), then
54+ // keep the most recent (keep_last - 1) messages.
55+ let tail_count = keep_last - 1;
56+ let mut result = vec![messages[0].clone()];
57+ result.extend_from_slice(&messages[messages.len() - tail_count..]);
58+ result
4959 }
5060 }
5161 FidelityMode::Compact | FidelityMode::Summary => {
@@ -125,10 +135,11 @@
125135 }
126136
127137 #[test]
128- fn apply_fidelity_truncate_keeps_last_n() {
138+ fn apply_fidelity_truncate_preserves_first_and_keeps_last() {
129139 let msgs = vec![1, 2, 3, 4, 5];
140+ // keep_last=3 → first message (system prompt) + last 2 messages
130141 let result = apply_fidelity(&msgs, &FidelityMode::Truncate { keep_last: 3 });
131- assert_eq!(result, vec![3, 4, 5]);
142+ assert_eq!(result, vec![1, 4, 5]);
132143 }
133144
134145 #[test]