Files
codex/codex-rs/protocol/src/models/configuration_update_tests.rs
T
felixxia-oai 0d502a4230 Support durable reasoning configuration updates (#42328)
## Why

Reasoning configuration changes need to retain their position and trusted provenance when model history is persisted and replayed. Client-injected history must not be able to forge these controls.

## What changed

- Add a typed `configuration_update` response item carrying reasoning effort, including custom model-defined values.
- Persist harness-authored updates with provenance and preserve them across history reconstruction, thread resume, raw response notifications, and agent forks.
- Exclude untrusted configuration updates from model history, strip client-supplied provenance metadata, and reject configuration updates supplied as turn input.
- Export the new item through the JSON and TypeScript app-server schemas and classify it in telemetry and persistence metrics.

## Testing

- Cover serialization, provenance persistence, history filtering and rollback, resume reconstruction, and injection attempts before and after restart.

GitOrigin-RevId: eb5559d2b52b7a931621e7c9812f009ff9fb8939
2026-09-02 18:52:44 +00:00

51 lines
1.5 KiB
Rust

use super::ConfigurationReasoning;
use crate::ResponseItemId;
use crate::models::ResponseItem;
use crate::openai_models::ReasoningEffort;
use pretty_assertions::assert_eq;
use serde_json::json;
#[test]
fn configuration_update_round_trips_without_message_fields() {
let value = json!({
"type": "configuration_update",
"reasoning": { "effort": "high" }
});
let mut item: ResponseItem = serde_json::from_value(value.clone()).unwrap();
assert_eq!(
item,
ResponseItem::ConfigurationUpdate {
reasoning: ConfigurationReasoning {
effort: ReasoningEffort::High,
},
}
);
item.set_id(Some(ResponseItemId::new("configuration-id")));
item.set_turn_id_if_missing("turn-id");
item.set_create_time_if_missing(serde_json::Number::from(123));
assert_eq!(
(item.id(), item.id_prefix(), item.turn_id()),
(None, None, None)
);
assert_eq!(serde_json::to_value(item).unwrap(), value);
}
#[test]
fn configuration_update_preserves_model_defined_effort() {
let value = json!({
"type": "configuration_update",
"reasoning": { "effort": "model-specific" }
});
let item: ResponseItem = serde_json::from_value(value.clone()).unwrap();
assert_eq!(
item,
ResponseItem::ConfigurationUpdate {
reasoning: ConfigurationReasoning {
effort: ReasoningEffort::Custom("model-specific".to_string()),
},
}
);
assert_eq!(serde_json::to_value(item).unwrap(), value);
}