Commit Graph

8634 Commits

Author SHA1 Message Date
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
Michael Bolin
e7741647bd merge commit for archive created by Sapling 2025-07-19 11:24:00 -04:00
Michael Bolin
0c9247556a fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner 2025-07-19 11:23:55 -04:00
Michael Bolin
34fbfe59c9 merge commit for archive created by Sapling 2025-07-19 11:17:14 -04:00
Michael Bolin
32767b7ee1 fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner 2025-07-19 11:17:09 -04:00
Michael Bolin
4f97301423 Merge 3d782880e3 into sapling-pr-archive-bolinfest 2025-07-19 11:12:13 -04:00
Michael Bolin
3d782880e3 fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner 2025-07-19 11:12:06 -04:00
Michael Bolin
018003e52f feat: leverage elicitations in the MCP server (#1623)
This updates the MCP server so that if it receives an
`ExecApprovalRequest` from the `Codex` session, it in turn sends an [MCP
elicitation](https://modelcontextprotocol.io/specification/draft/client/elicitation)
to the client to ask for the approval decision. Upon getting a response,
it forwards the client's decision via `Op::ExecApproval`.

Admittedly, we should be doing the same thing for
`ApplyPatchApprovalRequest`, but this is our first time experimenting
with elicitations, so I'm inclined to defer wiring that code path up
until we feel good about how this one works.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/1623).
* __->__ #1623
* #1622
* #1621
* #1620
2025-07-19 01:32:03 -04:00
Michael Bolin
d704b83b03 merge commit for archive created by Sapling 2025-07-19 01:08:05 -04:00
Michael Bolin
5724b3bf58 feat: leverage elicitations in the MCP server 2025-07-19 01:06:40 -04:00
Michael Bolin
170aa5f9ca Merge 7d7d3084bc into sapling-pr-archive-bolinfest 2025-07-19 00:31:28 -04:00
Michael Bolin
7d7d3084bc feat: leverage elicitations in the MCP server 2025-07-19 00:31:04 -04:00
Michael Bolin
11fd3123be chore: introduce OutgoingMessageSender (#1622)
Previous to this change, `MessageProcessor` had a
`tokio::sync::mpsc::Sender<JSONRPCMessage>` as an abstraction for server
code to send a message down to the MCP client. Because `Sender` is cheap
to `clone()`, it was straightforward to make it available to tasks
scheduled with `tokio::task::spawn()`.

This worked well when we were only sending notifications or responses
back down to the client, but we want to add support for sending
elicitations in #1623, which means that we need to be able to send
_requests_ to the client, and now we need a bit of centralization to
ensure all request ids are unique.

To that end, this PR introduces `OutgoingMessageSender`, which houses
the existing `Sender<OutgoingMessage>` as well as an `AtomicI64` to mint
out new, unique request ids. It has methods like `send_request()` and
`send_response()` so that callers do not have to deal with
`JSONRPCMessage` directly, as having to set the `jsonrpc` for each
message was a bit tedious (this cleans up `codex_tool_runner.rs` quite a
bit).

We do not have `OutgoingMessageSender` implement `Clone` because it is
important that the `AtomicI64` is shared across all users of
`OutgoingMessageSender`. As such, `Arc<OutgoingMessageSender>` must be
used instead, as it is frequently shared with new tokio tasks.

As part of this change, we update `message_processor.rs` to embrace
`await`, though we must be careful that no individual handler blocks the
main loop and prevents other messages from being handled.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/1622).
* #1623
* __->__ #1622
* #1621
* #1620
2025-07-19 00:30:56 -04:00
Michael Bolin
24c0c2985a Merge 4a70da083e into sapling-pr-archive-bolinfest 2025-07-19 00:18:31 -04:00
Michael Bolin
4a70da083e feat: leverage elicitations in the MCP server 2025-07-19 00:10:47 -04:00
Michael Bolin
3fe0feabbc chore: introduce OutgoingMessageSender 2025-07-19 00:10:47 -04:00
Michael Bolin
e78ec00e73 chore: support MCP schema 2025-06-18 (#1621)
This updates the schema in `generate_mcp_types.py` from `2025-03-26` to
`2025-06-18`, regenerates `mcp-types/src/lib.rs`, and then updates all
the code that uses `mcp-types` to honor the changes.

Ran

```
npx @modelcontextprotocol/inspector just codex mcp
```

and verified that I was able to invoke the `codex` tool, as expected.


---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/1621).
* #1623
* #1622
* __->__ #1621
2025-07-19 00:09:34 -04:00
Michael Bolin
471f185b0a merge commit for archive created by Sapling 2025-07-18 23:44:00 -04:00
Michael Bolin
d7676ec022 feat: leverage elicitations in the MCP server 2025-07-18 23:43:46 -04:00
Michael Bolin
bd223a2a10 chore: introduce OutgoingMessageSender 2025-07-18 23:43:46 -04:00
Michael Bolin
888326403d chore: support MCP schema 2025-06-18 2025-07-18 23:43:46 -04:00
Michael Bolin
85a8f7c167 Merge f9ad2814d6 into sapling-pr-archive-bolinfest 2025-07-18 23:30:59 -04:00
Michael Bolin
f9ad2814d6 feat: leverage elicitations in the MCP server 2025-07-18 23:30:47 -04:00
Michael Bolin
db02c0134f chore: introduce OutgoingMessageSender 2025-07-18 23:30:47 -04:00
Michael Bolin
494302de2d chore: support MCP schema 2025-06-18 2025-07-18 23:30:47 -04:00
Michael Bolin
a06d4f58e4 chore: clean up generate_mcp_types.py so codegen matches existing output (#1620) 2025-07-18 21:40:39 -04:00
Michael Bolin
83e600e8cc Merge eff57db67d into sapling-pr-archive-bolinfest 2025-07-18 17:19:09 -07:00
Michael Bolin
eff57db67d feat: leverage elicitations in the MCP server 2025-07-18 17:05:41 -07:00
Michael Bolin
87ca807e36 chore: introduce OutgoingMessageSender 2025-07-18 17:05:41 -07:00
Michael Bolin
ed18a038b8 chore: support MCP schema 2025-06-18 2025-07-18 17:05:41 -07:00
Michael Bolin
29ff032412 chore: clean up generate_mcp_types.py so codegen matches existing output 2025-07-18 17:05:41 -07:00
aibrahim-oai
83eefb55fb Add session loading support to Codex (#1602)
## Summary
- extend rollout format to store all session data in JSON
- add resume/write helpers for rollouts
- track session state after each conversation
- support `LoadSession` op to resume a previous rollout
- allow starting Codex with an existing session via
`experimental_resume` config variable

We need a way later for exploring the available sessions in a user
friendly way.

## Testing
- `cargo test --no-run` *(fails: `cargo: command not found`)*

------
https://chatgpt.com/codex/tasks/task_i_68792a29dd5c832190bf6930d3466fba

This video is outdated. you should use `-c experimental_resume:<full
path>` instead of `--resume <full path>`


https://github.com/user-attachments/assets/7a9975c7-aa04-4f4e-899a-9e87defd947a
2025-07-18 17:04:04 -07:00
aibrahim-oai
9846adeabf Refactor env settings into config (#1601)
## Summary
- add OpenAI retry and timeout fields to Config
- inject these settings in tests instead of mutating env vars
- plumb Config values through client and chat completions logic
- document new configuration options

## Testing
- `cargo test -p codex-core --no-run`

------
https://chatgpt.com/codex/tasks/task_i_68792c5b04cc832195c03050c8b6ea94

---------

Co-authored-by: Michael Bolin <mbolin@openai.com>
2025-07-18 19:12:39 +00:00
aibrahim-oai
d5a2148deb Fix ctrl+c interrupt while streaming (#1617)
Interrupting while streaming now causes is broken because we aren't
clearing the delta buffer.
2025-07-18 12:08:25 -07:00
Michael Bolin
cc874c9205 chore: use AtomicBool instead of Mutex<bool> (#1616) 2025-07-18 11:13:34 -07:00
Michael Bolin
76da4a5d8c Merge 0e2a52a835 into sapling-pr-archive-bolinfest 2025-07-18 10:44:02 -07:00
Michael Bolin
0e2a52a835 chore: use AtomicBool instead of Mutex<bool> 2025-07-18 10:43:56 -07:00
pakrym-oai
6f2b01bb6b feat: ensure session ID header is sent in Response API request (#1614)
Include the current session id in Responses API requests.
2025-07-18 09:59:07 -07:00
Michael Bolin
fc1cadb0eb Merge 20afce7105 into sapling-pr-archive-bolinfest 2025-07-18 09:01:03 -07:00
Michael Bolin
20afce7105 fix: disable debouncing RequestRedraw in the TUI for now 2025-07-18 09:00:53 -07:00
aibrahim-oai
9cedeadf6a change the default debounce rate to 10ms (#1606)
changed the default debounce rate to 10ms because typing was laggy.

Before:


https://github.com/user-attachments/assets/e5d15fcb-6a2b-4837-b2b4-c3dcb4cc3409

After



https://github.com/user-attachments/assets/6f0005eb-fd49-4130-ba68-635ee0f2831f
2025-07-17 17:00:17 -07:00
pakrym-oai
327e2254f6 chore: rename toolchain file (#1604)
Rename toolchain file so older versions of cargo can pick it up.
2025-07-17 15:36:15 -07:00
Michael Bolin
e16657ca45 feat: add --json flag to codex exec (#1603)
This is designed to facilitate programmatic use of Codex in a more
lightweight way than using `codex mcp`.

Passing `--json` to `codex exec` will print each event as a line of JSON
to stdout. Note that it does not print the individual tokens as they are
streamed, only full messages, as this is aimed at programmatic use
rather than to power UI.

<img width="1348" height="1307" alt="image"
src="https://github.com/user-attachments/assets/fc7908de-b78d-46e4-a6ff-c85de28415c7"
/>

I changed the existing `EventProcessor` into a trait and moved the
implementation to `EventProcessorWithHumanOutput`. Then I introduced an
alternative implementation, `EventProcessorWithJsonOutput`. The `--json`
flag determines which implementation to use.
2025-07-17 15:10:15 -07:00
Michael Bolin
da894c8da7 merge commit for archive created by Sapling 2025-07-17 14:54:29 -07:00
Michael Bolin
5608e220db feat: add --json flag to codex exec 2025-07-17 14:54:10 -07:00