mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
[codex] Dedupe fallback model metadata warnings (#21090)
Fixes #21070. This is a small cleanup around model metadata handling for gateway/provider model names. It follows the report and proposed direction from @dkbush by keeping the fallback metadata warning useful without repeating it every turn, and by tightening the existing provider-prefix lookup path. - Track fallback metadata warning slugs in session state so each unresolved model warns once per session. - Keep warning emission outside the session-state lock and preserve the existing warning text. - Allow one-segment provider prefixes with hyphenated provider IDs, while preserving the multi-segment rejection behavior. - Add focused coverage for warning dedupe and hyphenated provider-prefix metadata matching. Testing: - Ran `just fmt`. - Ran `git diff --check`. - Added tests for the new warning dedupe and provider-prefix lookup behavior.
This commit is contained in:
1 parent
63a27ad6c6
commit
d5f0b6d63a
6 files changed
+82
-6
No files matched your search
@@ -0,0 +1,23 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
const FALLBACK_MODEL_METADATA_WARNING_PREFIX: &str = "Model metadata for `";
|
||||
const FALLBACK_MODEL_METADATA_WARNING_SUFFIX: &str =
|
||||
"` not found. Defaulting to fallback metadata; this can degrade performance and cause issues.";
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct WarningDisplayState {
|
||||
fallback_model_metadata_slugs: HashSet<String>,
|
||||
}
|
||||
|
||||
impl WarningDisplayState {
|
||||
pub(super) fn should_display(&mut self, message: &str) -> bool {
|
||||
fallback_model_metadata_warning_slug(message)
|
||||
.is_none_or(|slug| self.fallback_model_metadata_slugs.insert(slug.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
fn fallback_model_metadata_warning_slug(message: &str) -> Option<&str> {
|
||||
message
|
||||
.strip_prefix(FALLBACK_MODEL_METADATA_WARNING_PREFIX)?
|
||||
.strip_suffix(FALLBACK_MODEL_METADATA_WARNING_SUFFIX)
|
||||
}
|
||||
Reference in new issue
Block a user