Support model catalog Apps usage instructions (#61213)

## What changed

- Add the disabled-by-default `catalog_apps_instructions` feature to use the selected model's `model_messages.apps.usage_instructions`, subject to existing Apps availability and model gates.
- Preserve valid catalog text literally, allow an empty string to clear guidance, and fall back to bundled instructions for missing, whitespace-only, or oversized values. Overrides are limited to 800 UTF-8 bytes.
- Reconcile guidance with the latest retained Apps fragment, emitting replacement or removal notices when needed and avoiding repeated updates across resumes. Preserve compatibility with bundled guidance and legacy checkpoints.
- Recognize catalog Apps fragments as contextual developer messages in event mapping and rollout rollback.

## Testing

Add resolver, world-state, client, and scenario coverage for literal text and byte limits, feature and availability gates, model switches, clearing guidance, resumes, and legacy history recovery.

GitOrigin-RevId: 6240d407ada8f22fa101753ff3ddb338632ae283
This commit is contained in:
goodman-oai
2026-11-13 00:29:24 +00:00
committed by copyberry
parent 6c7ecc322f
commit 83a23c0936
24 changed files with 1613 additions and 156 deletions
@@ -11,6 +11,8 @@
use codex_protocol::items::parse_hook_prompt_fragment;
use codex_protocol::models::ContentItem;
use codex_protocol::models::ResponseItem;
use codex_protocol::protocol::APPS_INSTRUCTIONS_OPEN_TAG;
use codex_protocol::protocol::CATALOG_APPS_INSTRUCTIONS_OPEN_TAG;
use codex_protocol::protocol::InterAgentCommunication;
use std::borrow::Borrow;
@@ -89,7 +91,8 @@ fn is_known_contextual_developer_message_content(content: &[ContentItem]) -> boo
"<permissions instructions>",
"<model_switch>",
"<managed_developer_instructions>",
"<apps_instructions>",
APPS_INSTRUCTIONS_OPEN_TAG,
CATALOG_APPS_INSTRUCTIONS_OPEN_TAG,
"<collaboration_mode>",
"<multi_agent_mode>",
"<environments_instructions>",
@@ -942,6 +942,10 @@ async fn migration_rolls_back_response_and_inter_agent_user_boundaries() {
"developer",
"<managed_developer_instructions>context only</managed_developer_instructions>",
)),
rollout_response_item(input_response_message(
"developer",
"<catalog_apps_instructions>context only</catalog_apps_instructions>",
)),
rollout_response_item(input_response_message(
"developer",
"<permissions instructions>context only</permissions instructions>",