Commit Graph
2855 Commits
Author SHA1 Message Date
Michael Bolin e7d0627cb5 Merge cc0c30a50d into sapling-pr-archive-bolinfest 2025-08-14 12:05:12 -07:00
Michael Bolin cc0c30a50d fix: do not allow dotenv to create/modify environment variables starting with CODEX_ 2025-08-14 12:05:04 -07:00
Jeremy Rose b42e679227 remove "status text" in bottom line (#2279)
this used to hold the most recent log line, but it was kinda broken and
not that useful.
2025-08-14 14:10:21 -04:00
Jeremy Rose 585f7b0679 HistoryCell is a trait (#2283)
refactors HistoryCell to be a trait instead of an enum. Also collapse
the many "degenerate" HistoryCell enums which were just a store of lines
into a single PlainHistoryCell type.

The goal here is to allow more ways of rendering history cells (e.g.
expanded/collapsed/"live"), and I expect we will return to more varied
types of HistoryCell as we develop this area.
2025-08-14 14:10:05 -04:00
Gabriel Peal cdd33b2c04 Tag InputItem (#2304)
Instead of:
```
{ Text: { text: string } }
```

It is now:
```
{ type: "text", data: { text: string } }
```
which makes for cleaner discriminated unions
2025-08-14 17:58:04 +00:00
Michael Bolin f1f54ef6f7 merge commit for archive created by Sapling 2025-08-14 10:48:54 -07:00
Michael Bolin ce34871ccf fix: parallelize logic in Session::new() 2025-08-14 10:48:49 -07:00
Michael Bolin eb5ea22e80 merge commit for archive created by Sapling 2025-08-14 10:40:12 -07:00
Michael Bolin a07132f451 fix: parallelize logic in Session::new() 2025-08-14 10:39:56 -07:00
Michael Bolin cf7a7e63a3 exploration: create Session as part of Codex::spawn() (#2291)
Historically, `Codex::spawn()` would create the instance of `Codex` and
enforce, by construction, that `Op::ConfigureSession` was the first `Op`
submitted via `submit()`. Then over in `submission_loop()`, it would
handle the case for taking the parameters of `Op::ConfigureSession` and
turning it into a `Session`.

This approach has two challenges from a state management perspective:


https://github.com/openai/codex/blob/f968a1327ad39a7786759ea8f1d1c088fe41e91b/codex-rs/core/src/codex.rs#L718

- The local `sess` variable in `submission_loop()` has to be `mut` and
`Option<Arc<Session>>` because it is not invariant that a `Session` is
present for the lifetime of the loop, so there is a lot of logic to deal
with the case where `sess` is `None` (e.g., the `send_no_session_event`
function and all of its callsites).
- `submission_loop()` is written in such a way that
`Op::ConfigureSession` could be observed multiple times, but in
practice, it is only observed exactly once at the start of the loop.

In this PR, we try to simplify the state management by _removing_ the
`Op::ConfigureSession` enum variant and constructing the `Session` as
part of `Codex::spawn()` so that it can be passed to `submission_loop()`
as `Arc<Session>`. The original logic from the `Op::ConfigureSession`
has largely been moved to the new `Session::new()` constructor.

---

Incidentally, I also noticed that the handling of `Op::ConfigureSession`
can result in events being dispatched in addition to
`EventMsg::SessionConfigured`, as an `EventMsg::Error` is created for
every MCP initialization error, so it is important to preserve that
behavior:


https://github.com/openai/codex/blob/f968a1327ad39a7786759ea8f1d1c088fe41e91b/codex-rs/core/src/codex.rs#L901-L916

Though admittedly, I believe this does not play nice with #2264, as
these error messages will likely be dispatched before the client has a
chance to call `addConversationListener`, so we likely need to make it
so `newConversation` automatically creates the subscription, but we must
also guarantee that the "ack" from `newConversation` is returned before
any other conversation-related notifications are sent so the client
knows what `conversation_id` to match on.
2025-08-14 09:55:28 -07:00
Michael Bolin a10e80e2c3 merge commit for archive created by Sapling 2025-08-14 09:34:10 -07:00
Michael Bolin 4245cead9f exploration: create Session as part of Codex::spawn() 2025-08-14 09:32:31 -07:00
Michael Bolin 398079af6b merge commit for archive created by Sapling 2025-08-14 00:07:18 -07:00
Michael Bolin b8627ef358 exploration: create Session as part of Codex::spawn() 2025-08-14 00:07:08 -07:00
Michael Bolin c4c9cb942b Merge 070970af30 into sapling-pr-archive-bolinfest 2025-08-13 23:42:57 -07:00
Michael Bolin 070970af30 exploration: rollback #1602 2025-08-13 23:42:50 -07:00
Michael Bolin f968a1327a feat: add support for an InterruptConversation request (#2287)
This adds `ClientRequest::InterruptConversation`, which effectively maps
directly to `Op::Interrupt`.

---

* __->__  #2287
* #2286
* #2285
2025-08-13 23:12:03 -07:00
Michael Bolin 661d56204c Merge 8d6a1b462f into sapling-pr-archive-bolinfest 2025-08-13 23:01:07 -07:00
Michael Bolin 8d6a1b462f feat: add support for an InterruptConversation request 2025-08-13 23:01:00 -07:00
Michael Bolin 539f4b290e fix: add support for exec and apply_patch approvals in the new wire format (#2286)
Now when `CodexMessageProcessor` receives either a
`EventMsg::ApplyPatchApprovalRequest` or a
`EventMsg::ExecApprovalRequest`, it sends the appropriate request from
the server to the client. When it gets a response, it forwards it on to
the `CodexConversation`.

Note this takes a lot of code from:


https://github.com/openai/codex/blob/main/codex-rs/mcp-server/src/conversation_loop.rs

https://github.com/openai/codex/blob/main/codex-rs/mcp-server/src/exec_approval.rs

https://github.com/openai/codex/blob/main/codex-rs/mcp-server/src/patch_approval.rs

I am copy/pasting for now because I am trying to consolidate around the
new `wire_format.rs`, so I plan to delete these other files soon.

Now that we have requests going both from client-to-server and
server-to-client, I renamed `CodexRequest` to `ClientRequest`.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2286).
* #2287
* __->__ #2286
* #2285
2025-08-13 23:00:50 -07:00
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 PealandDylan 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-oaiandAhmed Ibrahim 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