2025-06-24 17:48:51 -07:00
|
|
|
use codex_common::summarize_sandbox_policy;
|
feat: make reasoning effort/summaries configurable (#1199)
Previous to this PR, we always set `reasoning` when making a request
using the Responses API:
https://github.com/openai/codex/blob/d7245cbbc9d8ff5446da45e5951761103492476d/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:
https://github.com/openai/codex/blob/d7245cbbc9d8ff5446da45e5951761103492476d/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
|
|
|
use codex_core::WireApi;
|
2025-05-21 22:53:02 -07:00
|
|
|
use codex_core::config::Config;
|
feat: make reasoning effort/summaries configurable (#1199)
Previous to this PR, we always set `reasoning` when making a request
using the Responses API:
https://github.com/openai/codex/blob/d7245cbbc9d8ff5446da45e5951761103492476d/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:
https://github.com/openai/codex/blob/d7245cbbc9d8ff5446da45e5951761103492476d/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
|
|
|
use codex_core::model_supports_reasoning_summaries;
|
2025-04-29 09:59:35 -07:00
|
|
|
use codex_core::protocol::Event;
|
|
|
|
|
|
2025-07-17 15:10:15 -07:00
|
|
|
pub(crate) trait EventProcessor {
|
|
|
|
|
/// Print summary of effective configuration and user prompt.
|
|
|
|
|
fn print_config_summary(&mut self, config: &Config, prompt: &str);
|
|
|
|
|
|
|
|
|
|
/// Handle a single event emitted by the agent.
|
|
|
|
|
fn process_event(&mut self, event: Event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn create_config_summary_entries(config: &Config) -> Vec<(&'static str, String)> {
|
|
|
|
|
let mut entries = vec![
|
|
|
|
|
("workdir", config.cwd.display().to_string()),
|
|
|
|
|
("model", config.model.clone()),
|
|
|
|
|
("provider", config.model_provider_id.clone()),
|
|
|
|
|
("approval", format!("{:?}", config.approval_policy)),
|
|
|
|
|
("sandbox", summarize_sandbox_policy(&config.sandbox_policy)),
|
|
|
|
|
];
|
|
|
|
|
if config.model_provider.wire_api == WireApi::Responses
|
|
|
|
|
&& model_supports_reasoning_summaries(config)
|
|
|
|
|
{
|
|
|
|
|
entries.push((
|
|
|
|
|
"reasoning effort",
|
|
|
|
|
config.model_reasoning_effort.to_string(),
|
|
|
|
|
));
|
|
|
|
|
entries.push((
|
|
|
|
|
"reasoning summaries",
|
|
|
|
|
config.model_reasoning_summary.to_string(),
|
|
|
|
|
));
|
2025-05-30 16:22:10 -07:00
|
|
|
}
|
2025-05-21 22:53:02 -07:00
|
|
|
|
2025-07-17 15:10:15 -07:00
|
|
|
entries
|
2025-04-29 09:59:35 -07:00
|
|
|
}
|