mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Add managed new-thread model settings
This commit is contained in:
@@ -242,7 +242,7 @@ Example with notification opt-out:
|
||||
- `externalAgentConfig/import` — apply selected external-agent migration items by passing explicit `migrationItems` with `cwd` (`null` for home) and any `details` returned by detect. Callers may pass `source` to identify the product that initiated the import; omitted or `null` means unspecified. The response acknowledges the synchronous import phase with an `importId`. Expected migration failures are reported as per-item failures rather than JSON-RPC errors, so the server still returns that `importId` and emits `externalAgentConfig/import/completed` with the same ID once all synchronous and background work finishes. The completion notification contains type-level `itemTypeResults` with successes and failures, including raw failure messages for the client to report separately.
|
||||
- `config/value/write` — write a single config key/value to the user's config.toml on disk; dotted paths such as `desktop.someKey` use the same generic write surface.
|
||||
- `config/batchWrite` — apply multiple config edits atomically to the user's config.toml on disk, with optional `reloadUserConfig: true` to hot-reload loaded threads, including multiple `desktop.*` edits.
|
||||
- `configRequirements/read` — fetch loaded requirements constraints from `requirements.toml` and/or MDM (or `null` if none are configured), including allow-lists (`allowedApprovalPolicies`, `allowedSandboxModes`, `allowedWebSearchModes`), the layered permission-profile allow map (`allowedPermissionProfiles`), the managed permission-profile default (`defaultPermissions`), lifecycle hook lockdown (`allowManagedHooksOnly`), remote-control policy (`allowRemoteControl`; `false` force-disables remote control while `true` or `null` preserves existing behavior), computer use policy (`computerUse`), pinned feature values (`featureRequirements`), managed lifecycle hooks (`hooks`), `enforceResidency`, `models.newThread.model`, and `network` constraints such as canonical domain/socket permissions plus `managedAllowedDomainsOnly` and `dangerFullAccessDenylistOnly`.
|
||||
- `configRequirements/read` — fetch loaded requirements constraints from `requirements.toml` and/or MDM (or `null` if none are configured), including allow-lists (`allowedApprovalPolicies`, `allowedSandboxModes`, `allowedWebSearchModes`), the layered permission-profile allow map (`allowedPermissionProfiles`), the managed permission-profile default (`defaultPermissions`), lifecycle hook lockdown (`allowManagedHooksOnly`), remote-control policy (`allowRemoteControl`; `false` force-disables remote control while `true` or `null` preserves existing behavior), computer use policy (`computerUse`), pinned feature values (`featureRequirements`), managed lifecycle hooks (`hooks`), `enforceResidency`, managed new-thread defaults (`models.newThread.model`, `models.newThread.modelReasoningEffort`, and `models.newThread.serviceTier`), and `network` constraints such as canonical domain/socket permissions plus `managedAllowedDomainsOnly` and `dangerFullAccessDenylistOnly`.
|
||||
|
||||
### Example: Start or resume a thread
|
||||
|
||||
|
||||
@@ -380,6 +380,8 @@ fn map_requirements_toml_to_api(requirements: ConfigRequirementsToml) -> ConfigR
|
||||
models: requirements.models.map(|models| ModelsRequirements {
|
||||
new_thread: models.new_thread.map(|new_thread| NewThreadModelDefaults {
|
||||
model: new_thread.model,
|
||||
model_reasoning_effort: new_thread.model_reasoning_effort,
|
||||
service_tier: new_thread.service_tier,
|
||||
}),
|
||||
}),
|
||||
}
|
||||
@@ -578,6 +580,7 @@ mod tests {
|
||||
use codex_config::ModelsRequirementsToml;
|
||||
use codex_config::NewThreadModelDefaultsToml;
|
||||
use codex_config::WindowsRequirementsToml;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -638,23 +641,28 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn requirements_api_includes_new_thread_model() {
|
||||
fn requirements_api_includes_new_thread_model_defaults() {
|
||||
let mapped = map_requirements_toml_to_api(ConfigRequirementsToml {
|
||||
models: Some(ModelsRequirementsToml {
|
||||
new_thread: Some(NewThreadModelDefaultsToml {
|
||||
model: Some("gpt-managed".to_string()),
|
||||
model_reasoning_effort: Some(ReasoningEffort::Medium),
|
||||
service_tier: Some("fast".to_string()),
|
||||
}),
|
||||
}),
|
||||
..ConfigRequirementsToml::default()
|
||||
});
|
||||
|
||||
let defaults = mapped
|
||||
.models
|
||||
.and_then(|models| models.new_thread)
|
||||
.expect("new-thread defaults");
|
||||
assert_eq!(defaults.model.as_deref(), Some("gpt-managed"));
|
||||
assert_eq!(
|
||||
mapped
|
||||
.models
|
||||
.and_then(|models| models.new_thread)
|
||||
.and_then(|new_thread| new_thread.model),
|
||||
Some("gpt-managed".to_string())
|
||||
defaults.model_reasoning_effort,
|
||||
Some(ReasoningEffort::Medium)
|
||||
);
|
||||
assert_eq!(defaults.service_tier.as_deref(), Some("fast"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -76,13 +76,15 @@ async fn config_requirements_read_includes_allow_remote_control() -> Result<()>
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn config_requirements_read_includes_new_thread_model() -> Result<()> {
|
||||
async fn config_requirements_read_includes_new_thread_model_defaults() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("requirements.toml"),
|
||||
r#"
|
||||
[models.new_thread]
|
||||
model = "gpt-managed"
|
||||
model_reasoning_effort = "medium"
|
||||
service_tier = "fast"
|
||||
"#,
|
||||
)?;
|
||||
let mut mcp = TestAppServer::new(codex_home.path()).await?;
|
||||
@@ -96,15 +98,17 @@ model = "gpt-managed"
|
||||
.await??;
|
||||
let response: ConfigRequirementsReadResponse = to_response(response)?;
|
||||
|
||||
let defaults = response
|
||||
.requirements
|
||||
.and_then(|requirements| requirements.models)
|
||||
.and_then(|models| models.new_thread)
|
||||
.expect("managed new-thread defaults");
|
||||
assert_eq!(defaults.model.as_deref(), Some("gpt-managed"));
|
||||
assert_eq!(
|
||||
response
|
||||
.requirements
|
||||
.and_then(|requirements| requirements.models)
|
||||
.and_then(|models| models.new_thread)
|
||||
.and_then(|new_thread| new_thread.model)
|
||||
.as_deref(),
|
||||
Some("gpt-managed")
|
||||
defaults.model_reasoning_effort,
|
||||
Some(ReasoningEffort::Medium)
|
||||
);
|
||||
assert_eq!(defaults.service_tier.as_deref(), Some("fast"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ use codex_app_server_protocol::UserInput as V2UserInput;
|
||||
use codex_config::loader::project_trust_key;
|
||||
use codex_config::types::AuthCredentialsStoreMode;
|
||||
use codex_core::config::set_project_trust_level;
|
||||
use codex_core::test_support::all_model_presets;
|
||||
use codex_exec_server::LOCAL_FS;
|
||||
use codex_git_utils::resolve_root_git_project_for_trust;
|
||||
use codex_login::REFRESH_TOKEN_URL_OVERRIDE_ENV_VAR;
|
||||
@@ -200,16 +201,30 @@ async fn thread_start_creates_thread_and_emits_started() -> Result<()> {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_uses_managed_new_thread_model() -> Result<()> {
|
||||
async fn thread_start_uses_managed_new_thread_model_defaults() -> Result<()> {
|
||||
let server = create_mock_responses_server_repeating_assistant("Done").await;
|
||||
let codex_home = TempDir::new()?;
|
||||
create_config_toml_without_approval_policy(codex_home.path(), &server.uri())?;
|
||||
let managed_model = all_model_presets()
|
||||
.iter()
|
||||
.find(|preset| {
|
||||
preset
|
||||
.service_tiers
|
||||
.iter()
|
||||
.any(|tier| tier.id == "priority")
|
||||
})
|
||||
.context("expected a model with the fast service tier")?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("requirements.toml"),
|
||||
r#"
|
||||
format!(
|
||||
r#"
|
||||
[models.new_thread]
|
||||
model = "gpt-managed"
|
||||
model = "{}"
|
||||
model_reasoning_effort = "medium"
|
||||
service_tier = "fast"
|
||||
"#,
|
||||
managed_model.id
|
||||
),
|
||||
)?;
|
||||
|
||||
let mut mcp = TestAppServer::new(codex_home.path()).await?;
|
||||
@@ -228,7 +243,9 @@ model = "gpt-managed"
|
||||
.await??;
|
||||
let response: ThreadStartResponse = to_response(response)?;
|
||||
|
||||
assert_eq!(response.model, "gpt-managed");
|
||||
assert_eq!(response.model, managed_model.id);
|
||||
assert_eq!(response.reasoning_effort, Some(ReasoningEffort::Medium));
|
||||
assert_eq!(response.service_tier.as_deref(), Some("priority"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user