Add support for incremental code mode tool definitions (#60157)

## What changed

Render stable entries for nested tool definitions and namespace instructions alongside the full `functions.exec` description. Add optional catalog tracking that emits complete replacements for added or changed entries and explicit notices for removed entries, while keeping the existing exec declaration unchanged.

Preserve entry hashes while exec is unavailable, then restore the full catalog and withdraw removed entries when it returns. Keep the existing snapshot format for ordinary tool catalogs.

This change provides the rendering and state support; runtime activation remains disabled.

## Testing

Add tests for definition rendering and namespace identity, batched additions and changes, removal notices, unchanged catalogs, and full catalog restoration after exec is hidden.

GitOrigin-RevId: f472bd3e8e770a8cad9663c72e290abe7d0473be
This commit is contained in:
Alex Kira
2026-11-07 18:24:25 +00:00
committed by copyberry
parent 57e64682f8
commit 2bc8e7f545
10 changed files with 604 additions and 107 deletions
@@ -31,7 +31,7 @@ fn plain_tools_join_an_existing_functions_group_only_with_a_prefix() {
)]);
let render = |tools: &[ToolDefinition],
namespaces: &BTreeMap<String, ToolNamespaceDescription>| {
codex_code_mode::build_exec_tool_description(
codex_code_mode::build_exec_tool_description_and_definitions(
tools,
&[],
namespaces,
@@ -39,8 +39,10 @@ fn plain_tools_join_an_existing_functions_group_only_with_a_prefix() {
/*code_mode_only*/ true,
codex_code_mode::ImageDetailVisibility::Visible,
codex_code_mode::DeferredToolDiscovery::Catalog,
/*incremental_exec_enabled*/ false,
/*messages*/ None,
)
.0
};
let original = render(&original_tools, &original_namespaces);
for messages in [