mirror of
https://github.com/openai/codex.git
synced 2026-11-17 14:58:36 +00:00
Simplify tool executor and registry plumbing (#22636)
## Why The tool runtime path still had a typed output associated type on `ToolExecutor`, plus a core-only `RegisteredTool` adapter and extension-only executor aliases. That made every new shared tool runtime carry extra adapter plumbing before it could participate in core dispatch, extension tools, hook payloads, telemetry, and model-visible spec generation. This PR moves output erasure to the shared executor boundary so core and extension tools can use the same execution contract directly. ## What Changed - Changed `codex_tools::ToolExecutor` to return `Box<dyn ToolOutput>` instead of an associated `Output` type. - Removed the extension-specific `ExtensionToolExecutor` / `ExtensionToolOutput` aliases and exposed `ToolExecutor<ToolCall>` plus `ToolOutput` through `codex-extension-api`. - Reworked core tool registration around `CoreToolRuntime` and `ToolRegistry::from_tools`, removing the extra `RegisteredTool` / `ToolRegistryBuilder` layer. - Consolidated model-visible spec planning and registry construction in `core/src/tools/spec_plan.rs`, including deferred tool search and code-mode-only filtering. - Added `ToolOutput` helpers for post-tool-use hook ids and inputs so MCP, unified exec, extension, and other boxed outputs preserve the same hook payload behavior. - Updated core handlers, memories tools, and the related registry/spec/router tests to use the simplified contract. ## Test Coverage - Updated coverage for tool spec planning, registry lookup, deferred tool search registration, extension tool routing, post-tool-use hook payloads, dispatch tracing, guardian output extraction, and memories extension tool execution.
This commit is contained in:
1 parent
0322ac3df8
commit
6f1a01fbdd
65 files changed
+830
-1008
No files matched your search
@@ -20,6 +20,16 @@ pub trait ToolOutput: Send {
|
||||
|
||||
fn to_response_item(&self, call_id: &str, payload: &ToolPayload) -> ResponseInputItem;
|
||||
|
||||
/// Returns the tool call id exposed to `PostToolUse` hooks for this output.
|
||||
fn post_tool_use_id(&self, call_id: &str) -> String {
|
||||
call_id.to_string()
|
||||
}
|
||||
|
||||
/// Returns the tool input exposed to `PostToolUse` hooks for this output.
|
||||
fn post_tool_use_input(&self, _payload: &ToolPayload) -> Option<JsonValue> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns the stable value exposed to `PostToolUse` hooks for this tool output.
|
||||
///
|
||||
/// Tool handlers decide whether a tool participates in `PostToolUse`, but
|
||||
@@ -52,6 +62,14 @@ where
|
||||
(**self).to_response_item(call_id, payload)
|
||||
}
|
||||
|
||||
fn post_tool_use_id(&self, call_id: &str) -> String {
|
||||
(**self).post_tool_use_id(call_id)
|
||||
}
|
||||
|
||||
fn post_tool_use_input(&self, payload: &ToolPayload) -> Option<JsonValue> {
|
||||
(**self).post_tool_use_input(payload)
|
||||
}
|
||||
|
||||
fn post_tool_use_response(&self, call_id: &str, payload: &ToolPayload) -> Option<JsonValue> {
|
||||
(**self).post_tool_use_response(call_id, payload)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user