Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions codex-rs/code-mode/src/description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ use std::collections::BTreeMap;
use crate::PUBLIC_TOOL_NAME;

const MAX_JS_SAFE_INTEGER: u64 = (1_u64 << 53) - 1;
const CODE_MODE_ONLY_PREFACE: &str =
"Use `exec/wait` tool to run all other tools, do not attempt to use any other tools directly";
const DEFERRED_NESTED_TOOLS_GUIDANCE: &str = r#"Some nested MCP/app tools may be omitted from this description. They are still available on the global `tools` object and listed in `ALL_TOOLS`.
To find one, filter `ALL_TOOLS` by `name` and `description`; do not print the full `ALL_TOOLS` array. Print only a small set of relevant matches if you need to inspect them."#;
To find one, filter `ALL_TOOLS` by `name` and `description`."#;
const EXEC_DESCRIPTION_TEMPLATE: &str = r#"Run JavaScript code to orchestrate/compose tool calls
- Evaluates the provided JavaScript code in a fresh V8 isolate as an async module.
- All nested tools are available on the global `tools` object, for example `await tools.exec_command(...)`. Tool names are exposed as normalized JavaScript identifiers, for example `await tools.mcp__ologs__get_profile(...)`.
Expand Down Expand Up @@ -256,9 +254,6 @@ pub fn build_exec_tool_description(
deferred_tools_available: bool,
) -> String {
let mut sections = Vec::new();
if code_mode_only {
sections.push(CODE_MODE_ONLY_PREFACE.to_string());
}
sections.push(EXEC_DESCRIPTION_TEMPLATE.to_string());
if deferred_tools_available {
sections.push(DEFERRED_NESTED_TOOLS_GUIDANCE.to_string());
Expand Down Expand Up @@ -875,6 +870,7 @@ mod tests {
"### `foo`
bar"
));
assert!(!description.contains("do not attempt to use any other tools directly"));
}

#[test]
Expand Down Expand Up @@ -1097,5 +1093,6 @@ bar"

assert!(description.contains("Some nested MCP/app tools may be omitted"));
assert!(description.contains("filter `ALL_TOOLS` by `name` and `description`"));
assert!(!description.contains("do not print the full `ALL_TOOLS` array"));
}
}
5 changes: 2 additions & 3 deletions codex-rs/core/src/tools/spec_plan_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2265,9 +2265,8 @@ fn code_mode_only_exec_description_includes_full_nested_tool_details() {

assert!(!description.contains("Enabled nested tools:"));
assert!(!description.contains("Nested tool reference:"));
assert!(description.starts_with(
"Use `exec/wait` tool to run all other tools, do not attempt to use any other tools directly"
));
assert!(description.starts_with("Run JavaScript code to orchestrate/compose tool calls"));
assert!(!description.contains("do not attempt to use any other tools directly"));
assert!(description.contains("### `update_plan`"));
assert!(description.contains("### `view_image`"));
}
Expand Down
5 changes: 5 additions & 0 deletions codex-rs/core/src/tools/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,11 @@ async fn code_mode_only_can_expose_multi_agent_v2_as_normal_tools() {
};
assert!(!exec.description.contains("spawn_agent"));
assert!(!exec.description.contains("wait_agent"));
assert!(
!exec
.description
.contains("do not attempt to use any other tools directly")
);

let spawn_agent = find_tool(&model_visible_specs, "spawn_agent");
let ToolSpec::Function(spawn_agent) = spawn_agent else {
Expand Down
Loading