Skip to content

Name a Codex script by the tools it calls, not by those its strings name - #82

Merged
joeychilson merged 2 commits into
mainfrom
codex-script-real-calls
Oct 19, 2026
Merged

joeychilson merged 2 commits into
mainfrom
codex-script-real-calls

Conversation

@joeychilson

Copy link
Copy Markdown
Owner

Codex's reader names an exec script by the tools it calls, as exec: apply_patch, exec_command. It found them by every tools. in the script's text, strings included. So a script that only searches, await tools.exec_command({cmd: "rg -n tools.apply_patch src"}), was named exec: exec_command, apply_patch, as if it also patched files. sessions read, read_session and the handoff show that name, and #77 makes the handoff's reads_only decide by it, so with #77 such a script would still count as work.

The name now takes only calls: each tools.<name>( outside the script's strings. A string is one in " or `, to its closing quote, past \-escaped ones. That covers the shapes in the tests and the fixture (commands and patches in " strings) and patches in template literals, which agents::patched already expects. Not ': outside a string, a ' may be an apostrophe in a comment, and taking it for a string would hide every call after it. So a tool's call written inside a ' string, as 'tools.apply_patch(', is still named, as before. The decision is written beside the code.

The test agents::codex::tests::a_script_is_named_by_the_tools_it_calls_not_those_its_strings_name names three scripts: the one above, a patch in a template literal that adds a line calling tools.view_image(, and a command whose string holds an escaped \"tools.view_image(\" followed by a real tools.apply_patch( call. On origin/main it fails:

thread 'agents::codex::tests::a_script_is_named_by_the_tools_it_calls_not_those_its_strings_name' panicked at src/agents/codex.rs:1498:9:
assertion `left == right` failed
  left: ["exec: exec_command, apply_patch", "exec: apply_patch, view_image", "exec: exec_command, view_image, apply_patch"]
 right: ["exec: exec_command", "exec: apply_patch", "exec: exec_command, apply_patch"]

It passes with the fix. The existing test a_conversation_keeps_the_persons_words_and_names_what_a_script_did and the Codex snapshots (sessions-read-codex, sessions-read-failed) pass unchanged: no snapshot changed.

ingest::READERS stays as it is: the name is built only when a transcript is read, on demand, and transcripts aren't stored. CHANGELOG.md gets an entry under 0.1.5.

Checked: cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings, cargo test --locked, TZ=America/Chicago cargo test --locked and RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --locked all pass. Not run: the Swift tests, shellcheck, actionlint and cargo deny, since nothing they cover changed; the handoff cases, since the handoff's code didn't change. Not checked: how often real Codex scripts use ' strings or comments; I didn't look at real sessions.

@joeychilson
joeychilson merged commit c52c1f5 into main Oct 19, 2026
3 checks passed
@joeychilson
joeychilson deleted the codex-script-real-calls branch October 19, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant