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:
@@ -119,3 +119,26 @@ def test_schema_generation_failure_does_not_update_python(monkeypatch):
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
runpy.run_path(str(script), run_name="__main__")
|
||||
assert calls == ["cargo"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"payload",
|
||||
[
|
||||
{"type": "modelProviderNotConfigured", "modelProvider": "old-provider"},
|
||||
{
|
||||
"type": "modelProviderMismatch",
|
||||
"modelProvider": "old-provider",
|
||||
"currentModelProvider": "current-provider",
|
||||
},
|
||||
{
|
||||
"type": "modelProviderPolicyConflict",
|
||||
"modelProvider": "old-provider",
|
||||
"requiredModelProvider": "required-provider",
|
||||
},
|
||||
],
|
||||
)
|
||||
def test_model_provider_errors_round_trip_wire_names(payload):
|
||||
from openai_codex.generated.v2_all import ModelProviderError
|
||||
|
||||
error = ModelProviderError.model_validate(payload)
|
||||
assert error.model_dump(by_alias=True) == payload
|
||||
|
||||
Reference in New Issue
Block a user