Files
codex/codex-rs/core/src/context/compaction_summary.rs
T
pakrym-oai 287587c32c Classify additional generated context fragments (#40275)
## What changed

- Represent compaction summaries and Guardian-approved actions as typed contextual fragments.
- Inject subagent notifications through the same fragment path.
- Annotate the resulting request items with `compaction.summary`, `guardian.approved_action`, and `multi_agent.subagent_notification` content kinds while preserving their existing roles and text.

## Testing

- Verify the content-kind metadata on compacted summaries, approved actions, and subagent notifications.

GitOrigin-RevId: 01c93e7f08b2dc1c1e85ba69e82bfb5f56e6cca5
2026-08-23 20:08:40 +00:00

38 lines
802 B
Rust

use super::ContextualUserFragment;
use codex_protocol::models::ContentItemKind;
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct CompactionSummary {
summary: String,
}
impl CompactionSummary {
pub(crate) fn new(summary: impl Into<String>) -> Self {
Self {
summary: summary.into(),
}
}
}
impl ContextualUserFragment for CompactionSummary {
fn content_kind(&self) -> ContentItemKind {
ContentItemKind("compaction.summary".to_string())
}
fn role(&self) -> &'static str {
"user"
}
fn markers(&self) -> (&'static str, &'static str) {
Self::type_markers()
}
fn type_markers() -> (&'static str, &'static str) {
("", "")
}
fn body(&self) -> String {
self.summary.clone()
}
}