feat(codex): align Search and execution protocol

This commit is contained in:
MMEXA
2026-07-12 03:04:15 +08:00
parent 59d37ae1dd
commit 2316df5c9a
121 changed files with 5141 additions and 543 deletions
+13 -1
View File
@@ -56,7 +56,7 @@ pub fn api_format_matches_allowed_value(allowed_value: &str, api_format: &str) -
if allowed_value.is_empty() || api_format.is_empty() {
return false;
}
crate::normalize_api_format(allowed_value) == crate::normalize_api_format(api_format)
aether_ai_formats::api_format_permission_covers(allowed_value, api_format)
}
pub fn auth_constraints_allow_model(
@@ -248,6 +248,18 @@ mod tests {
"openai:responses",
"openai:responses"
));
assert!(api_format_matches_allowed_value(
"openai:responses",
"openai:search"
));
assert!(api_format_matches_allowed_value(
"openai:search",
"openai:search"
));
assert!(!api_format_matches_allowed_value(
"openai:search",
"openai:responses"
));
assert!(!api_format_matches_allowed_value(
"openai:responses",
"claude:messages"
+40 -1
View File
@@ -279,7 +279,7 @@ fn mapping_scope_matches(
let api_format_matches_scope = mapping.api_formats.as_ref().is_none_or(|api_formats| {
api_formats
.iter()
.any(|value| api_format_matches(value, api_format))
.any(|value| api_format_scope_covers(value, api_format))
});
if !api_format_matches_scope {
return false;
@@ -419,6 +419,10 @@ fn api_format_matches(left: &str, right: &str) -> bool {
normalize_api_format(left) == normalize_api_format(right)
}
fn api_format_scope_covers(allowed: &str, requested: &str) -> bool {
aether_ai_formats::api_format_permission_covers(allowed, requested)
}
fn requested_model_name_candidates(
requested_model_name: &str,
enable_model_directives: bool,
@@ -568,6 +572,41 @@ mod tests {
);
}
#[test]
fn responses_model_mapping_scope_covers_search_in_one_direction() {
let mut row = sample_row("search-global", "search-default");
row.endpoint_api_format = "openai:search".to_string();
row.model_provider_model_mappings = Some(vec![StoredProviderModelMapping {
name: "gpt-5.6-sol".to_string(),
priority: 1,
api_formats: Some(vec!["openai:responses".to_string()]),
endpoint_ids: None,
}]);
assert!(row_supports_requested_model(
&row,
"gpt-5.6-sol",
"openai:search"
));
assert_eq!(
resolve_provider_model_name(&row, "gpt-5.6-sol", "openai:search")
.map(|resolved| resolved.0),
Some("gpt-5.6-sol".to_string())
);
row.model_provider_model_mappings = Some(vec![StoredProviderModelMapping {
name: "search-only".to_string(),
priority: 1,
api_formats: Some(vec!["openai:search".to_string()]),
endpoint_ids: None,
}]);
assert!(!row_supports_requested_model(
&row,
"search-only",
"openai:responses"
));
}
#[test]
fn model_directive_suffix_prefers_exact_model_before_base_fallback() {
let exact = sample_row("gpt-5.4-high", "gpt-5.4-high-upstream");