Skip to main content

SpanSummarizer

Trait SpanSummarizer 

Source
pub trait SpanSummarizer {
    // Required methods
    fn summarize(&self, span_text: &str) -> Result<String, ReductionError>;
    fn model_id(&self) -> &str;
}
Expand description

Injectable summarization side-call (SPEC.md TR-7’s “explicit, budgeted, injectable side-call”). A real implementation calls out to a cheap model; tests inject a deterministic fake (and, for the dev/03 fault-injection AC, one that always errors) — nothing in this crate’s own test suite ever performs a real network/model call.

Required Methods§

Source

fn summarize(&self, span_text: &str) -> Result<String, ReductionError>

Summarize span_text (the rendering render_span_text produces) into a short paragraph. Err — for any reason, including a caller-modeled timeout or budget exhaustion — means the caller must fall back to the deterministic stub; this call must never block or fail the surrounding reduce pass.

Threading note for implementers. This method is synchronous, and is invoked synchronously from Agent::build_request_messages (via super::prepare_cleared_turns_summary), which itself runs on a tokio worker thread as part of Agent::run_loop’s async machinery. No implementation in this crate performs real network I/O — only in-memory test stubs implement this trait today — but a FUTURE real, provider-backed implementation must NOT perform a blocking network call inline here: doing so would stall that tokio worker thread on every reduce cycle in which TR-7 fires. Such an implementation must instead run the call off-thread and block only on that (e.g. tokio::task::block_in_place + Handle::block_on, or a dedicated blocking thread/pool joined synchronously), so the surrounding async runtime is never starved by this call.

Source

fn model_id(&self) -> &str

Identifier of the model behind this summarizer (e.g. "claude-haiku-4-5"), recorded on super::SpanSummary::model_id for the audit trail (SPEC.md TR-7 dev/04).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§