Files
codex/codex-rs/protocol/src/openai_models/incremental_tools.rs
T
Alex Kira c3936b4b8a Allow model overrides for incremental Code Mode tool messages (#60188)
## What changed

Add `exec_tools_update_hint` and `exec_tools_removed_definitions_header` to `model_messages.tools.incremental_tools` and use them when rendering Code Mode catalog updates and removals.

Overrides are literal strings limited to 512 UTF-8 bytes per field. Missing, null, or oversized values use the existing bundled wording. Empty strings omit the guidance while retaining changed definitions and removal keys. Wording changes alone do not trigger catalog updates.

## Testing

Extend unit coverage for defaults, null fields, independent fallback, and UTF-8 byte limits. Add scenario assertions and a snapshot covering custom and empty wording, model switches, catalog changes, and restoration after compaction.

GitOrigin-RevId: da9e00fdb5197a2b5fa39ce533ba87c76ff3e82c
2026-11-08 01:13:32 +00:00

31 lines
1.6 KiB
Rust

//! Optional model-catalog overrides for harness-owned incremental tool notices.
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
/// Incremental tool notice overrides; missing/null or >512-byte values use bundled defaults.
/// Empty strings omit static text but retain runtime names and instructions.
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
pub struct IncrementalToolMessages {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tool_update_hint: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub removed_tools_header: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub removed_namespaces_header: Option<String>,
/// Prefix supporting `{name}`; the namespace instructions are appended verbatim.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub namespace_instructions_prefix: Option<String>,
/// Message supporting `{name}` when a namespace's instructions are cleared.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub namespace_instructions_cleared: Option<String>,
/// Literal hint before changed Code Mode tool definitions and namespace instructions.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub exec_tools_update_hint: Option<String>,
/// Literal header before removed Code Mode tool and namespace-instruction identities.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub exec_tools_removed_definitions_header: Option<String>,
}