Commit Graph

2128 Commits

Author SHA1 Message Date
Michael Bolin
a87e648071 Merge 1ccd7af0b3 into sapling-pr-archive-bolinfest 2025-07-22 10:45:11 -07:00
Michael Bolin
1ccd7af0b3 feat: support dotenv (including ~/.codex/.env) 2025-07-22 10:45:00 -07:00
Michael Bolin
dfa9a44202 feat: support dotenv 2025-07-22 10:19:42 -07:00
Michael Bolin
41f993a93f Merge d5809ef6ef into sapling-pr-archive-bolinfest 2025-07-22 10:11:13 -07:00
Michael Bolin
d5809ef6ef chore: install an extension for TOML syntax highlighting in the devcontainer 2025-07-22 10:11:07 -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
Michael Bolin
79c7804f1b Merge 50755c65b7 into sapling-pr-archive-bolinfest 2025-07-22 00:29:59 -07:00
Michael Bolin
50755c65b7 fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner 2025-07-22 00:29:45 -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
Michael Bolin
23cc9d726b merge commit for archive created by Sapling 2025-07-21 22:03:20 -07:00
Michael Bolin
2511223680 fix 2025-07-21 22:03:13 -07:00
Michael Bolin
a7263bbf97 Merge 022c5dc997 into sapling-pr-archive-bolinfest 2025-07-21 21:55:36 -07:00
Michael Bolin
022c5dc997 fix 2025-07-21 21:55:30 -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
Michael Bolin
6567a14a3d merge commit for archive created by Sapling 2025-07-21 17:13:33 -07:00
Michael Bolin
50f38401d4 fix 2025-07-21 17:13:23 -07:00
Michael Bolin
3d8537b850 Merge 94f1a946ae into sapling-pr-archive-bolinfest 2025-07-21 17:09:11 -07:00
Michael Bolin
94f1a946ae fix 2025-07-21 17:08:58 -07:00
Michael Bolin
4ea6d54de9 Merge ac85a01ea7 into sapling-pr-archive-bolinfest 2025-07-21 10:27:44 -07:00
Michael Bolin
ac85a01ea7 fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner 2025-07-21 10:27:34 -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
Michael Bolin
f5d3cb0dd6 merge commit for archive created by Sapling 2025-07-20 20:09:58 -07:00
Michael Bolin
24a80cf9d7 fix: integration test for MCP server 2025-07-20 20:09:52 -07:00
Michael Bolin
12c516f7ba merge commit for archive created by Sapling 2025-07-20 19:56:42 -07:00
Michael Bolin
111bab0a61 fix: integration test for MCP server 2025-07-20 19:56:19 -07:00
Michael Bolin
d7e6ba42d8 merge commit for archive created by Sapling 2025-07-20 19:44:22 -07:00
Michael Bolin
4640946c05 fix: integration test for MCP server 2025-07-20 19:44:17 -07:00
Michael Bolin
547342b2e1 merge commit for archive created by Sapling 2025-07-20 19:41:26 -07:00
Michael Bolin
69bdec9824 fix: integration test for MCP server 2025-07-20 19:41:20 -07:00
Michael Bolin
0022eeeee5 merge commit for archive created by Sapling 2025-07-20 19:23:30 -07:00
Michael Bolin
78ad35a6a9 fix: integration test for MCP server 2025-07-20 19:23:05 -07:00
Michael Bolin
20d74a9562 merge commit for archive created by Sapling 2025-07-20 19:16:20 -07:00
Michael Bolin
cfd24302bb fix: integration test for MCP server 2025-07-20 19:16:15 -07:00
Michael Bolin
6c9a411cc8 merge commit for archive created by Sapling 2025-07-20 19:15:47 -07:00
Michael Bolin
58bcc91c7f fix: integration test for MCP server 2025-07-20 19:13:33 -07:00
Michael Bolin
62fe3fc4db Merge 96092108b1 into sapling-pr-archive-bolinfest 2025-07-20 17:42:23 -04:00
Michael Bolin
96092108b1 fix: integration test for MCP server 2025-07-20 14:42:17 -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
Michael Bolin
9bce460754 merge commit for archive created by Sapling 2025-07-20 14:37:13 -07:00
Michael Bolin
1a608d680b fix: integration test for MCP server 2025-07-20 14:36:51 -07:00
Michael Bolin
96343988f2 fix: address review feedback on #1621 and #1623 2025-07-20 14:36:51 -07:00
Gabriel Peal
8b590105de Don't drop sessions on elicitation responses (#1629) 2025-07-20 13:31:19 -04:00
Michael Bolin
e3827fcb43 Merge 900509d12c into sapling-pr-archive-bolinfest 2025-07-20 11:15:06 -04:00
Michael Bolin
900509d12c fix: address review feedback on #1621 and #1623 2025-07-20 11:14:52 -04:00
Michael Bolin
4c6c7addda merge commit for archive created by Sapling 2025-07-19 12:31:30 -04:00
Michael Bolin
45b0b67c10 fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner 2025-07-19 12:31:21 -04:00
Michael Bolin
adcad5b1de merge commit for archive created by Sapling 2025-07-19 12:01:21 -04:00
Michael Bolin
b9a18b9a24 fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner 2025-07-19 12:01:16 -04:00