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
+4 -4
View File
@@ -596,7 +596,7 @@ impl ModelInfo {
/// retained for model catalog compatibility.
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
pub struct ModelMessages {
/// Optional model-owned Apps wording, transported without runtime interpretation.
/// Model-owned Apps usage guidance, subject to existing Apps availability and authorization.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub apps: Option<AppsMessages>,
/// Model-owned plugin wording; runtime capability facts and eligibility remain client-owned.
@@ -627,11 +627,11 @@ pub struct ModelMessages {
pub confirmation_policies: Option<ConfirmationPolicies>,
}
/// Optional Apps wording from the model catalog, preserved for future runtime consumption.
/// Literal model-owned Apps guidance inside the existing developer fragment markers.
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
pub struct AppsMessages {
/// Missing and null deserialize as `None`; all strings preserve their exact bytes.
/// Rendering, size limits, and empty-string behavior are defined by consumers.
/// Missing/null uses bundled guidance; empty clears it. Whitespace-only or more than
/// 800 UTF-8 bytes falls back to bundled guidance. Other values preserve exact bytes.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub usage_instructions: Option<String>,
}
+2
View File
@@ -134,6 +134,8 @@ pub const ENVIRONMENTS_INSTRUCTIONS_OPEN_TAG: &str = "<environments_instructions
pub const ENVIRONMENTS_INSTRUCTIONS_CLOSE_TAG: &str = "</environments_instructions>";
pub const APPS_INSTRUCTIONS_OPEN_TAG: &str = "<apps_instructions>";
pub const APPS_INSTRUCTIONS_CLOSE_TAG: &str = "</apps_instructions>";
pub const CATALOG_APPS_INSTRUCTIONS_OPEN_TAG: &str = "<catalog_apps_instructions>";
pub const CATALOG_APPS_INSTRUCTIONS_CLOSE_TAG: &str = "</catalog_apps_instructions>";
pub const SKILLS_INSTRUCTIONS_OPEN_TAG: &str = "<skills_instructions>";
pub const SKILLS_INSTRUCTIONS_CLOSE_TAG: &str = "</skills_instructions>";
pub const PLUGINS_INSTRUCTIONS_OPEN_TAG: &str = "<plugins_instructions>";