pub struct CompactStrategy {
pub enabled: bool,
pub threshold_percent: f32,
pub summary_model: String,
pub max_summary_tokens: u32,
pub keep_coding_instructions: bool,
pub custom_instructions: Option<String>,
}Expand description
Strategy for context compaction.
Controls when and how conversation history is summarized to fit within
context limits. The keep_coding_instructions flag determines whether
detailed coding information (code snippets, file changes, function
signatures) is preserved in summaries.
This flag mirrors OutputStyle::keep_coding_instructions for consistency.
Fields§
§enabled: bool§threshold_percent: f32§summary_model: String§max_summary_tokens: u32§keep_coding_instructions: boolWhen true, includes detailed coding information in summaries:
- Full code snippets
- File names and changes
- Function signatures
- Error details and fixes
When false, creates a minimal summary focusing on:
- Primary request and intent
- Key decisions made
- Current work status
- Next steps
This mirrors OutputStyle::keep_coding_instructions for API consistency.
custom_instructions: Option<String>Optional custom instructions to append to the compact prompt. These are user-provided instructions for customizing the summary.
Implementations§
Source§impl CompactStrategy
impl CompactStrategy
pub fn disabled() -> Self
pub fn with_threshold(self, percent: f32) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Sourcepub fn with_keep_coding_instructions(self, keep: bool) -> Self
pub fn with_keep_coding_instructions(self, keep: bool) -> Self
Set whether to keep detailed coding information in summaries.
This mirrors the keep_coding_instructions flag in OutputStyle.
Sourcepub fn with_custom_instructions(self, instructions: impl Into<String>) -> Self
pub fn with_custom_instructions(self, instructions: impl Into<String>) -> Self
Set custom instructions for the compact prompt.
Sourcepub fn from_output_style(style: &OutputStyle) -> Self
Available on crate feature cli-integration only.
pub fn from_output_style(style: &OutputStyle) -> Self
cli-integration only.Create a CompactStrategy that inherits coding instruction preference from OutputStyle.
Trait Implementations§
Source§impl Clone for CompactStrategy
impl Clone for CompactStrategy
Source§fn clone(&self) -> CompactStrategy
fn clone(&self) -> CompactStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompactStrategy
impl Debug for CompactStrategy
Source§impl Default for CompactStrategy
impl Default for CompactStrategy
Source§impl<'de> Deserialize<'de> for CompactStrategy
impl<'de> Deserialize<'de> for CompactStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for CompactStrategy
impl RefUnwindSafe for CompactStrategy
impl Send for CompactStrategy
impl Sync for CompactStrategy
impl Unpin for CompactStrategy
impl UnsafeUnpin for CompactStrategy
impl UnwindSafe for CompactStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D> DeserializeWith<JsonFormat> for Dwhere
D: DeserializeOwned,
impl<D> DeserializeWith<JsonFormat> for Dwhere
D: DeserializeOwned,
Source§fn deserialize_with(body: ResponseBody) -> Result<D, Error>
fn deserialize_with(body: ResponseBody) -> Result<D, Error>
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more