mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Add model-specific prefixes to indirect tool descriptions (#47642)
## What changed Add `model_messages.tools.indirect_description_prefixes` with selectors for exact namespaces and configured MCP server names. Apply the selected model's guidance to namespace documentation embedded in `CodeModeOnly` prompts, `ALL_TOOLS` descriptions, and namespaces returned by tool search. Trim prefix values, treat empty values as no prefix, and reject conflicting selectors for the same namespace. Apply prefixes during rendering so model changes take effect without altering direct tool specifications, search ranking, or tool dispatch. ## Testing Add unit tests for prefix normalization, namespace grouping, MCP server mapping, and conflicts. Add scenarios covering both Code Mode variants, clearing prefixes on model changes, unchanged tool dispatch, and conflict rejection before a model request. GitOrigin-RevId: 0c7ce6d418c775945c2ccfdab3c605fa4d431b55
This commit is contained in:
@@ -4,6 +4,8 @@ use crate::tools::context::ToolPayload;
|
||||
use crate::tools::context::boxed_tool_output;
|
||||
use crate::tools::registry::CoreToolRuntime;
|
||||
use crate::tools::registry::ToolExecutor;
|
||||
use codex_prompts::ResolvedModelMessages;
|
||||
use codex_tools::IndirectNamespacePrefixes;
|
||||
use codex_tools::ToolName;
|
||||
use codex_tools::ToolSpec;
|
||||
use std::sync::Arc;
|
||||
@@ -66,6 +68,13 @@ impl CodeModeExecuteHandler {
|
||||
}
|
||||
enabled_tools.sort_by(|left, right| left.name.cmp(&right.name));
|
||||
enabled_tools.dedup_by(|left, right| left.name == right.name);
|
||||
let model_messages = ResolvedModelMessages::from_model(&step_context.settings.model_info);
|
||||
IndirectNamespacePrefixes::new(
|
||||
model_messages.indirect_description_prefixes(),
|
||||
step_context.tool_router.mcp_namespaces(),
|
||||
)
|
||||
.map_err(|error| FunctionCallError::Fatal(error.to_string()))?
|
||||
.apply_code_mode(&mut enabled_tools);
|
||||
let started_at = std::time::Instant::now();
|
||||
let started_cell = exec
|
||||
.session
|
||||
|
||||
Reference in New Issue
Block a user