Commit Graph
564 Commits
Author SHA1 Message Date
Ahmed Ibrahim ddaa072f87 revert some edits because they got too old 2025-07-24 11:56:28 -07:00
Ahmed Ibrahim 032743575d review 2025-07-24 11:43:17 -07:00
aibrahim-oai 6ddbe7ec2b Merge branch 'main' into chores-rollout 2025-07-23 15:04:43 -07:00
aibrahim-oai b4ab7c1b73 Flaky CI fix (#1647)
Flushing before sending `TaskCompleteEvent` and ending the submission
loop to avoid race conditions.
2025-07-23 15:03:26 -07:00
Ahmed Ibrahim dbc7bc9f3a rebase 2025-07-23 14:54:49 -07:00
aibrahim-oai 3b130f3b39 Merge branch 'main' into chores-rollout 2025-07-23 14:21:31 -07:00
Ahmed Ibrahim c29b0a09a4 Merge branch 'chores-rollout' of github.com:openai/codex into chores-rollout 2025-07-23 14:05:19 -07:00
Ahmed Ibrahim b52156eb82 rollout 2025-07-23 14:04:57 -07:00
Gabriel Peal 084236f717 Add call_id to patch approvals and elicitations (#1660)
Builds on https://github.com/openai/codex/pull/1659 and adds call_id to
a few more places for the same reason.
2025-07-23 15:55:35 -04:00
Gabriel Peal bc944e77f5 Improve messages emitted for exec failures (#1659)
1. Emit call_id to exec approval elicitations for mcp client convenience
2. Remove the `-retry` from the call id for the same reason as above but
upstream the reset behavior to the mcp client
2025-07-23 14:43:53 -04:00
pakrym-oai 591cb6149a Always send entire request context (#1641)
Always store the entire conversation history.
Request encrypted COT when not storing Responses.
Send entire input context instead of sending previous_response_id
2025-07-23 10:37:45 -07:00
Michael Bolin d6c4083f98 feat: support dotenv (including ~/.codex/.env) (#1653)
This PR adds a `load_dotenv()` helper function to the `codex-common`
crate that is available when the `cli` feature is enabled. The function
uses [`dotenvy`](https://crates.io/crates/dotenvy) to update the
environment from:

- `$CODEX_HOME/.env`
- `$(pwd)/.env`

To test:

- ran `printenv OPENAI_API_KEY` to verify the env var exists in my
environment
- ran `just codex exec hello` to verify the CLI uses my `OPENAI_API_KEY`
- ran `unset OPENAI_API_KEY`
- ran `just codex exec hello` again and got **ERROR: Missing environment
variable: `OPENAI_API_KEY`**, as expected
- created `~/.codex/.env` and added `OPENAI_API_KEY=sk-proj-...` (also
ran `chmod 400 ~/.codex/.env` for good measure)
- ran `just codex exec hello` again and it worked, verifying it picked
up `OPENAI_API_KEY` from `~/.codex/.env`

Note this functionality was available in the TypeScript CLI:
https://github.com/openai/codex/pull/122 and was recently requested over
on https://github.com/openai/codex/issues/1262#issuecomment-3093203551.
2025-07-22 15:54:33 -07:00
Michael Bolin 3ef544fb95 chore: for release build, build specific targets instead of --all-targets (#1656)
I noticed that releases have taken longer and longer to build.
Originally, I think I did `--all-targets` to be confident that
everything builds cleanly, but that's really the job of CI that runs on
`main`, so we're spending a lot of time in `rust-release.yml` for not
that much additional signal.
2025-07-22 14:35:50 -07:00
aibrahim-oai 01c0896f0f Adding interrupt Support to MCP (#1646) 2025-07-22 20:33:49 +00:00
aibrahim-oai ede52e89f3 Merge branch 'main' into chores-rollout 2025-07-22 11:59:03 -07:00
Michael Bolin 4082246f6a chore: install an extension for TOML syntax highlighting in the devcontainer (#1650)
Small quality-of-life improvement when doing devcontainer development.
2025-07-22 10:58:09 -07:00
pakrym-oai 6d82907082 Add support for custom base instructions (#1645)
Allows providing custom instructions file as a config parameter and
custom instruction text via MCP tool call.
2025-07-22 09:42:22 -07:00
pakrym-oai ed206d5687 Log response.failed error message and request-id (#1649)
To help with diagnosing failures.
2025-07-22 09:28:00 -07:00
Michael Bolin d51654822f fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner (#1626)
Some users have reported issues where child processes are not cleaned up
after Codex exits (e.g., https://github.com/openai/codex/issues/1570).

This is generally a tricky issue on operating systems: if a parent
process receives `SIGKILL`, then it terminates immediately and cannot
communicate with the child.

**It only helps on Linux**, but this PR introduces the use of `prctl(2)`
so that if the parent process dies, `SIGTERM` will be delivered to the
child process. Whereas previously, I believe that if Codex spawned a
long-running process (like `tsc --watch`) and the Codex process received
`SIGKILL`, the `tsc --watch` process would be reparented to the init
process and would never be killed. Now with the use of `prctl(2)`, the
`tsc --watch` process should receive `SIGTERM` in that scenario.

We still need to come up with a solution for macOS. I've started to look
at `launchd`, but I'm researching a number of options.
2025-07-22 00:41:27 -07:00
Gabriel Peal 710f728124 Add an elicitation for approve patch and refactor tool calls (#1642)
1. Added an elicitation for `approve-patch` which is very similar to
`approve-exec`.
2. Extracted both elicitations to their own files to prevent
`codex_tool_runner` from blowing up in size.
2025-07-22 02:58:41 -04:00
Michael Bolin 6cf4b96f9d fix: check flags to ripgrep when deciding whether the invocation is "trusted" (#1644)
With this change, if any of `--pre`, `--hostname-bin`, `--search-zip`, or `-z` are used with a proposed invocation of `rg`, do not auto-approve.
2025-07-21 22:38:50 -07:00
Dylan 18b2b30841 [mcp-server] Add reply tool call (#1643)
## Summary
Adds a new mcp tool call, `codex-reply`, so we can continue existing
sessions. This is a first draft and does not yet support sessions from
previous processes.

## Testing
- [x] tested with mcp client
2025-07-21 21:01:56 -07:00
Ahmed Ibrahim 2c13f1e86d Merge branch 'chores-rollout' of github.com:openai/codex into chores-rollout 2025-07-21 20:10:13 -07:00
Ahmed Ibrahim b5a12a3fd5 remove flakyness to another PR 2025-07-21 20:09:49 -07:00
aibrahim-oai efd4edc0b6 Merge branch 'main' into chores-rollout 2025-07-21 13:58:35 -07:00
Michael Bolin d49d802b06 test: add integration test for MCP server (#1633)
This PR introduces a single integration test for `cargo mcp`, though it
also introduces a number of reusable components so that it should be
easier to introduce more integration tests going forward.

The new test is introduced in `codex-rs/mcp-server/tests/elicitation.rs`
and the reusable pieces are in `codex-rs/mcp-server/tests/common`.

The test itself verifies new functionality around elicitations
introduced in https://github.com/openai/codex/pull/1623 (and the fix
introduced in https://github.com/openai/codex/pull/1629) by doing the
following:

- starts a mock model provider with canned responses for
`/v1/chat/completions`
- starts the MCP server with a `config.toml` to use that model provider
(and `approval_policy = "untrusted"`)
- sends the `codex` tool call which causes the mock model provider to
request a shell call for `git init`
- the MCP server sends an elicitation to the client to approve the
request
- the client replies to the elicitation with `"approved"`
- the MCP server runs the command and re-samples the model, getting a
`"finish_reason": "stop"`
- in turn, the MCP server sends the final response to the original
`codex` tool call
- verifies that `git init` ran as expected

To test:

```
cargo test shell_command_approval_triggers_elicitation
```

In writing this test, I discovered that `ExecApprovalResponse` does not
conform to `ElicitResult`, so I added a TODO to fix that, since I think
that should be updated in a separate PR. As it stands, this PR does not
update any business logic, though it does make a number of members of
the `mcp-server` crate `pub` so they can be used in the test.

One additional learning from this PR is that
`std::process::Command::cargo_bin()` from the `assert_cmd` trait is only
available for `std::process::Command`, but we really want to use
`tokio::process::Command` so that everything is async and we can
leverage utilities like `tokio::time::timeout()`. The trick I came up
with was to use `cargo_bin()` to locate the program, and then to use
`std::process::Command::get_program()` when constructing the
`tokio::process::Command`.
2025-07-21 10:27:07 -07:00
Ahmed Ibrahim 79dce68a0b adding todo 2025-07-20 18:15:13 -07:00
Ahmed Ibrahim 24e05336f4 wait for flush after task complete 2025-07-20 18:09:22 -07:00
Ahmed Ibrahim 90f9c6ee9b adding exit signal 2025-07-20 17:41:17 -07:00
Ahmed Ibrahim 7119f241d1 Merge branch 'chores-rollout' of github.com:openai/codex into chores-rollout 2025-07-20 17:33:27 -07:00
Ahmed Ibrahim 4262b77cfa adding exit signal 2025-07-20 17:32:54 -07:00
aibrahim-oai 7eccca035f Merge branch 'main' into chores-rollout 2025-07-20 17:24:50 -07:00
Michael Bolin 8a6c6cee88 fix: address review feedback on #1621 and #1623 (#1631)
- formalizes `ExecApprovalElicitRequestParams`
- adds some defensive logic when messages fail to parse
- fixes a typo in a comment
2025-07-20 14:42:11 -07:00
Ahmed Ibrahim e382e19c65 eprintln 2025-07-20 13:53:09 -07:00
Ahmed Ibrahim 119e216c14 eprintln 2025-07-20 13:48:08 -07:00
Ahmed Ibrahim 0fe8a4b9c8 use utc instead 2025-07-20 11:34:42 -07:00
Ahmed Ibrahim 78c7b0f4df move live_cli 2025-07-20 11:19:25 -07:00
Ahmed Ibrahim 1d3b2e76dd move live_cli 2025-07-20 11:07:55 -07:00
Ahmed Ibrahim 9c1a046de1 move live_cli 2025-07-20 10:52:50 -07:00
Ahmed Ibrahim 567653a3b1 Merge branch 'chores-rollout' of github.com:openai/codex into chores-rollout 2025-07-20 10:45:37 -07:00
Ahmed Ibrahim 3616f16b8f moving to cli 2025-07-20 10:45:10 -07:00
aibrahim-oai 41c3747e45 Merge branch 'main' into chores-rollout 2025-07-20 10:39:57 -07:00
Ahmed Ibrahim 2dbe76d4a2 moving to cli 2025-07-20 10:39:03 -07:00
Gabriel Peal 8b590105de Don't drop sessions on elicitation responses (#1629) 2025-07-20 13:31:19 -04:00
Ahmed Ibrahim 36a7427983 logging 2025-07-19 23:35:14 -07:00
Ahmed Ibrahim c8c269e52c adding logging 2025-07-19 23:29:48 -07:00
Ahmed Ibrahim 60d5a80d51 use bin cargo-cli 2025-07-19 23:10:29 -07:00
Ahmed Ibrahim b7360b3dda use bin cargo-cli 2025-07-19 23:10:24 -07:00
Ahmed Ibrahim b376c55912 recognizing codex-rs 2025-07-19 23:02:42 -07:00
Ahmed Ibrahim 3e908f5a17 recognizing codex-rs 2025-07-19 23:00:42 -07:00