Commit Graph

2835 Commits

Author SHA1 Message Date
Michael Bolin
ab4c4e0831 Merge 2e44ccc409 into sapling-pr-archive-bolinfest 2025-08-13 22:54:35 -07:00
Michael Bolin
2e44ccc409 feat: add support for an InterruptConversation request 2025-08-13 22:54:20 -07:00
Michael Bolin
0afb5b2b66 fix: make all fields of Session private
***
fix: add support for exec and apply_patch approvals in the new wire format
2025-08-13 22:54:20 -07:00
Michael Bolin
085f166707 fix: make all fields of Session private (#2285)
As `Session` needs a bit of work, it will make things easier to move
around if we can start by reducing the extent of its public API. This
makes all the fields private, though adds three `pub(crate)` getters.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2285).
* #2287
* #2286
* __->__ #2285
2025-08-13 22:53:54 -07:00
Michael Bolin
ff8ef4a9ca Merge fdcdf0843e into sapling-pr-archive-bolinfest 2025-08-13 22:37:38 -07:00
Michael Bolin
fdcdf0843e feat: add support for an InterruptConversation request 2025-08-13 22:37:31 -07:00
Michael Bolin
3111817c62 Merge 7e8c80f005 into sapling-pr-archive-bolinfest 2025-08-13 22:25:27 -07:00
Michael Bolin
7e8c80f005 fix: make all fields of Session private
***
fix: add support for exec and apply_patch approvals in the new wire format
2025-08-13 22:25:07 -07:00
Michael Bolin
93c7015b6a Merge a0ff6e8395 into sapling-pr-archive-bolinfest 2025-08-13 22:24:38 -07:00
Michael Bolin
a0ff6e8395 fix: make all fields of Session private 2025-08-13 22:24:03 -07:00
Michael Bolin
7ae4de59de Merge 6c2ed966f2 into sapling-pr-archive-bolinfest 2025-08-13 22:21:05 -07:00
Michael Bolin
6c2ed966f2 fix: add support for exec and apply_patch approvals in the new wire format 2025-08-13 22:20:14 -07:00
Michael Bolin
f086da31e5 fix: make all fields of Session private 2025-08-13 22:16:47 -07:00
Michael Bolin
fa801fb3d0 Merge 6643dcf735 into sapling-pr-archive-bolinfest 2025-08-13 21:31:15 -07:00
Michael Bolin
6643dcf735 fix: make all fields of Session private 2025-08-13 21:31:07 -07:00
Kazuhiro Sera
6d0eb9128e Use enhancement tag for feature requests (#2282) 2025-08-14 12:08:35 +09:00
Gabriel Peal
e8ffecd632 Clarify PR/Contribution guidelines and issue templates (#2281)
Co-authored-by: Dylan <dylan.hurd@openai.com>
2025-08-13 21:56:29 -04:00
pakrym-oai
f1be7978cf Parse reasoning text content (#2277)
Sometimes COT is returns as text content instead of `ReasoningText`. We
should parse it but not serialize back on requests.

---------

Co-authored-by: Ahmed Ibrahim <aibrahim@openai.com>
2025-08-13 18:39:58 -07:00
Michael Bolin
a62510e0ae fix: verify notifications are sent with the conversationId set (#2278)
This updates `CodexMessageProcessor` so that each notification it sends
for a `EventMsg` from a `CodexConversation` such that:

- The `params` always has an appropriate `conversationId` field.
- The `method` is now includes the name of the `EventMsg` type rather
than using `codex/event` as the `method` type for all notifications. (We
currently prefix the method name with `codex/event/`, but I think that
should go away once we formalize the notification schema in
`wire_format.rs`.)

As part of this, we update `test_codex_jsonrpc_conversation_flow()` to
verify that the `task_finished` notification has made it through the
system instead of sleeping for 5s and "hoping" the server finished
processing the task. Note we have seen some flakiness in some of our
other, similar integration tests, and I expect adding a similar check
would help in those cases, as well.
2025-08-13 17:54:12 -07:00
Michael Bolin
03b31736ec Merge fdcedd671a into sapling-pr-archive-bolinfest 2025-08-13 17:54:03 -07:00
Michael Bolin
fdcedd671a fix: verify notifications are sent with the conversationId set 2025-08-13 17:53:49 -07:00
Michael Bolin
e7bad650ff feat: support traditional JSON-RPC request/response in MCP server (#2264)
This introduces a new set of request types that our `codex mcp`
supports. Note that these do not conform to MCP tool calls so that
instead of having to send something like this:

```json
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "id": 42,
  "params": {
    "name": "newConversation",
    "arguments": {
      "model": "gpt-5",
      "approvalPolicy": "on-request"
    }
  }
}
```

we can send something like this:


```json
{
  "jsonrpc": "2.0",
  "method": "newConversation",
  "id": 42,
  "params": {
    "model": "gpt-5",
    "approvalPolicy": "on-request"
  }
}
```

Admittedly, this new format is not a valid MCP tool call, but we are OK
with that right now. (That is, not everything we might want to request
of `codex mcp` is something that is appropriate for an autonomous agent
to do.)

To start, this introduces four request types:

- `newConversation`
- `sendUserMessage`
- `addConversationListener`
- `removeConversationListener`

The new `mcp-server/tests/codex_message_processor_flow.rs` shows how
these can be used.

The types are defined on the `CodexRequest` enum, so we introduce a new
`CodexMessageProcessor` that is responsible for dealing with requests
from this enum. The top-level `MessageProcessor` has been updated so
that when `process_request()` is called, it first checks whether the
request conforms to `CodexRequest` and dispatches it to
`CodexMessageProcessor` if so.

Note that I also decided to use `camelCase` for the on-the-wire format,
as that seems to be the convention for MCP.

For the moment, the new protocol is defined in `wire_format.rs` within
the `mcp-server` crate, but in a subsequent PR, I will probably move it
to its own crate to ensure the protocol has minimal dependencies and
that we can codegen a schema from it.



---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2264).
* #2278
* __->__ #2264
2025-08-13 17:36:29 -07:00
Michael Bolin
9042585db1 merge commit for archive created by Sapling 2025-08-13 17:26:38 -07:00
Michael Bolin
fc31c6bdda fix: verify notifications are sent with the conversationId set 2025-08-13 17:25:30 -07:00
Michael Bolin
62b35cb687 feat: support traditional JSON-RPC request/response in MCP server 2025-08-13 17:25:30 -07:00
Michael Bolin
5053b43a46 Merge 0f3eed0d0d into sapling-pr-archive-bolinfest 2025-08-13 17:07:04 -07:00
Michael Bolin
0f3eed0d0d fix: verify notifications are sent with the conversationId set 2025-08-13 17:07:00 -07:00
pakrym-oai
de2c6a2ce7 Enable reasoning for codex-prefixed models (#2275)
## Summary
- enable reasoning for any model slug starting with `codex-`
- provide default model info for `codex-*` slugs
- test that codex models are detected and support reasoning

## Testing
- `just fmt`
- `just fix` *(fails: E0658 `let` expressions in this position are
unstable)*
- `cargo test --all-features` *(fails: E0658 `let` expressions in this
position are unstable)*

------
https://chatgpt.com/codex/tasks/task_i_689d13f8705483208a6ed21c076868e1
2025-08-13 17:02:50 -07:00
Michael Bolin
589c6096be Merge 0076e3ac19 into sapling-pr-archive-bolinfest 2025-08-13 17:00:34 -07:00
Michael Bolin
0076e3ac19 fix: verify notifications are sent with the conversationId set 2025-08-13 17:00:22 -07:00
Michael Bolin
3a0656df63 fix: skip cargo test for release builds on ordinary CI because it is slow, particularly with --all-features set (#2276)
I put this PR together because I noticed I have to wait quite a bit
longer on my PRs since we added
https://github.com/openai/codex/pull/2242 to catch more build issues.

I think we should think about reigning in our use of create features,
but this should be good enough to speed things up for now.
2025-08-13 16:27:20 -07:00
Michael Bolin
8d4eaea440 Merge 55b62d6e25 into sapling-pr-archive-bolinfest 2025-08-13 16:20:04 -07:00
Michael Bolin
55b62d6e25 fix: skip cargo test for release builds on ordinary CI because it is slow, particularly with --all-features set 2025-08-13 16:19:57 -07:00
Jeremy Rose
bb9ce3cb78 tui: standardize tree prefix glyphs to └ (#2274)
Replace mixed `⎿` and `L` prefixes with `└` in TUI rendering.

<img width="454" height="659" alt="Screenshot 2025-08-13 at 4 02 03 PM"
src="https://github.com/user-attachments/assets/61c9c7da-830b-4040-bb79-a91be90870ca"
/>
2025-08-13 19:14:03 -04:00
Michael Bolin
f516910dca Merge 1b07bd717f into sapling-pr-archive-bolinfest 2025-08-13 16:02:38 -07:00
Michael Bolin
1b07bd717f feat: support traditional JSON-RPC request/response in MCP server 2025-08-13 16:02:33 -07:00
Michael Bolin
9bf0be74f1 merge commit for archive created by Sapling 2025-08-13 15:55:59 -07:00
Michael Bolin
c50e892ba5 feat: support traditional JSON-RPC request/response in MCP server 2025-08-13 15:55:52 -07:00
aibrahim-oai
cbf972007a use modifier dim instead of gray and .dim (#2273)
gray color doesn't work very well with white terminals. `.dim` doesn't
have an effect for some reason.

after:
<img width="1080" height="149" alt="image"
src="https://github.com/user-attachments/assets/26c0f8bb-550d-4d71-bd06-11b3189bc1d7"
/>

Before
<img width="1077" height="186" alt="image"
src="https://github.com/user-attachments/assets/b1fba0c7-bc4d-4da1-9754-6c0a105e8cd1"
/>
2025-08-13 22:50:50 +00:00
Michael Bolin
4fd22134b7 Merge b792c4d0bb into sapling-pr-archive-bolinfest 2025-08-13 15:50:12 -07:00
Michael Bolin
b792c4d0bb feat: support traditional JSON-RPC request/response in MCP server 2025-08-13 15:47:50 -07:00
pakrym-oai
41eb59a07d Wait for requested delay in rate limit errors (#2266)
Fixes: https://github.com/openai/codex/issues/2131

Response doesn't have the delay in a separate field (yet) so parse the
message.
2025-08-13 15:43:54 -07:00
Michael Bolin
37fc4185ef fix: update OutgoingMessageSender::send_response() to take Serialize (#2263)
This makes `send_response()` easier to work with.
2025-08-13 14:29:13 -07:00
aibrahim-oai
d4533a0bb3 TUI: change the diff preview to have color fg not bg (#2270)
<img width="328" height="95" alt="image"
src="https://github.com/user-attachments/assets/70e1e6c2-a88f-4058-8763-85c3a02eedb4"
/>
2025-08-13 14:21:24 -07:00
Dylan
99a242ef41 [codex-cli] Add ripgrep as a dependency for node environment (#2237)
## Summary
Ripgrep is our preferred tool for file search. When users install via
`brew install codex`, it's automatically installed as a dependency. We
want to ensure that users running via an npm install also have this
tool! Microsoft has already solved this problem for VS Code - let's not
reinvent the wheel.

This approach of appending to the PATH directly might be a bit
heavy-handed, but feels reasonably robust to a variety of environment
concerns. Open to thoughts on better approaches here!

## Testing
- [x] confirmed this import approach works with `node -e "const { rgPath
} = require('@vscode/ripgrep'); require('child_process').spawn(rgPath,
['--version'], { stdio: 'inherit' })"`
- [x] Ran codex.js locally with `rg` uninstalled, asked it to run `which
rg`. Output below:

```
 Ran command which rg; echo $?
  ⎿ /Users/dylan.hurd/code/dh--npm-rg/node_modules/@vscode/ripgrep/bin/rg
    0

codex
Re-running to confirm the path and exit code.

- Path: `/Users/dylan.hurd/code/dh--npm-rg/node_modules/@vscode/ripgrep/bin/rg`
- Exit code: `0`
```
2025-08-13 13:49:27 -07:00
Michael Bolin
472f9cfb38 merge commit for archive created by Sapling 2025-08-13 13:40:14 -07:00
Michael Bolin
06aa79880e fix: update OutgoingMessageSender::send_response() to take Serialize 2025-08-13 13:40:04 -07:00
Michael Bolin
08ed618f72 chore: introduce ConversationManager as a clearinghouse for all conversations (#2240)
This PR does two things because after I got deep into the first one I
started pulling on the thread to the second:

- Makes `ConversationManager` the place where all in-memory
conversations are created and stored. Previously, `MessageProcessor` in
the `codex-mcp-server` crate was doing this via its `session_map`, but
this is something that should be done in `codex-core`.
- It unwinds the `ctrl_c: tokio::sync::Notify` that was threaded
throughout our code. I think this made sense at one time, but now that
we handle Ctrl-C within the TUI and have a proper `Op::Interrupt` event,
I don't think this was quite right, so I removed it. For `codex exec`
and `codex proto`, we now use `tokio::signal::ctrl_c()` directly, but we
no longer make `Notify` a field of `Codex` or `CodexConversation`.

Changes of note:

- Adds the files `conversation_manager.rs` and `codex_conversation.rs`
to `codex-core`.
- `Codex` and `CodexSpawnOk` are no longer exported from `codex-core`:
other crates must use `CodexConversation` instead (which is created via
`ConversationManager`).
- `core/src/codex_wrapper.rs` has been deleted in favor of
`ConversationManager`.
- `ConversationManager::new_conversation()` returns `NewConversation`,
which is in line with the `new_conversation` tool we want to add to the
MCP server. Note `NewConversation` includes `SessionConfiguredEvent`, so
we eliminate checks in cases like `codex-rs/core/tests/client.rs` to
verify `SessionConfiguredEvent` is the first event because that is now
internal to `ConversationManager`.
- Quite a bit of code was deleted from
`codex-rs/mcp-server/src/message_processor.rs` since it no longer has to
manage multiple conversations itself: it goes through
`ConversationManager` instead.
- `core/tests/live_agent.rs` has been deleted because I had to update a
bunch of tests and all the tests in here were ignored, and I don't think
anyone ever ran them, so this was just technical debt, at this point.
- Removed `notify_on_sigint()` from `util.rs` (and in a follow-up, I
hope to refactor the blandly-named `util.rs` into more descriptive
files).
- In general, I started replacing local variables named `codex` as
`conversation`, where appropriate, though admittedly I didn't do it
through all the integration tests because that would have added a lot of
noise to this PR.




---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2240).
* #2264
* #2263
* __->__ #2240
2025-08-13 13:38:18 -07:00
Michael Bolin
b58aa53e01 Merge 7a5c29804c into sapling-pr-archive-bolinfest 2025-08-13 13:04:49 -07:00
Michael Bolin
7a5c29804c feat: support traditional JSON-RPC request/response in MCP server 2025-08-13 13:02:22 -07:00