mirror of
https://github.com/openai/codex.git
synced 2026-06-02 19:31:59 +00:00
fixes
This commit is contained in:
@@ -185,7 +185,7 @@ mod tests {
|
||||
"additionalProperties": false,
|
||||
}),
|
||||
},
|
||||
Arc::new(StubExtensionExecutor),
|
||||
Arc::new(StubExtensionExecutor) as Arc<dyn codex_tool_api::ToolExecutor>,
|
||||
);
|
||||
let handler = ExtensionToolHandler::new(definition);
|
||||
let (session, turn) = crate::session::tests::make_session_and_context().await;
|
||||
|
||||
@@ -70,7 +70,6 @@ pub use shell::ShellHandler;
|
||||
pub use test_sync::TestSyncHandler;
|
||||
pub use tool_search::ToolSearchHandler;
|
||||
pub use unavailable_tool::UnavailableToolHandler;
|
||||
pub(crate) use unavailable_tool::unavailable_tool_message;
|
||||
pub use unified_exec::ExecCommandHandler;
|
||||
pub use unified_exec::WriteStdinHandler;
|
||||
pub use view_image::ViewImageHandler;
|
||||
|
||||
@@ -2,8 +2,15 @@ use crate::function_tool::FunctionCallError;
|
||||
use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::flat_tool_name;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_tools::AdditionalProperties;
|
||||
use codex_tools::JsonSchema;
|
||||
use codex_tools::ResponsesApiTool;
|
||||
use codex_tools::ToolName;
|
||||
use codex_tools::ToolSpec;
|
||||
|
||||
pub struct UnavailableToolHandler {
|
||||
tool_name: ToolName,
|
||||
@@ -13,6 +20,26 @@ impl UnavailableToolHandler {
|
||||
pub fn new(tool_name: ToolName) -> Self {
|
||||
Self { tool_name }
|
||||
}
|
||||
|
||||
pub(crate) fn definition(tool_name: ToolName) -> RuntimeToolDefinition {
|
||||
let name = flat_tool_name(&tool_name).into_owned();
|
||||
let spec = ToolSpec::Function(ResponsesApiTool {
|
||||
name: name.clone(),
|
||||
description: unavailable_tool_message(
|
||||
&name,
|
||||
"Calling this placeholder returns an error explaining that the tool is unavailable.",
|
||||
),
|
||||
strict: false,
|
||||
parameters: JsonSchema::object(
|
||||
Default::default(),
|
||||
/*required*/ None,
|
||||
Some(AdditionalProperties::Boolean(false)),
|
||||
),
|
||||
output_schema: None,
|
||||
defer_loading: None,
|
||||
});
|
||||
runtime_tool_definition(Self::new(tool_name), spec)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn unavailable_tool_message(
|
||||
|
||||
@@ -5,7 +5,6 @@ use crate::tools::handlers::multi_agents_common::DEFAULT_WAIT_TIMEOUT_MS;
|
||||
use crate::tools::handlers::multi_agents_common::MAX_WAIT_TIMEOUT_MS;
|
||||
use crate::tools::handlers::multi_agents_common::MIN_WAIT_TIMEOUT_MS;
|
||||
use crate::tools::handlers::multi_agents_spec::WaitAgentTimeoutOptions;
|
||||
use crate::tools::registry::AnyToolHandler;
|
||||
use crate::tools::registry::ToolRegistryBuilder;
|
||||
use crate::tools::spec_plan::build_tool_registry_builder;
|
||||
use crate::tools::spec_plan_types::ToolNamespace;
|
||||
@@ -14,10 +13,7 @@ use codex_mcp::ToolInfo;
|
||||
use codex_protocol::dynamic_tools::DynamicToolSpec;
|
||||
use codex_tool_api::ToolDefinition;
|
||||
use codex_tool_api::ToolExecutor;
|
||||
use codex_tools::AdditionalProperties;
|
||||
use codex_tools::DiscoverableTool;
|
||||
use codex_tools::JsonSchema;
|
||||
use codex_tools::ResponsesApiTool;
|
||||
use codex_tools::ToolName;
|
||||
use codex_tools::ToolUserShellType;
|
||||
use codex_tools::ToolsConfig;
|
||||
@@ -68,7 +64,6 @@ pub(crate) fn build_specs_with_discoverable_tools(
|
||||
dynamic_tools: &[DynamicToolSpec],
|
||||
) -> ToolRegistryBuilder {
|
||||
use crate::tools::handlers::UnavailableToolHandler;
|
||||
use crate::tools::handlers::unavailable_tool_message;
|
||||
let mcp_tool_plan_inputs = mcp_tools.as_deref().map(map_mcp_tools_for_plan);
|
||||
let deferred_mcp_tool_sources = deferred_mcp_tools.as_deref();
|
||||
let default_agent_type_description =
|
||||
@@ -113,24 +108,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
|
||||
for unavailable_tool in unavailable_called_tools {
|
||||
let tool_name = flat_tool_name(&unavailable_tool).into_owned();
|
||||
if existing_spec_names.insert(tool_name.clone()) {
|
||||
let spec = codex_tools::ToolSpec::Function(ResponsesApiTool {
|
||||
name: tool_name.clone(),
|
||||
description: unavailable_tool_message(
|
||||
&tool_name,
|
||||
"Calling this placeholder returns an error explaining that the tool is unavailable.",
|
||||
),
|
||||
strict: false,
|
||||
parameters: JsonSchema::object(
|
||||
Default::default(),
|
||||
/*required*/ None,
|
||||
Some(AdditionalProperties::Boolean(false)),
|
||||
),
|
||||
output_schema: None,
|
||||
defer_loading: None,
|
||||
});
|
||||
let handler = Arc::new(UnavailableToolHandler::new(unavailable_tool.clone()))
|
||||
as Arc<dyn AnyToolHandler>;
|
||||
let definition = ToolDefinition::new(unavailable_tool, spec, handler);
|
||||
let definition = UnavailableToolHandler::definition(unavailable_tool);
|
||||
if builder.register_erased_handler(
|
||||
definition.tool_name().clone(),
|
||||
Arc::clone(definition.runtime()),
|
||||
|
||||
Reference in New Issue
Block a user