mirror of
https://github.com/openai/codex.git
synced 2026-10-29 19:08:43 +00:00
Validate thread providers before resume and input (#57840)
## Why Existing chats retain their provider configuration when the selected provider changes. Reject resume and input until the configured provider matches the chat, while keeping history readable and allowing recovery after configuration is restored. ## What changed - Validate saved providers before applying resume overrides, preserving the provider when only model or reasoning settings change. - Check the current provider selection, including profiles and launch overrides, before accepting input. Reject input when configuration cannot be loaded. - Return structured `ModelProviderError` data for provider mismatches, missing definitions, and policy conflicts, with generated JSON Schema, TypeScript, and Python types. ## Testing Add coverage for override bypass prevention, provider restoration, readable history after rejection, and blocked requests sending no inference traffic. Verify schema fields and Python round trips match the error wire format. GitOrigin-RevId: 051f97c3815c547d8411c71b770df30eae969f68
This commit is contained in:
@@ -1558,10 +1558,23 @@ impl ConfigBuilder {
|
||||
|
||||
pub async fn build(self) -> std::io::Result<Config> {
|
||||
// Keep the large config-loading future off small runtime thread stacks.
|
||||
Box::pin(self.build_inner()).await
|
||||
// Avoid an additional async frame for ordinary config loads.
|
||||
Box::pin(self.build_inner(|_, _, _| Ok(()))).await
|
||||
}
|
||||
|
||||
async fn build_inner(self) -> std::io::Result<Config> {
|
||||
/// Validates the same loaded configuration that will be materialized, before provider
|
||||
/// selection or initialization. Validation cannot alter the loaded configuration.
|
||||
pub async fn build_with_validation(
|
||||
self,
|
||||
validate: impl FnOnce(&ConfigToml, &ConfigOverrides, &ConfigLayerStack) -> std::io::Result<()>,
|
||||
) -> std::io::Result<Config> {
|
||||
Box::pin(self.build_inner(validate)).await
|
||||
}
|
||||
|
||||
async fn build_inner(
|
||||
self,
|
||||
validate: impl FnOnce(&ConfigToml, &ConfigOverrides, &ConfigLayerStack) -> std::io::Result<()>,
|
||||
) -> std::io::Result<Config> {
|
||||
let Self {
|
||||
codex_home,
|
||||
cli_overrides,
|
||||
@@ -1602,6 +1615,7 @@ impl ConfigBuilder {
|
||||
)
|
||||
.await?;
|
||||
let config_toml = config_toml_from_layers(&config_layer_stack).await?;
|
||||
validate(&config_toml, &harness_overrides, &config_layer_stack)?;
|
||||
Config::load_config_with_layer_stack(
|
||||
LOCAL_FS.as_ref(),
|
||||
config_toml,
|
||||
|
||||
Reference in New Issue
Block a user