mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58:46 +00:00
## What changed - Add the built-in `amazon-bedrock-runtime` provider for regional `bedrock-runtime` OpenAI-compatible endpoints. - Use endpoint-specific SigV4 service configuration while preserving bearer token auth and per-provider AWS profile, region, and transport overrides. - Provide global and US cross-region GPT-5.6 model variants, prefer global routing for fallback and background tasks, and disable unsupported web search. ## Testing - Cover provider configuration and capabilities, endpoint and auth selection, runtime catalog ordering, model fallback, and web search omission. GitOrigin-RevId: d158ab74a5768e1b4c61063365a0c06735313322
95 lines
2.9 KiB
Rust
95 lines
2.9 KiB
Rust
use std::time::Duration;
|
|
|
|
use anyhow::Result;
|
|
use app_test_support::TestAppServer;
|
|
use codex_app_server_protocol::ModelProviderCapabilitiesReadParams;
|
|
use codex_app_server_protocol::ModelProviderCapabilitiesReadResponse;
|
|
use pretty_assertions::assert_eq;
|
|
use tempfile::TempDir;
|
|
use tokio::time::timeout;
|
|
|
|
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);
|
|
|
|
#[tokio::test]
|
|
async fn read_default_provider_capabilities() -> Result<()> {
|
|
let codex_home = TempDir::new()?;
|
|
let mut mcp = TestAppServer::builder()
|
|
.with_codex_home(codex_home.path())
|
|
.without_auto_env()
|
|
.build_initialized_with_timeout(DEFAULT_TIMEOUT)
|
|
.await?;
|
|
|
|
let request_id = mcp
|
|
.send_model_provider_capabilities_read_request(ModelProviderCapabilitiesReadParams {})
|
|
.await?;
|
|
let received: ModelProviderCapabilitiesReadResponse =
|
|
timeout(DEFAULT_TIMEOUT, mcp.read_response(request_id)).await??;
|
|
|
|
let expected = ModelProviderCapabilitiesReadResponse {
|
|
namespace_tools: true,
|
|
image_generation: true,
|
|
web_search: true,
|
|
};
|
|
assert_eq!(received, expected);
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn read_amazon_bedrock_provider_capabilities() -> Result<()> {
|
|
let codex_home = TempDir::new()?;
|
|
std::fs::write(
|
|
codex_home.path().join("config.toml"),
|
|
r#"model_provider = "amazon-bedrock"
|
|
"#,
|
|
)?;
|
|
let mut mcp = TestAppServer::builder()
|
|
.with_codex_home(codex_home.path())
|
|
.without_auto_env()
|
|
.build_initialized_with_timeout(DEFAULT_TIMEOUT)
|
|
.await?;
|
|
|
|
let request_id = mcp
|
|
.send_model_provider_capabilities_read_request(ModelProviderCapabilitiesReadParams {})
|
|
.await?;
|
|
let received: ModelProviderCapabilitiesReadResponse =
|
|
timeout(DEFAULT_TIMEOUT, mcp.read_response(request_id)).await??;
|
|
|
|
let expected = ModelProviderCapabilitiesReadResponse {
|
|
namespace_tools: true,
|
|
image_generation: false,
|
|
web_search: true,
|
|
};
|
|
assert_eq!(received, expected);
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn read_amazon_bedrock_runtime_provider_capabilities() -> Result<()> {
|
|
let codex_home = TempDir::new()?;
|
|
std::fs::write(
|
|
codex_home.path().join("config.toml"),
|
|
r#"model_provider = "amazon-bedrock-runtime"
|
|
"#,
|
|
)?;
|
|
let mut mcp = TestAppServer::builder()
|
|
.with_codex_home(codex_home.path())
|
|
.build_initialized_with_timeout(DEFAULT_TIMEOUT)
|
|
.await?;
|
|
|
|
let request_id = mcp
|
|
.send_model_provider_capabilities_read_request(ModelProviderCapabilitiesReadParams {})
|
|
.await?;
|
|
let received: ModelProviderCapabilitiesReadResponse =
|
|
timeout(DEFAULT_TIMEOUT, mcp.read_response(request_id)).await??;
|
|
|
|
assert_eq!(
|
|
received,
|
|
ModelProviderCapabilitiesReadResponse {
|
|
namespace_tools: true,
|
|
image_generation: false,
|
|
web_search: false,
|
|
}
|
|
);
|
|
Ok(())
|
|
}
|