fix(codex): track code-mode status lifecycle - #161
Conversation
graykode
left a comment
There was a problem hiding this comment.
Thanks for the comprehensive lifecycle work. The status ordering and custom tool-call tracking are generally well structured, and the full test suite, clippy, and release build pass locally. However, I found two blocking issues in the current Code Mode path.
-
The user-input wait detection does not match the event shape emitted by Code Mode. tool_waits_for_user checks the recorded tool name for request_user_input or AskUserQuestion, but current Code Mode records this as a custom_tool_call whose name is exec and whose input contains tools.request_user_input(...). call_names therefore stores exec, waiting_for_user remains false, and the open custom call is reported as Executing instead of Waiting. In sampled current rollouts, the user-input requests were custom-wrapped and there were no standalone function_call events for request_user_input. The new regression test uses the standalone function_call shape, so it does not reproduce the actual failure. Please add a fixture using custom_tool_call name exec with tools.request_user_input in input and make that path resolve to Waiting.
-
The new custom-tool branch copies the entire raw JavaScript input into ToolCall.arg after only secret-prefix redaction and a 120-character truncation. sanitize_tool_arg does not call sanitize_terminal_text and does not extract a bounded safe argument. This value reaches current_task, the TUI timeline, and JSON snapshots. Ordinary Code Mode inputs are multiline, and attacker-controlled ANSI/control or bidi characters can pass through as well; the raw source can also contain request bodies or other content that should not be treated as a short argument preview. Please sanitize terminal controls and bidi marks, and preferably extract only an allowlisted path or command preview. If a safe preview cannot be derived, display the tool name without the raw input. Add regression coverage for multiline input, terminal control characters, bidi marks, and sensitive inline content.
The lifecycle changes outside these two paths look sound. My requested changes are limited to matching the real custom-wrapped user-input event and keeping raw Code Mode source out of display and snapshot fields.
Summary
custom_tool_callandcustom_tool_call_outputevents emitted by current Codex Code Modetask_started/user_messagethroughtask_complete, including automatic turns with no user messageexec_command/write_stdintrackingRoot cause
The collector treated every
agent_messageas the end of a turn and only parsed the olderfunction_callevent shape. Codex CLI 0.144.6 emits intermediate progress messages and routes Code Mode tools through custom tool-call events, so the parsed state frequently disagreed with the live turn.Testing
cargo clippy --all-targets -- -D warningscargo test(207 unit tests and 1 doc test)abtop --jsonvalidation against active Codex CLI 0.144.6 sessions covering active tools, post-tool reasoning, completed turns, andrequest_user_inputCloses #160