mirror of
https://github.com/openai/codex.git
synced 2026-05-04 03:16:31 +00:00
follow up of #19442. The app server now exposes provider-derived bounds through a new v2 `modelProvider/read` method. The response reports the configured provider map key as `modelProvider` and returns the effective capability booleans so clients can align their UI with the same provider-owned limits used by core.
70 lines
2.2 KiB
Rust
70 lines
2.2 KiB
Rust
use std::time::Duration;
|
|
|
|
use anyhow::Result;
|
|
use app_test_support::McpProcess;
|
|
use app_test_support::to_response;
|
|
use codex_app_server_protocol::JSONRPCResponse;
|
|
use codex_app_server_protocol::ModelProviderCapabilitiesReadParams;
|
|
use codex_app_server_protocol::ModelProviderCapabilitiesReadResponse;
|
|
use codex_app_server_protocol::RequestId;
|
|
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 = McpProcess::new(codex_home.path()).await?;
|
|
timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??;
|
|
|
|
let request_id = mcp
|
|
.send_model_provider_capabilities_read_request(ModelProviderCapabilitiesReadParams {})
|
|
.await?;
|
|
let response: JSONRPCResponse = timeout(
|
|
DEFAULT_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(request_id)),
|
|
)
|
|
.await??;
|
|
let received: ModelProviderCapabilitiesReadResponse = to_response(response)?;
|
|
|
|
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 = McpProcess::new(codex_home.path()).await?;
|
|
timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??;
|
|
|
|
let request_id = mcp
|
|
.send_model_provider_capabilities_read_request(ModelProviderCapabilitiesReadParams {})
|
|
.await?;
|
|
let response: JSONRPCResponse = timeout(
|
|
DEFAULT_TIMEOUT,
|
|
mcp.read_stream_until_response_message(RequestId::Integer(request_id)),
|
|
)
|
|
.await??;
|
|
let received: ModelProviderCapabilitiesReadResponse = to_response(response)?;
|
|
|
|
let expected = ModelProviderCapabilitiesReadResponse {
|
|
namespace_tools: false,
|
|
image_generation: false,
|
|
web_search: false,
|
|
};
|
|
assert_eq!(received, expected);
|
|
Ok(())
|
|
}
|