mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Use Luna for API-key Guardian reviews (#37103)
## What changed - Select `gpt-5.6-luna` for Guardian approval reviews authenticated with an API key, while retaining `codex-auto-review` for ChatGPT authentication. - Exercise API-key reviews through Responses Lite and fall back to the bundled Guardian policy when the selected model has no catalog-provided review policy. - Refine the bundled policy's handling of trusted authorization, sensitive-data egress, credential probing, destructive command targets, and post-denial approval. ## Testing - Cover provider model selection for API-key and ChatGPT authentication. - Verify Guardian prewarming and review reuse with both Responses Lite and standard Responses requests. GitOrigin-RevId: e35c43e1692fd643ab8faad1444c0d6a869b3e0c
This commit is contained in:
1 parent
952e87d3f2
commit
c4f42d161a
5 files changed
+198
-58
No files matched your search
@@ -102,6 +102,8 @@ pub type ProviderAccountResult = std::result::Result<ProviderAccountState, Provi
|
||||
/// require a backend-specific model ID.
|
||||
pub const DEFAULT_APPROVAL_REVIEW_PREFERRED_MODEL: &str = "codex-auto-review";
|
||||
|
||||
const API_KEY_APPROVAL_REVIEW_PREFERRED_MODEL: &str = "gpt-5.6-luna";
|
||||
|
||||
/// Default model used for memory extraction when a provider does not require a
|
||||
/// backend-specific model ID.
|
||||
pub const DEFAULT_MEMORY_EXTRACTION_PREFERRED_MODEL: &str = "gpt-5.6-luna";
|
||||
@@ -309,6 +311,19 @@ impl ModelProvider for ConfiguredModelProvider {
|
||||
}
|
||||
}
|
||||
|
||||
fn approval_review_preferred_model(&self) -> &'static str {
|
||||
if self
|
||||
.auth_manager
|
||||
.as_ref()
|
||||
.and_then(|auth_manager| auth_manager.auth_cached())
|
||||
.is_some_and(|auth| auth.is_api_key_auth())
|
||||
{
|
||||
API_KEY_APPROVAL_REVIEW_PREFERRED_MODEL
|
||||
} else {
|
||||
DEFAULT_APPROVAL_REVIEW_PREFERRED_MODEL
|
||||
}
|
||||
}
|
||||
|
||||
fn auth_manager(&self) -> Option<Arc<AuthManager>> {
|
||||
self.auth_manager.clone()
|
||||
}
|
||||
@@ -625,6 +640,33 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_provider_uses_luna_for_approval_review_with_api_key_auth() {
|
||||
let provider = create_model_provider(
|
||||
ModelProviderInfo::create_openai_provider(/*base_url*/ None),
|
||||
Some(AuthManager::from_auth_for_testing(CodexAuth::from_api_key(
|
||||
"openai-api-key",
|
||||
))),
|
||||
);
|
||||
|
||||
assert_eq!(provider.approval_review_preferred_model(), "gpt-5.6-luna");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_provider_uses_default_approval_review_model_with_chatgpt_auth() {
|
||||
let provider = create_model_provider(
|
||||
ModelProviderInfo::create_openai_provider(/*base_url*/ None),
|
||||
Some(AuthManager::from_auth_for_testing(
|
||||
CodexAuth::create_dummy_chatgpt_auth_for_testing(),
|
||||
)),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
provider.approval_review_preferred_model(),
|
||||
DEFAULT_APPROVAL_REVIEW_PREFERRED_MODEL
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn configured_provider_runtime_base_url_uses_configured_base_url() {
|
||||
let provider = create_model_provider(
|
||||
|
||||
Reference in new issue
Block a user