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
This commit is contained in:
rhan-oai authored and copyberry committed 2026-09-16 21:01:13 +00:00
1 parent 0d083092b4
commit a8c36ca6d2
94 files changed
+2345 -2000

No files matched your search

@@ -16,6 +16,7 @@ use crate::tools::handlers::multi_agents_spec::SpawnAgentToolOptions;
use crate::tools::handlers::multi_agents_spec::create_spawn_agent_tool_v2;
use crate::tools::handlers::multi_agents_v2::message_tool::message_content;
use crate::turn_timing::now_unix_timestamp_ms;
use codex_prompts::ResolvedModelMessages;
use codex_protocol::AgentPath;
use codex_protocol::ThreadId;
use codex_protocol::protocol::MultiAgentVersion;
@@ -175,16 +176,13 @@ async fn handle_spawn_agent(
),
_ => None,
};
let child_catalog = child_model_info
.as_ref()
.unwrap_or(turn.model_info())
.model_messages
.as_ref()
.and_then(|messages| messages.multi_agent.as_ref())
.and_then(|messages| messages.role.as_ref());
let child_multi_agent_messages = ResolvedModelMessages::from_model(
child_model_info.as_ref().unwrap_or(turn.model_info()),
)
.multi_agent();
Some(resolve_usage_hints(
&config.multi_agent_v2,
child_catalog,
child_multi_agent_messages,
!config.update_plan_enabled && config.model_catalog.is_none(),
))
} else {
@@ -22,7 +22,7 @@ use std::collections::BTreeMap;
const TOOL_NAME: &str = "request_user_input_async";
pub struct RequestUserInputAsyncHandler {
pub description: Option<String>,
pub description: String,
}
#[derive(Debug, Deserialize)]
@@ -62,10 +62,7 @@ impl ToolExecutor<ToolInvocation> for RequestUserInputAsyncHandler {
ToolSpec::Function(ResponsesApiTool {
name: TOOL_NAME.to_string(),
description: self.description.clone().unwrap_or_else(|| {
"Ask the user one or more questions during ongoing work. Use this tool only to request missing information, preferences, constraints, clarification, or approval. The tool returns immediately without ending the turn or waiting for a reply; any reply arrives asynchronously as a new user message. Keep questions concise, self-contained, and easy to understand, using a level of detail appropriate to the user and task. The UI always allows a free-text answer, including when suggested options are provided. A preselected option is not submitted automatically."
.to_string()
}),
description: self.description.clone(),
strict: false,
defer_loading: None,
parameters: JsonSchema::object(