Skip to main content

summarize_edit

Function summarize_edit 

Source
pub fn summarize_edit(
    diff: &str,
    affected_files: &[&str],
    sampling: &dyn SamplingProvider,
) -> String
Expand description

Generate a summary of an edit event for the experience pool.

When a SamplingProvider is available, builds a structured prompt from the diff and affected file list and requests a natural-language summary via the provider. The diff is truncated to MAX_DIFF_CHARS characters to stay within context-window limits.

Falls back gracefully to listing affected files when sampling is unavailable or when the sampling call fails for any reason.

§Blocking behaviour

This function synchronously blocks on the async SamplingProvider::sample call using tokio::task::block_in_place. It must therefore be called from within a multi-threaded tokio runtime (the default for #[tokio::main]).

§Examples

use synwire_core::NoopSamplingProvider;
use synwire_agent::experience_sampling::summarize_edit;
let p = NoopSamplingProvider;
let summary = summarize_edit("- old line\n+ new line", &["src/main.rs"], &p);
assert!(summary.contains("src/main.rs"));