mirror of
https://github.com/openai/codex.git
synced 2026-10-31 19:28:49 +00:00
Keep shared MCP types stable in Code Mode exec descriptions (#50536)
## Why Changing a deferred tool's output schema could add or remove the shared MCP type preamble from the `exec` description. ## What changed Include the default or configured MCP TypeScript preamble whenever `code_mode_only` is enabled, regardless of the available tools' output schemas. Preserve an empty preamble override as a way to omit the section. ## Testing Add a regression test that checks description stability when a deferred tool gains an MCP output schema, covering default, custom, and empty preambles. Update description expectations, request snapshots, and two Guardian context-budget test thresholds for the added preamble. GitOrigin-RevId: 725035d6159e9da3c4beff5482c426c082e768b4
This commit is contained in:
@@ -304,17 +304,11 @@ pub fn build_exec_tool_description(
|
||||
return sections.join("\n\n");
|
||||
}
|
||||
|
||||
let has_mcp_tools = enabled_tools
|
||||
.iter()
|
||||
.chain(deferred_tools)
|
||||
.any(|tool| mcp_structured_content_schema(tool.output_schema.as_ref()).is_some());
|
||||
if has_mcp_tools {
|
||||
let preamble = messages
|
||||
.and_then(|messages| messages.mcp_typescript_preamble.as_deref())
|
||||
.unwrap_or(MCP_TYPESCRIPT_PREAMBLE);
|
||||
if !preamble.is_empty() {
|
||||
sections.push(format!("Shared MCP Types:\n```ts\n{preamble}\n```"));
|
||||
}
|
||||
let preamble = messages
|
||||
.and_then(|messages| messages.mcp_typescript_preamble.as_deref())
|
||||
.unwrap_or(MCP_TYPESCRIPT_PREAMBLE);
|
||||
if !preamble.is_empty() {
|
||||
sections.push(format!("Shared MCP Types:\n```ts\n{preamble}\n```"));
|
||||
}
|
||||
|
||||
if !enabled_tools.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user