Files
codex/codex-rs/prompts/src/multi_agent_instructions_tests.rs
T
rhan-oai 2b5111917c Tag all multi-agent role instructions consistently (#62842)
## Why

Only catalog role instructions carried the `<multi_agent_role>` tag,
so the same guidance appeared in different formats depending on its source.

## What changed

Render bundled, catalog, and configured root and subagent guidance as
`multi_agent.role_instructions` developer messages. Wrap the guidance in
`<multi_agent_role>` tags and preserve configured text that's already tagged.
Match untagged parent guidance by its body when filtering forked history.

## Testing

Update prompt and session assertions for tagged role instructions, and keep
the cold-resume test exercising a rollout with legacy untagged guidance.

GitOrigin-RevId: 60c55b5d7227811b92bd1bf125f1cd3a965720fd
2026-11-20 21:42:17 +00:00

36 lines
1.4 KiB
Rust

//! Covers role composition and attribution for captured model instructions.
use super::*;
use codex_context_fragments::AnnotatedContent;
use codex_context_fragments::RenderedFragment;
use codex_protocol::models::ContentItemMetadata;
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}"
);
let instructions = MultiAgentRoleInstructions::Composed {
base: "Role.\n## Plan tool\nOmit role checklist guidance.\n## Work\nContinue.".to_string(),
omit_update_plan_instructions: true,
max_concurrency: 2,
wait_agent_enabled: true,
expose_model_overrides: true,
};
assert_eq!(
instructions.render_fragment(),
RenderedFragment::new(
"developer",
AnnotatedContent::text(
format!("<multi_agent_role>{expected_body}</multi_agent_role>"),
ContentItemKind("multi_agent.role_instructions".to_string()),
ContentItemMetadata::harness(),
),
),
);
}