mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
## What changed - Support `model_provider = "gcp"` with a Vertex AI endpoint derived from `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION`, defaulting to the `global` location. - Obtain credentials through `gcloud auth application-default print-access-token` by default, and allow `base_url`, `auth`, and `http_headers` overrides under `model_providers.gcp`. - Use a static model catalog tailored to Vertex AI, preserve function tools, namespaces, and client-side tool search, and support remote compaction V2. Disable unsupported reasoning summaries, Responses Lite, custom tools, web search, and image generation. - Expose a `gcp` account type through the app-server protocol and generated clients without resolving credentials during account reads or requiring OpenAI authentication. ## Testing Add coverage for endpoint resolution, configuration overrides, model catalog filtering, authenticated requests, unsupported request fields, missing credentials, account reporting across provider changes, and automatic remote compaction. GitOrigin-RevId: 97a3158269e6dbc2605e2cf576998e09817ea12a
61 lines
2.0 KiB
Rust
61 lines
2.0 KiB
Rust
//! Provider capability defaults and resolution of custom provider overrides.
|
|
|
|
use codex_api::is_azure_responses_provider;
|
|
use codex_model_provider_info::ModelProviderInfo;
|
|
use codex_model_provider_info::RemoteCompactionSupport;
|
|
|
|
/// Optional provider-backed features that Codex may expose at runtime.
|
|
///
|
|
/// These capabilities are a provider-owned upper bound. Model and turn settings
|
|
/// can further restrict the functionality exposed to the model.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub struct ProviderCapabilities {
|
|
/// Whether requests may include the Responses API `reasoning.summary` parameter.
|
|
pub reasoning_summaries: bool,
|
|
pub image_generation: bool,
|
|
pub web_search: bool,
|
|
pub external_web_access: bool,
|
|
pub remote_compaction: RemoteCompactionSupport,
|
|
}
|
|
|
|
impl Default for ProviderCapabilities {
|
|
fn default() -> Self {
|
|
Self {
|
|
reasoning_summaries: true,
|
|
image_generation: true,
|
|
web_search: true,
|
|
external_web_access: true,
|
|
remote_compaction: RemoteCompactionSupport::Unsupported,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ProviderCapabilities {
|
|
pub(crate) fn from_config(info: &ModelProviderInfo) -> Self {
|
|
let defaults = Self {
|
|
remote_compaction: if info.is_openai()
|
|
|| is_azure_responses_provider(&info.name, info.base_url.as_deref())
|
|
{
|
|
RemoteCompactionSupport::V2
|
|
} else {
|
|
RemoteCompactionSupport::Unsupported
|
|
},
|
|
..Self::default()
|
|
};
|
|
let overrides = info.capabilities.unwrap_or_default();
|
|
Self {
|
|
external_web_access: overrides
|
|
.external_web_access
|
|
.unwrap_or(defaults.external_web_access),
|
|
remote_compaction: overrides
|
|
.remote_compaction
|
|
.unwrap_or(defaults.remote_compaction),
|
|
..defaults
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "capabilities_tests.rs"]
|
|
mod tests;
|