Files
codex/codex-rs/prompts/src/multi_agent_instructions_tests.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

43 lines
1.6 KiB
Rust

//! Covers role composition and attribution for captured model instructions.
use super::*;
use codex_context_fragments::AnnotatedContent;
use codex_context_fragments::RenderedFragment;
use pretty_assertions::assert_eq;
#[test]
fn role_segment_filters_base_and_appends_bundled_guidance() {
let shared = DEFAULT_MULTI_AGENT_V2_SHARED_USAGE_HINT_TEXT;
let wait = DEFAULT_MULTI_AGENT_V2_WAIT_AGENT_USAGE_HINT_TEXT;
let model_override = DEFAULT_MULTI_AGENT_V2_MODEL_OVERRIDE_USAGE_HINT_TEXT;
let expected_body = format!(
"Role.\n## Work\nContinue.\n{shared}\n{wait}\n\nThere are 2 available concurrency slots, meaning that up to 2 agents can be active at once, including you.\n\n{model_override}"
);
for marked in [false, true] {
let instructions = MultiAgentRoleInstructions::Composed {
base: "Role.\n## Plan tool\nOmit role checklist guidance.\n## Work\nContinue."
.to_string(),
marked,
omit_update_plan_instructions: true,
max_concurrency: 2,
wait_agent_enabled: true,
expose_model_overrides: true,
};
let expected_text = if marked {
format!("<multi_agent_role>{expected_body}</multi_agent_role>")
} else {
expected_body.clone()
};
assert_eq!(
instructions.render_fragment(),
RenderedFragment::new(
"developer",
AnnotatedContent::input_text(
expected_text,
ContentItemKind("multi_agent.role_instructions".to_string()),
),
),
);
}
}