fix(agents): warn on unrecognised model ID instead of silently falling back#38631
fix(agents): warn on unrecognised model ID instead of silently falling back#38631ademczuk wants to merge 3 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR adds warning logs in two places when a configured model ID cannot be found: at runtime when
Confidence Score: 4/5
Last reviewed commit: aeb6181 |
|
@steipete — small agents fix (4 files, size:S). When an unrecognised model ID is configured, the current code silently falls back to the default model. This adds a CI all green, greptile finding (missing mockRestore) already fixed in |
|
Fixed in Uses the existing |
da08ac8 to
1c9e452
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c9e4524b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
1c9e452 to
c9c8b1b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9c8b1bd71
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
c9c8b1b to
7c8c8fb
Compare
|
@steipete -- would appreciate your eyes on this when you get a chance. Context: Adds a warning log when an unrecognised model ID silently falls back to defaults (closes #37813). Size S, 4 files in CI note: The The "Changes at a glance" table in the description has the exact lines to review. |
7c8c8fb to
b3fa786
Compare
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🔵 Incomplete log sanitization allows terminal control / log injection via C1 control characters
Description
Because many terminals/log viewers treat C1 characters as control codes (e.g. U+009B CSI, U+009D OSC, U+0085 NEL), an attacker who can influence provider/model strings can still:
Vulnerable code: const sanitize = (v: string) => {
let out = stripAnsi(v);
for (let c = 0; c <= 0x1f; c++) {
out = out.replaceAll(String.fromCharCode(c), "");
}
return out.replaceAll(String.fromCharCode(0x7f), "");
};
log.warn(`Model "${sanitize(attempts[0].provider)}/${sanitize(attempts[0].model)}" ...`);This leaves C1 controls intact (e.g. RecommendationUse a dedicated sanitizer that removes both C0 and C1 control characters before logging, and consider making separators visible (escaping) instead of deleting. This repo already has a helper for this purpose: import { sanitizeTerminalText } from "../terminal/safe-text.js";
log.warn(
`Model "${sanitizeTerminalText(attempts[0].provider)}/${sanitizeTerminalText(attempts[0].model)}" not found. ` +
`Fell back to "${sanitizeTerminalText(candidate.provider)}/${sanitizeTerminalText(candidate.model)}".`,
);If you keep a local sanitizer, extend it to strip Analyzed PR: #38631 at commit Last updated on: 2026-03-07T21:12:23Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3fa786c4c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
CI Status Update (post-rebase)After rebasing onto latest Fixed in this PR (commit 4da48cb):
Pre-existing on
Our PR touches only 4 files in |
|
Closing this one. The merge conflicts and CI failures have stacked up, and the extensions test regressions on main make it hard to get a clean baseline here. The underlying idea (warning on unrecognised model IDs) still has merit - I'll revisit it as a smaller, more focused fix once the test landscape on main settles down. |
Summary
openai/gpt-5.4-pro), the agent silently falls back to the primary default model with no warning.src/agents/model-fallback.ts: Runtime fallback. WhenrunWithModelFallbacksucceeds on a later candidate after the user's primary model fails withmodel_not_found, a warning is logged.src/agents/model-selection.ts: Config-level. When a malformed model string (e.g."openai/") can't be parsed into a valid ModelRef, a warning is logged before falling back to defaults.Change Type
Scope
Linked Issue/PR
User-visible / Behavior Changes
Users will now see a warning log when their specified model ID is not found and the system falls back to the default model:
Model "openai/gpt-6" not found. Fell back to "openai/gpt-4.1-mini".Security Impact
Evidence
Human Verification
attempts[0]precision. Only warns when user's primary model (always candidate 0) hasmodel_not_found, not when a fallback model is unrecognised.runWithImageModelFallback(same pattern but doesn't extractreasonintoattempts, separate concern and out of scope).Compatibility / Migration
Failure Recovery
git revert <sha>model_not_foundreason gating prevents this).Risks and Mitigations
runWithImageModelFallback