Skip to content

feat: add LastMessage to read --output-last-message back - #168

Merged
joshrotenberg merged 2 commits into
mainfrom
feat/last-message-153
Nov 1, 2026
Merged

joshrotenberg merged 2 commits into
mainfrom
feat/last-message-153

Conversation

@joshrotenberg

@joshrotenberg joshrotenberg commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #153.

Changes

  • CodexWrapper.LastMessage.run/3 (command, config, opts) for Exec, ExecResume, ExecFork and Review. With no explicit path it creates a temp file with mode 0600 in System.tmp_dir!/0, sets --output-last-message, runs the command through its execute/3 (so observation options pass through), reads the file and removes it in an after block. This follows CodexWrapper.Structured.
  • An explicit output_last_message/2 path is used as given; the wrapper reads it but does not create or remove it.
  • Outcomes:
    • {:ok, text, result}: exit 0, non-empty file
    • {:error, {:no_last_message, result}}: exit 0, missing or empty file
    • {:error, {:process_failed, text, result}}: non-zero exit, with "" when nothing was written
    • {:error, {:last_message_read, reason, result}}: other read failures
    • {:error, {:last_message_file, reason}}: temp file creation failed
    • runner errors unchanged
  • 7 tests with a fake executable (test/fixtures/fake_codex_last_message) that writes the -o path: all four commands, explicit path, missing and empty output, non-zero exit, file mode, cleanup after error and raise, option forwarding, read errors.
  • README section and docs grouping entry.
  • docs/last-message-native-0.165.0.md records the native failed-turn run: codex-cli 0.165.0 with an unsupported model exits 1 and does not create the -o file, so an owned file stays empty and the text is "".

Checks

On the host: mix deps.unlock --check-unused, mix hex.audit, mix compile --warnings-as-errors, mix format --check-formatted, mix credo --strict, mix dialyzer, mix test (616 passed, 4 excluded), mix docs --warnings-as-errors.

The change was made by a Codex agent (codex-cli 0.165.0, workspace_write) in a gen_agent_server instance, in two turns: the implementation, then a revision that replaced a network-blocked probe record with the host's native run. The procedure and run record are in genagent/gen_agent_server#134.

CodexWrapper.LastMessage.run/3 runs Exec, ExecResume, ExecFork or Review
with an owned 0600 temp file for --output-last-message, reads it after the
process exits, and removes it on success, failure or raise. An explicit
output_last_message/2 path is used as given and left to the caller.

Exit 0 with a missing or empty file returns {:no_last_message, result};
a non-zero exit returns {:process_failed, text, result}. A native run with
codex-cli 0.165.0 shows a failed turn exits 1 without writing the file.
Closes #153.
@joshrotenberg
joshrotenberg marked this pull request as ready for review November 1, 2026 03:47
@joshrotenberg
joshrotenberg merged commit dd5bf0d into main Nov 1, 2026
5 checks passed
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.

feat: read the --output-last-message file back for the caller

1 participant