mirror of
https://github.com/openai/codex.git
synced 2026-11-13 21:30:47 +00:00
## What changed - Read optional tool descriptions and parameter schemas for `history`, `notes`, `new_context`, and `get_context_remaining` from the acting model's catalog messages. - Support catalog namespace descriptions for history and notes, preserving explicit empty and whitespace descriptions. - Share catalog override handling across native tools and MCP resource helpers. Keep bundled schemas when overrides are invalid, preserve encrypted parameters, and leave tool identity and transport fields unchanged. ## Testing Add coverage for sparse catalog serialization, schema fallback and encryption preservation, per-step tool definitions, and context tool updates when switching models. Extend outgoing-request tests to verify history and notes overrides while retaining history image attachments. GitOrigin-RevId: 1adac8b5009f95c91adba491f20a4e2e2dc91475
50 lines
1.8 KiB
Rust
50 lines
1.8 KiB
Rust
//! Applies sparse catalog overrides while preserving bundled tool transport requirements.
|
|
//! Invalid parameters retain the bundled schema; other tool fields remain harness-owned.
|
|
|
|
use crate::ResponsesApiTool;
|
|
use crate::parse_catalog_tool_parameters;
|
|
use codex_protocol::openai_models::ToolMessage;
|
|
|
|
/// Apply catalog descriptions and parameters without changing the tool's identity or transport.
|
|
pub fn with_catalog_tool_message(
|
|
mut tool: ResponsesApiTool,
|
|
messages: Option<&ToolMessage>,
|
|
) -> ResponsesApiTool {
|
|
let Some(messages) = messages else {
|
|
return tool;
|
|
};
|
|
if let Some(description) = &messages.description {
|
|
tool.description.clone_from(description);
|
|
}
|
|
if let Some(parameters) = &messages.parameters {
|
|
let parameters = parse_catalog_tool_parameters(parameters).and_then(|mut parameters| {
|
|
if let Some(properties) = &tool.parameters.properties {
|
|
for (name, bundled_property) in properties.iter() {
|
|
if bundled_property.encrypted == Some(true) {
|
|
let property = parameters
|
|
.properties
|
|
.as_mut()
|
|
.and_then(|properties| properties.get_mut(name))
|
|
.ok_or("schema omits an encrypted parameter")?;
|
|
property.encrypted = Some(true);
|
|
}
|
|
}
|
|
}
|
|
Ok(parameters)
|
|
});
|
|
match parameters {
|
|
Ok(parameters) => tool.parameters = parameters,
|
|
Err(reason) => tracing::warn!(
|
|
tool = %tool.name,
|
|
reason,
|
|
"Invalid catalog tool parameters; using bundled parameters"
|
|
),
|
|
}
|
|
}
|
|
tool
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "catalog_tool_message_tests.rs"]
|
|
mod tests;
|