Commit Graph

1797 Commits

Author SHA1 Message Date
Michael Bolin
2d6824040a merge commit for archive created by Sapling 2025-06-02 16:59:26 -07:00
Michael Bolin
956dc56a1f chore: replace regex with regex-lite, where appropriate 2025-06-02 16:58:49 -07:00
Michael Bolin
8691e269c4 Merge 0efbb7f7f1 into sapling-pr-archive-bolinfest 2025-06-02 16:56:39 -07:00
Michael Bolin
0efbb7f7f1 chore: replace regex with regex-lite, where appropriate 2025-06-02 16:56:32 -07:00
Michael Bolin
0f3cc8f842 feat: make reasoning effort/summaries configurable (#1199)
Previous to this PR, we always set `reasoning` when making a request
using the Responses API:


d7245cbbc9/codex-rs/core/src/client.rs (L108-L111)

Though if you tried to use the Rust CLI with `--model gpt-4.1`, this
would fail with:

```shell
"Unsupported parameter: 'reasoning.effort' is not supported with this model."
```

We take a cue from the TypeScript CLI, which does a check on the model
name:


d7245cbbc9/codex-cli/src/utils/agent/agent-loop.ts (L786-L789)

This PR does a similar check, though also adds support for the following
config options:

```
model_reasoning_effort = "low" | "medium" | "high" | "none"
model_reasoning_summary = "auto" | "concise" | "detailed" | "none"
```

This way, if you have a model whose name happens to start with `"o"` (or
`"codex"`?), you can set these to `"none"` to explicitly disable
reasoning, if necessary. (That said, it seems unlikely anyone would use
the Responses API with non-OpenAI models, but we provide an escape
hatch, anyway.)

This PR also updates both the TUI and `codex exec` to show `reasoning
effort` and `reasoning summaries` in the header.
2025-06-02 16:01:34 -07:00
Michael Bolin
76e0eba41c merge commit for archive created by Sapling 2025-06-02 15:49:23 -07:00
Michael Bolin
75266a1018 feat: make reasoning effort/summaries configurable 2025-06-02 15:49:16 -07:00
Michael Bolin
cb57fd44a9 Merge 02cf240557 into sapling-pr-archive-bolinfest 2025-06-02 15:24:32 -07:00
Michael Bolin
02cf240557 feat: make reasoning effort/summaries configurable 2025-06-02 15:24:23 -07:00
Michael Bolin
d7245cbbc9 fix: chat completions API now also passes tools along (#1167)
Prior to this PR, there were two big misses in `chat_completions.rs`:

1. The loop in `stream_chat_completions()` was only including items of
type `ResponseItem::Message` when building up the `"messages"` JSON for
the `POST` request to the `chat/completions` endpoint. This fixes things
by ensuring other variants (`FunctionCall`, `LocalShellCall`, and
`FunctionCallOutput`) are included, as well.
2. In `process_chat_sse()`, we were not recording tool calls and were
only emitting items of type
`ResponseEvent::OutputItemDone(ResponseItem::Message)` to the stream.
Now we introduce `FunctionCallState`, which is used to accumulate the
`delta`s of type `tool_calls`, so we can ultimately emit a
`ResponseItem::FunctionCall`, when appropriate.

While function calling now appears to work for chat completions with my
local testing, I believe that there are still edge cases that are not
covered and that this codepath would benefit from a battery of
integration tests. (As part of that further cleanup, we should also work
to support streaming responses in the UI.)

The other important part of this PR is some cleanup in
`core/src/codex.rs`. In particular, it was hard to reason about how
`run_task()` was building up the list of messages to include in a
request across the various cases:

- Responses API
- Chat Completions API
- Responses API used in concert with ZDR

I like to think things are a bit cleaner now where:

- `zdr_transcript` (if present) contains all messages in the history of
the conversation, which includes function call outputs that have not
been sent back to the model yet
- `pending_input` includes any messages the user has submitted while the
turn is in flight that need to be injected as part of the next `POST` to
the model
- `input_for_next_turn` includes the tool call outputs that have not
been sent back to the model yet
2025-06-02 13:47:51 -07:00
Michael Bolin
0789e6125e Merge a13a300e0f into sapling-pr-archive-bolinfest 2025-06-02 13:33:13 -07:00
Michael Bolin
a13a300e0f fix: chat completions API to work with tools 2025-06-02 13:33:06 -07:00
Michael Bolin
e40f86b446 chore: logging cleanup (#1196)
Update what we log to make `RUST_LOG=debug` a bit easier to work with.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/1196).
* #1167
* __->__ #1196
2025-06-02 13:31:33 -07:00
Michael Bolin
d4e9a81abc Merge 0b880458a7 into sapling-pr-archive-bolinfest 2025-06-02 13:19:18 -07:00
Michael Bolin
0b880458a7 fix: chat completions API to work with tools 2025-06-02 13:18:56 -07:00
Michael Bolin
ee43e1b2d1 chore: logging cleanup
Update what we log to make `RUST_LOG=debug` a bit easier to work with.
2025-06-02 13:18:50 -07:00
Michael Bolin
54854e516a Merge e5f9b9ce92 into sapling-pr-archive-bolinfest 2025-06-02 13:17:23 -07:00
Michael Bolin
e5f9b9ce92 fix: chat completions API to work with tools 2025-06-02 13:13:14 -07:00
Michael Bolin
7907ead08e merge commit for archive created by Sapling 2025-06-02 13:09:45 -07:00
Michael Bolin
c16d2ce27e fix: chat completions API to work with tools 2025-06-02 13:09:39 -07:00
Michael Bolin
b1b2ff50d9 merge commit for archive created by Sapling 2025-06-02 12:00:39 -07:00
Michael Bolin
55c0d4e9c1 fix: chat completions API to work with tools 2025-06-02 12:00:32 -07:00
Michael Bolin
7896b1089d chore: update the WORKFLOW_URL in install_native_deps.sh to the latest release (#1190) 2025-05-31 10:30:50 -07:00
Michael Bolin
f1731e7cac Merge ce808d7cc6 into sapling-pr-archive-bolinfest 2025-05-31 10:24:26 -07:00
Michael Bolin
ce808d7cc6 chore: update the WORKFLOW_URL in install_native_deps.sh to the latest release 2025-05-31 10:24:19 -07:00
Michael Bolin
1410ae95ca fix: set --config hide_agent_reasoning=true in the GitHub Action (#1185)
Whoops, I had this flipped in https://github.com/openai/codex/pull/1183.
2025-05-30 23:57:05 -07:00
Michael Bolin
4145e489c4 Merge 7bda9d1fbc into sapling-pr-archive-bolinfest 2025-05-30 23:56:32 -07:00
Michael Bolin
7bda9d1fbc fix: set --config hide_agent_reasoning=true in the GitHub Action 2025-05-30 23:56:23 -07:00
Michael Bolin
a4a9204d2c Merge b7d9e36bbe into sapling-pr-archive-bolinfest 2025-05-30 23:50:21 -07:00
Michael Bolin
b7d9e36bbe fix: chat completions API to work with tools 2025-05-30 23:50:16 -07:00
Michael Bolin
fccf5f3221 fix: disable agent reasoning output by default in the GitHub Action (#1183) 2025-05-30 23:49:48 -07:00
Michael Bolin
0f5319714d merge commit for archive created by Sapling 2025-05-30 23:41:34 -07:00
Michael Bolin
9358392237 fix: disable agent reasoning output by default in the GitHub Action 2025-05-30 23:41:27 -07:00
Michael Bolin
2df6e07bed Merge 953fd5324b into sapling-pr-archive-bolinfest 2025-05-30 23:32:08 -07:00
Michael Bolin
953fd5324b fix: disable agent reasoning output by default in the GitHub Action 2025-05-30 23:30:33 -07:00
Michael Bolin
1159eaf04f feat: show the version when starting Codex (#1182)
The TypeScript version of the CLI shows the version when it starts up,
which is helpful when users share screenshots (and nice to know, as a
user).
codex-rs-ca8e97fcbcb991e542b8689f2d4eab9d30c399d6-1-rust-v0.0.2505302325
2025-05-30 23:24:36 -07:00
Michael Bolin
ccdf43699d Merge 1bda6e0da5 into sapling-pr-archive-bolinfest 2025-05-30 23:22:00 -07:00
Michael Bolin
1bda6e0da5 feat: show the version when starting Codex 2025-05-30 23:21:46 -07:00
Michael Bolin
e81327e5f4 feat: add hide_agent_reasoning config option (#1181)
This PR introduces a `hide_agent_reasoning` config option (that defaults
to `false`) that users can enable to make the output less verbose by
suppressing reasoning output.

To test, verified that this includes agent reasoning in the output:

```
echo hello | just exec
```

whereas this does not:

```
echo hello | just exec --config hide_agent_reasoning=false
```
2025-05-30 23:14:56 -07:00
Michael Bolin
67915b460b Merge 6576c6292c into sapling-pr-archive-bolinfest 2025-05-30 23:11:59 -07:00
Michael Bolin
6576c6292c feat: add hide_agent_reasoning config option 2025-05-30 23:11:55 -07:00
Michael Bolin
76700f7f05 merge commit for archive created by Sapling 2025-05-30 23:08:18 -07:00
Michael Bolin
ace269f2b6 feat: add hide_agent_reasoning config option 2025-05-30 23:06:30 -07:00
Michael Bolin
4f3d294762 feat: dim the timestamp in the exec output (#1180)
This required changing `ts_println!()` to take `$self:ident`, which is a
bit more verbose, but the usability improvement seems worth it.

Also eliminated an unnecessary `.to_string()` while here.
codex-rs-378d773f3af95384eef51addf560df30aa9fd15f-1-rust-v0.0.2505301630
2025-05-30 16:27:37 -07:00
Michael Bolin
941a84aafb merge commit for archive created by Sapling 2025-05-30 16:25:47 -07:00
Michael Bolin
b3623ffc61 feat: dim the timestamp in the exec output 2025-05-30 16:25:39 -07:00
Michael Bolin
cf1d070538 feat: grab-bag of improvements to exec output (#1179)
Fixes:

* Instantiate `EventProcessor` earlier in `lib.rs` so
`print_config_summary()` can be an instance method of it and leverage
its various `Style` fields to ensure it honors `with_ansi` properly.
* After printing the config summary, print out user's prompt with the
heading `User instructions:`. As noted in the comment, now that we can
read the instructions via stdin as of #1178, it is helpful to the user
to ensure they know what instructions were given to Codex.
* Use same colors/bold/italic settings for headers as the TUI, making
the output a bit easier to read.
2025-05-30 16:22:10 -07:00
Michael Bolin
44a9fc30d1 Merge 4b0578b5e4 into sapling-pr-archive-bolinfest 2025-05-30 16:05:06 -07:00
Michael Bolin
4b0578b5e4 feat: grab-bag of improvements to exec output 2025-05-30 16:04:59 -07:00
Michael Bolin
ae743d56b0 feat: for codex exec, if PROMPT is not specified, read from stdin if not a TTY (#1178)
This attempts to make `codex exec` more flexible in how the prompt can
be passed:

* as before, it can be passed as a single string argument
* if `-` is passed as the value, the prompt is read from stdin
* if no argument is passed _and stdin is a tty_, prints a warning to
stderr that no prompt was specified an exits non-zero.
* if no argument is passed _and stdin is NOT a tty_, prints `Reading
prompt from stdin...` to stderr to let the user know that Codex will
wait until it reads EOF from stdin to proceed. (You can repro this case
by doing `yes | just exec` since stdin is not a TTY in that case but it
also never reaches EOF).
2025-05-30 14:41:55 -07:00