Commit Graph
8002 Commits
Author SHA1 Message Date
Michael Bolin 23a753bb86 Merge 591f0ee2a0 into sapling-pr-archive-bolinfest 2025-11-20 16:47:33 -08:00
Michael Bolin 591f0ee2a0 feat: codex-shell-tool-mcp 2025-11-20 16:45:46 -08:00
Michael Bolin 8e5f38c0f0 feat: waiting for an elicitation should not count against a shell tool timeout (#6973)
Previously, we were running into an issue where we would run the `shell`
tool call with a timeout of 10s, but it fired an elicitation asking for
user approval, the time the user took to respond to the elicitation was
counted agains the 10s timeout, so the `shell` tool call would fail with
a timeout error unless the user is very fast!

This PR addresses this issue by introducing a "stopwatch" abstraction
that is used to manage the timeout. The idea is:

- `Stopwatch::new()` is called with the _real_ timeout of the `shell`
tool call.
- `process_exec_tool_call()` is called with the `Cancellation` variant
of `ExecExpiration` because it should not manage its own timeout in this
case
- the `Stopwatch` expiration is wired up to the `cancel_rx` passed to
`process_exec_tool_call()`
- when an elicitation for the `shell` tool call is received, the
`Stopwatch` pauses
- because it is possible for multiple elicitations to arrive
concurrently, it keeps track of the number of "active pauses" and does
not resume until that counter goes down to zero

I verified that I can test the MCP server using
`@modelcontextprotocol/inspector` and specify `git status` as the
`command` with a timeout of 500ms and that the elicitation pops up and I
have all the time in the world to respond whereas previous to this PR,
that would not have been possible.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/6973).
* #7005
* __->__ #6973
* #6972
2025-11-20 16:45:38 -08:00
Ahmed Ibrahim 1388e99674 fix flaky tool_call_output_exceeds_limit_truncated_chars_limit (#7043)
I am suspecting this is flaky because of the wall time can become 0,
0.1, or 1.
2025-11-20 16:36:29 -08:00
Michael Bolin 1bc4ab1a89 Merge c33e2de3e6 into sapling-pr-archive-bolinfest 2025-11-20 16:30:46 -08:00
Michael Bolin c33e2de3e6 feat: codex-shell-tool-mcp 2025-11-20 16:30:18 -08:00
Michael Bolin f5ee3ee637 feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 16:30:18 -08:00
Michael Bolin f56d1dc8fc feat: update process_exec_tool_call() to take a cancellation token (#6972)
This updates `ExecParams` so that instead of taking `timeout_ms:
Option<u64>`, it now takes a more general cancellation mechanism,
`ExecExpiration`, which is an enum that includes a
`Cancellation(tokio_util::sync::CancellationToken)` variant.

If the cancellation token is fired, then `process_exec_tool_call()`
returns in the same way as if a timeout was exceeded.

This is necessary so that in #6973, we can manage the timeout logic
external to the `process_exec_tool_call()` because we want to "suspend"
the timeout when an elicitation from a human user is pending.








---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/6972).
* #7005
* #6973
* __->__ #6972
2025-11-20 16:29:57 -08:00
Michael Bolin 0d1b4dd643 merge commit for archive created by Sapling 2025-11-20 16:22:56 -08:00
Michael Bolin a3821f1904 feat: codex-shell-tool-mcp 2025-11-20 16:22:49 -08:00
Michael Bolin 5f4459948f feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 16:22:49 -08:00
Michael Bolin fa83591049 merge commit for archive created by Sapling 2025-11-20 16:16:25 -08:00
Michael Bolin 8d3473b229 feat: update process_exec_tool_call() to take a cancellation token 2025-11-20 16:16:17 -08:00
Michael Bolin 3c3bedc8bb feat: codex-shell-tool-mcp 2025-11-20 16:16:17 -08:00
Michael Bolin 24e97ab3c4 feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 16:16:17 -08:00
Michael Bolin 0b30f833d3 merge commit for archive created by Sapling 2025-11-20 16:14:17 -08:00
Michael Bolin 35075b2f0e feat: codex-shell-tool-mcp 2025-11-20 16:14:10 -08:00
Michael Bolin 50ab543dea feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 16:14:10 -08:00
Michael Bolin 3892e0b578 merge commit for archive created by Sapling 2025-11-20 16:07:13 -08:00
Michael Bolin 6e37a602f7 feat: update process_exec_tool_call() to take a cancellation token 2025-11-20 16:07:07 -08:00
Michael Bolin 0bb0c48415 feat: codex-shell-tool-mcp 2025-11-20 16:07:07 -08:00
Michael Bolin 0401532bec feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 16:07:07 -08:00
Ahmed Ibrahim 9be310041b migrate collect_tool_identifiers_for_model to test_codex (#7041)
Maybe it solved flakiness
2025-11-20 16:02:50 -08:00
Michael Bolin d25a07c6c3 merge commit for archive created by Sapling 2025-11-20 16:02:18 -08:00
Michael Bolin f0cc39b131 feat: codex-shell-tool-mcp 2025-11-20 16:02:08 -08:00
Michael Bolin 45586d7bbf feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 16:02:08 -08:00
Michael Bolin 4c158b05ce feat: update process_exec_tool_call() to take a cancellation token 2025-11-20 16:02:08 -08:00
Xiao-Yong Jin 0fbcdd77c8 core: make shell behavior portable on FreeBSD (#7039)
- Use /bin/sh instead of /bin/bash on FreeBSD/OpenBSD in the process
group timeout test to avoid command-not-found failures.

- Accept /usr/local/bin/bash as a valid SHELL path to match common
FreeBSD installations.

- Switch the shell serialization duration test to /bin/sh for improved
portability across Unix platforms.

With this change, `cargo test -p codex-core --lib` runs and passes on
FreeBSD.
2025-11-20 16:01:35 -08:00
Michael Bolin 4c4c5b5803 merge commit for archive created by Sapling 2025-11-20 15:44:54 -08:00
Michael Bolin c975c3d60f feat: codex-shell-tool-mcp 2025-11-20 15:44:43 -08:00
Michael Bolin 88c03b24b2 feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 15:44:43 -08:00
Michael Bolin e38be129a7 feat: update process_exec_tool_call() to take a cancellation token 2025-11-20 15:44:43 -08:00
Michael Bolin 2538a5fd23 merge commit for archive created by Sapling 2025-11-20 15:23:13 -08:00
Michael Bolin 781e03664c feat: codex-shell-tool-mcp 2025-11-20 15:23:05 -08:00
Michael Bolin 782ed9af2e feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 15:23:05 -08:00
Michael Bolin 208863fdd6 feat: update process_exec_tool_call() to take a cancellation token 2025-11-20 15:23:04 -08:00
Celia Chen 9bce050385 [app-server & core] introduce new codex error code and v2 app-server error events (#6938)
This PR does two things:
1. populate a new `codex_error_code` protocol in error events sent from
core to client;
2. old v1 core events `codex/event/stream_error` and `codex/event/error`
will now both become `error`. We also show codex error code for
turncompleted -> error status.

new events in app server test:
```
< {
<   "method": "codex/event/stream_error",
<   "params": {
<     "conversationId": "019aa34c-0c14-70e0-9706-98520a760d67",
<     "id": "0",
<     "msg": {
<       "codex_error_code": {
<         "response_stream_disconnected": {
<           "http_status_code": 401
<         }
<       },
<       "message": "Reconnecting... 2/5",
<       "type": "stream_error"
<     }
<   }
< }

 {
<   "method": "error",
<   "params": {
<     "error": {
<       "codexErrorCode": {
<         "responseStreamDisconnected": {
<           "httpStatusCode": 401
<         }
<       },
<       "message": "Reconnecting... 2/5"
<     }
<   }
< }

< {
<   "method": "turn/completed",
<   "params": {
<     "turn": {
<       "error": {
<         "codexErrorCode": {
<           "responseTooManyFailedAttempts": {
<             "httpStatusCode": 401
<           }
<         },
<         "message": "exceeded retry limit, last status: 401 Unauthorized, request id: 9a1b495a1a97ed3e-SJC"
<       },
<       "id": "0",
<       "items": [],
<       "status": "failed"
<     }
<   }
< }
```
2025-11-20 23:06:55 +00:00
Michael Bolin 4d03259976 merge commit for archive created by Sapling 2025-11-20 15:05:45 -08:00
Michael Bolin 9fb1355710 feat: codex-shell-tool-mcp 2025-11-20 15:05:30 -08:00
Michael Bolin a0e90b219c feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 15:05:30 -08:00
Michael Bolin aec9655023 feat: update process_exec_tool_call() to take a cancellation token 2025-11-20 14:59:48 -08:00
iceweasel-oai 3f92ad4190 add deny ACEs for world writable dirs (#7022)
Our Restricted Token contains 3 SIDs (Logon, Everyone, {WorkspaceWrite
Capability || ReadOnly Capability})

because it must include Everyone, that left us vulnerable to directories
that allow writes to Everyone. Even though those directories do not have
ACEs that enable our capability SIDs to write to them, they could still
be written to even in ReadOnly mode, or even in WorkspaceWrite mode if
they are outside of a writable root.

A solution to this is to explicitly add *Deny* ACEs to these
directories, always for the ReadOnly Capability SID, and for the
WorkspaceWrite SID if the directory is outside of a workspace root.

Under a restricted token, Windows always checks Deny ACEs before Allow
ACEs so even though our restricted token would allow a write to these
directories due to the Everyone SID, it fails first because of the Deny
ACE on the capability SID
2025-11-20 14:50:33 -08:00
Ahmed Ibrahim 54ee302a06 Attempt to fix unified_exec_formats_large_output_summary flakiness (#7029)
second attempt to fix this test after
https://github.com/openai/codex/pull/6884. I think this flakiness is
happening because yield_time is too small for a 10,000 step loop in
python.
2025-11-20 14:38:04 -08:00
Ahmed Ibrahim 44fa06ae36 fix flaky test: approval_matrix_covers_all_modes (#7028)
looks like it sometimes flake around 30. let's give it more time.
2025-11-20 14:37:42 -08:00
pakrym-oai 856f97f449 Delete shell_command feature (#7024) 2025-11-20 14:14:56 -08:00
Michael Bolin c21cd389bc merge commit for archive created by Sapling 2025-11-20 13:50:11 -08:00
Michael Bolin 5f81440698 feat: codex-shell-tool-mcp 2025-11-20 13:50:02 -08:00
zhao-oaiandMichael Bolin fe7a3f0c2b execpolicycheck command in codex cli (#7012)
adding execpolicycheck tool onto codex cli

this is useful for validating policies (can be multiple) against
commands.

it will also surface errors in policy syntax:
<img width="1150" height="281" alt="Screenshot 2025-11-19 at 12 46
21 PM"
src="https://github.com/user-attachments/assets/8f99b403-564c-4172-acc9-6574a8d13dc3"
/>

this PR also changes output format when there's no match in the CLI.
instead of returning the raw string `noMatch`, we return
`{"noMatch":{}}`

this PR is a rewrite of: https://github.com/openai/codex/pull/6932 (due
to the numerous merge conflicts present in the original PR)

---------

Co-authored-by: Michael Bolin <mbolin@openai.com>
2025-11-20 16:44:31 -05:00
Michael Bolin 7cfd859afb feat: waiting for an elicitation should not count against a shell tool timeout 2025-11-20 13:43:05 -08:00
Michael Bolin d41c652890 feat: update process_exec_tool_call() to take a cancellation token 2025-11-20 13:43:05 -08:00