Files
codex/codex-rs/core/src/context/developer_instructions.rs
T
pakrym-oai a70974c1a0 Preserve developer instruction annotations in subagent forks (#40297)
## What changed

- Add a dedicated contextual fragment for developer instructions that emits the
  `generic.developer_instructions` content kind.
- Use the fragment when adding child-specific developer instructions to a
  full-history subagent fork, preserving their classification and ensuring they
  reach the child exactly once without appearing in the parent request.

## Testing

- Extend full-history subagent coverage to verify the child-only instructions'
  annotation, placement, and count.

GitOrigin-RevId: 82589d311535225fed76d500a19458fda72f40f2
2026-08-23 23:56:23 +00:00

38 lines
856 B
Rust

use super::ContextualUserFragment;
use codex_protocol::models::ContentItemKind;
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct DeveloperInstructions {
instructions: String,
}
impl DeveloperInstructions {
pub(crate) fn new(instructions: impl Into<String>) -> Self {
Self {
instructions: instructions.into(),
}
}
}
impl ContextualUserFragment for DeveloperInstructions {
fn content_kind(&self) -> ContentItemKind {
ContentItemKind("generic.developer_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.instructions.clone()
}
}