mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
1.4 KiB
1.4 KiB
Code Mode (code_mode)
code_mode runs JavaScript in a Node-backed node:vm context.
Feature gate
code_mode is disabled by default and only appears when:
[features]
code_mode = true
Unlike js_repl, enabling code_mode does not disable direct model tool calls.
Node runtime
code_mode uses the same Node runtime resolution as js_repl:
CODEX_JS_REPL_NODE_PATHenvironment variablejs_repl_node_pathin config/profilenodediscovered onPATH
Usage
code_modeis a freeform tool: send raw JavaScript source text.- It exposes async wrappers for other tools through
await tools[name](args)and identifier globals for valid tool names. Nested tool calls resolve to arrays of content items. - Function tools require JSON object arguments. Freeform tools require raw strings.
add_content(value)is synchronous. It accepts a content item or an array of content items, soadd_content(await exec_command(...))returns the same content items a direct tool call would expose.- Only content passed to
add_content(value)is surfaced back to the model. - The tool description lists which nested tools are available in the current session.
code_modecannot invoke itself recursively.
Notes
- Because
code_modeusesnode:vm, it is lighter than the persistentjs_replkernel but does not keep top-level bindings between calls.