Skip to content

Commit 390b644

Browse files
authored
Update code mode exec() instructions (#16279)
1 parent 28a9807 commit 390b644

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

codex-rs/code-mode/src/description.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ use crate::PUBLIC_TOOL_NAME;
77
const MAX_JS_SAFE_INTEGER: u64 = (1_u64 << 53) - 1;
88
const CODE_MODE_ONLY_PREFACE: &str =
99
"Use `exec/wait` tool to run all other tools, do not attempt to use any other tools directly";
10-
const EXEC_DESCRIPTION_TEMPLATE: &str = r#"## exec
11-
- Runs raw JavaScript in an isolated context (no Node, no file system, or network access, no console).
12-
- Send raw JavaScript source text, not JSON, quoted strings, or markdown code fences.
10+
const EXEC_DESCRIPTION_TEMPLATE: &str = r#"Run JavaScript code to orchestrate/compose tool calls
11+
- Evaluates the provided JavaScript code in a fresh V8 isolate as an async module.
12+
- 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(...)`.
13+
- Nested tool methods take either a string or an object as their input argument.
14+
- Nested tools return either an object or a string, based on the description.
15+
- Runs raw JavaScript -- no Node, no file system, no network access, no console.
16+
- Accepts raw JavaScript source text, not JSON, quoted strings, or markdown code fences.
1317
- You may optionally start the tool input with a first-line pragma like `// @exec: {"yield_time_ms": 10000, "max_output_tokens": 1000}`.
1418
- `yield_time_ms` asks `exec` to yield early after that many milliseconds if the script is still running.
1519
- `max_output_tokens` sets the token budget for direct `exec` results. By default the result is truncated to 10000 tokens.
16-
- 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(...)`.
17-
- Tool methods take either string or object as parameter.
18-
- They return either a structured value or a string based on the description above.
20+
- When the JS code is fully evaluated, the isolate's lifetime ends and unawaited promises are silently discarded.
1921
2022
- Global helpers:
2123
- `exit()`: Immediately ends the current script successfully (like an early return from the top level).

0 commit comments

Comments
 (0)