Track deferred tool namespaces in world state (#35063)

## What changed

- Add the disabled-by-default `deferred_tool_world_state` feature, which exposes deferred tool namespaces and their descriptions to the model in a `<tools>` world-state section.
- Emit added and removed namespace updates as tool availability changes, bound the rendered context size, and persist nonempty state across thread resumes.
- Omit empty tool state while retaining deferred tool discovery through `tool_search`.

## Testing

- Cover initial, unchanged, removed, recovered, empty, and resumed namespace state, along with description truncation and rendered-size limits.

GitOrigin-RevId: 867e599666dc3569eb0789ba78aaa40254253a6f
This commit is contained in:
Ahmed Ibrahim authored and copyberry committed 2026-07-24 01:20:04 +00:00
1 parent 09241ae4db
commit 1d4b58f32d
16 files changed
+785 -5

No files matched your search

+6
View File
@@ -1,3 +1,4 @@
use std::collections::BTreeMap;
use std::sync::Arc;
use crate::config::Config;
@@ -338,6 +339,11 @@ async fn specs_filter_deferred_dynamic_tools() -> anyhow::Result<()> {
namespace_function_names(&router.model_visible_specs(), "codex_app"),
vec![visible_tool.to_string()]
);
assert_eq!(
router.deferred_tool_namespaces(),
BTreeMap::from([("codex_app".to_string(), "Codex app tools.".to_string())])
);
Ok(())
}