Extract built-in tool spec constructors into codex-tools (#16493)

## Why

`core/src/tools/spec.rs` still had a few built-in tool specs assembled
inline even though those definitions are pure metadata and already live
conceptually in `codex-tools`. Keeping that construction in `codex-core`
makes `spec.rs` do more than registry orchestration and slows the
migration toward a right-sized `codex-tools` crate.

This continues the extraction stack from #16379, #16471, #16477, #16481,
and #16482.

## What Changed

- added `create_local_shell_tool()`, `create_web_search_tool(...)`, and
`create_image_generation_tool(...)` to `codex-rs/tools/src/tool_spec.rs`
- exported those helpers from `codex-rs/tools/src/lib.rs`
- switched `codex-rs/core/src/tools/spec.rs` to call those helpers
instead of constructing `ToolSpec::LocalShell`, `ToolSpec::WebSearch`,
and `ToolSpec::ImageGeneration` inline
- removed the remaining core-local web-search content-type constant and
made the affected spec test assert the literal expected values directly

This is intended to be a straight refactor: tool behavior and wire shape
should not change.

## Testing

- `cargo test -p codex-tools`
- `cargo test -p codex-core tools::spec::tests`
This commit is contained in:
Michael Bolin
2026-04-01 19:31:24 -07:00
committed by GitHub
parent d7e5bc6a3a
commit 5a2f3a8102
4 changed files with 71 additions and 47 deletions

View File

@@ -102,7 +102,11 @@ pub use tool_spec::ConfiguredToolSpec;
pub use tool_spec::ResponsesApiWebSearchFilters;
pub use tool_spec::ResponsesApiWebSearchUserLocation;
pub use tool_spec::ToolSpec;
pub use tool_spec::WebSearchToolOptions;
pub use tool_spec::create_image_generation_tool;
pub use tool_spec::create_local_shell_tool;
pub use tool_spec::create_tools_json_for_responses_api;
pub use tool_spec::create_web_search_tool;
pub use utility_tool::create_list_dir_tool;
pub use utility_tool::create_test_sync_tool;
pub use view_image::ViewImageToolOptions;