Files
codex/codex-rs/code-mode/src/tool_catalog_tests.rs
T
Alex Daley a54018ff36 Expose TypeScript signatures in Code Mode's ALL_TOOLS (#64939)
## Why

Code Mode embeds TypeScript declarations in tool descriptions, so scripts
that want to inspect a tool's argument and return types have to extract
the declaration from the description.

## What changed

Enable `features.code_mode_all_tools_schema` to expose callable names,
descriptions, and TypeScript signatures as separate fields in `ALL_TOOLS`.
Update the `exec` guidance to match the selected format, including when
resuming a session. The flag is off by default.

Carry signatures over gRPC and stdio. Reject execution requests with
signatures when the host does not advertise support for them.

## Testing

Add coverage for both catalog formats, `exec` guidance on resume, and
signature preservation over gRPC and stdio.

GitOrigin-RevId: dedaeec4a2563c23d432c324187ef20f6a0e5ea3
2026-12-01 06:54:13 +00:00

54 lines
1.8 KiB
Rust

#![cfg(test)]
use super::*;
use codex_code_mode_protocol::CodeModeToolKind;
use codex_protocol::ToolName;
use pretty_assertions::assert_eq;
#[test]
fn references_require_an_acknowledged_matching_admission() {
let cache = Arc::new(Mutex::new(Catalog::default()));
let mut tools = [ToolDefinition {
name: "echo".to_string(),
tool_name: ToolName::plain("echo"),
description: String::new(),
kind: CodeModeToolKind::Function,
signature: None,
input_schema: None,
input_schema_max_bytes: None,
output_schema: None,
}];
let cancelled = CatalogAdmission::prepare(&cache, &tools).unwrap();
assert!(!cancelled.reuses_catalog());
assert!(CatalogAdmission::prepare(&cache, &tools).is_none());
let abandoned_revision = cancelled.revision();
drop(cancelled);
let registration = CatalogAdmission::prepare(&cache, &tools).unwrap();
assert!(!registration.reuses_catalog());
assert!(registration.revision() > abandoned_revision);
let revision = registration.revision();
registration.accepted();
let hit = CatalogAdmission::prepare(&cache, &tools).unwrap();
assert!(hit.reuses_catalog());
assert_eq!(hit.revision(), revision);
hit.accepted();
let other = Arc::new(Mutex::new(Catalog::default()));
let registration = CatalogAdmission::prepare(&other, &tools).unwrap();
assert!(!registration.reuses_catalog());
registration.accepted();
{
let first = cache.try_lock().unwrap();
let second = other.try_lock().unwrap();
assert!(Arc::ptr_eq(
&first.tools.as_ref().unwrap()[0],
&second.tools.as_ref().unwrap()[0],
));
}
tools[0].description = "changed".to_string();
assert!(
!CatalogAdmission::prepare(&cache, &tools)
.unwrap()
.reuses_catalog()
);
}