Files
codex/codex-rs/core/src/context/base_instructions.rs
T
pakrym-oai 0df76892b1 Support ordered response items in world-state context updates (#50441)
## Why

World-state sections could return only a single optional text fragment, with message separation controlled by the fragment itself. They could not contribute explicit `ResponseItem` values alongside instructions.

## What changed

- Let sections return ordered `WorldStateUpdate` values containing fragments or response items, with `Prefix`, `Standalone`, or `Mergeable` placement.
- Preserve explicit item boundaries when grouping context updates, and place prefix updates first when assembling initial context.
- Move standalone-message decisions from fragments to world-state updates and retain snapshot handling.

## Testing

Add tests for mixed fragment/item ordering, role and standalone boundaries, initial-context prefix placement, and snapshot restoration without repeated updates.

GitOrigin-RevId: c2514c3c98538da83f5140c10a9d89f531de6549
2026-10-02 22:12:07 +00:00

28 lines
659 B
Rust

use super::ContextualUserFragment;
use codex_protocol::models::ContentItemKind;
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct BaseInstructionsFragment(pub(crate) String);
impl ContextualUserFragment for BaseInstructionsFragment {
fn content_kind(&self) -> ContentItemKind {
ContentItemKind("model.base_instructions".to_string())
}
fn role(&self) -> &'static str {
"developer"
}
fn markers(&self) -> (&'static str, &'static str) {
Self::type_markers()
}
fn type_markers() -> (&'static str, &'static str) {
("", "")
}
fn body(&self) -> String {
self.0.clone()
}
}