mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
feat: route guardian review model selection through providers (#22258)
## Why Guardian review selection was hard-coded in `core`, which worked for the default OpenAI path but did not give provider implementations a way to choose backend-specific reviewer model IDs. That matters for Amazon Bedrock: guardian review should run through the Bedrock/Mantle provider using Bedrock's `openai.gpt-5.4` model ID, instead of accidentally selecting a reviewer model that implies the OpenAI backend. ## What Changed - Added provider-owned approval review model selection via `ModelProvider::approval_review_model_selection`. - Moved the existing default selection policy into the provider abstraction: prefer the requested reviewer model when it is available, otherwise fall back to the active turn model, preferring `Low` reasoning when supported. - Added an Amazon Bedrock override that pins guardian review to `openai.gpt-5.4` with `Low` reasoning.
This commit is contained in:
1 parent
51bfb5f3b1
commit
e2eb7c30fe
7 files changed
+82
-10
No files matched your search
@@ -70,6 +70,10 @@ impl std::error::Error for ProviderAccountError {}
|
||||
|
||||
pub type ProviderAccountResult = std::result::Result<ProviderAccountState, ProviderAccountError>;
|
||||
|
||||
/// Default model used for automatic approval review when a provider does not
|
||||
/// require a backend-specific model ID.
|
||||
pub const DEFAULT_APPROVAL_REVIEW_PREFERRED_MODEL: &str = "codex-auto-review";
|
||||
|
||||
/// Runtime provider abstraction used by model execution.
|
||||
///
|
||||
/// Implementations own provider-specific behavior for a model backend. The
|
||||
@@ -85,6 +89,13 @@ pub trait ModelProvider: fmt::Debug + Send + Sync {
|
||||
ProviderCapabilities::default()
|
||||
}
|
||||
|
||||
/// Returns the preferred model used for automatic approval review.
|
||||
///
|
||||
/// Providers that require backend-specific model IDs should override this.
|
||||
fn approval_review_preferred_model(&self) -> &'static str {
|
||||
DEFAULT_APPROVAL_REVIEW_PREFERRED_MODEL
|
||||
}
|
||||
|
||||
/// Returns whether requests made through this provider should include attestation.
|
||||
fn supports_attestation(&self) -> bool {
|
||||
false
|
||||
@@ -350,6 +361,19 @@ mod tests {
|
||||
assert_eq!(provider.capabilities(), ProviderCapabilities::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_provider_uses_default_approval_review_preferred_model() {
|
||||
let provider = create_model_provider(
|
||||
ModelProviderInfo::create_openai_provider(/*base_url*/ None),
|
||||
/*auth_manager*/ None,
|
||||
);
|
||||
|
||||
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