Files
codex/codex-rs/prompts/src/model_instructions.rs
T
rhan-oai a8c36ca6d2 Centralize model-message resolution and rendering in codex-prompts (#46026)
## What changed

- Add `ResolvedModelMessages` to resolve catalog text and bundled defaults while preserving explicit empty overrides and their source.
- Move base-instruction rendering, Guardian prompt composition, multi-agent role rendering, and `update_plan` guidance filtering into `codex-prompts`; migrate consumers to the shared APIs.
- Separate permission-profile resolution from prompt composition, and annotate Guardian policy and classifier instructions with content kinds.

## Testing

Add and update coverage for missing versus empty templates, literal overrides, multi-agent role composition, Guardian policy substitution and truncation, and preservation of permission path spellings and order.

GitOrigin-RevId: 52335bb7acec0f432d5c57acb2accd5f0276056e
2026-09-16 21:01:13 +00:00

22 lines
798 B
Rust

//! Returns literal model instructions from the captured model metadata.
//! Missing templates produce a warning; supplied empty templates remain valid input.
use crate::ResolvedModelMessages;
use codex_protocol::openai_models::ModelInfo;
/// Renders base instructions from the caller's captured model, retaining missing-template warnings.
pub fn render_model_instructions(model_info: &ModelInfo) -> String {
let template = ResolvedModelMessages::from_model(model_info).instructions_template();
if template.is_none() {
tracing::warn!(
model = %model_info.slug,
"Model has no instruction template; returning empty instructions."
);
}
template.unwrap_or_default().to_owned()
}
#[cfg(test)]
#[path = "model_instructions_tests.rs"]
mod tests;