pub struct CompactionFork<D> { /* private fields */ }Expand description
A compaction snapshot taken at a request boundary, asking for a D.
Implementations§
Source§impl<D: HandoffSchema> CompactionFork<D>
impl<D: HandoffSchema> CompactionFork<D>
Sourcepub fn new(
request: &LLMRequest,
fork_point: u64,
previous_file_index: &[String],
focus: Option<&str>,
skills: &[SkillCatalogEntry],
attachments: &[AttachmentCatalogEntry],
) -> Result<Self, CompactionError>
pub fn new( request: &LLMRequest, fork_point: u64, previous_file_index: &[String], focus: Option<&str>, skills: &[SkillCatalogEntry], attachments: &[AttachmentCatalogEntry], ) -> Result<Self, CompactionError>
Forks request — the exact request the run is about to send — into a
compaction request for a D, optionally focused by focus.
previous_file_index is the file index of the handoff the result
will replace, and attachments the catalog of attachments the user
messages below fork_point carry, which the instruction offers for
the handoff to name.
The instruction D::instruction
renders is appended and the tool definitions and parameters are
reused untouched: everything up to the instruction is byte-for-byte
what the main request sent, so the provider’s prefix cache still
applies.
§Errors
Returns CompactionError::Empty when the request carries no
conversation to summarize.
Sourcepub fn with_file_references(self, references: Option<AnyFileReferences>) -> Self
pub fn with_file_references(self, references: Option<AnyFileReferences>) -> Self
Sets how the file index finds the files the conversation’s tool results name.
Sourcepub const fn fork_point(&self) -> u64
pub const fn fork_point(&self) -> u64
The sequence number items must reach to survive this compaction.
Sourcepub const fn request(&self) -> &LLMRequest
pub const fn request(&self) -> &LLMRequest
The request the fork replays, instruction included.
Sourcepub async fn run<M: LanguageModel>(
self,
model: M,
) -> Result<CompletedCompaction, CompactionError>
pub async fn run<M: LanguageModel>( self, model: M, ) -> Result<CompletedCompaction, CompactionError>
Runs the compaction against model.
Structured output is attempted first. A schema mismatch — the common
failure for models without native structured output — or a document
D::validate rejects earns one corrective
retry, D::retry, that quotes the failure
back to the model. The accepted document is rendered with the file
index and split into the handoff and its restoration.
§Errors
Returns CompactionError when the provider fails, or when the
retry also fails to produce a valid document.