fix(param-support): handle strip rules without match/drop

Cloudflare AI rule only sets flattenContent. Treat missing match as
provider-wide and missing drop as empty list to avoid crash. Fixes #1960.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Joseph Yaksich
2026-06-26 17:18:39 +07:00
committed by decolua
parent 639f1204d0
commit 4a54824f7f
2 changed files with 33 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ const STRIP_RULES = [
// Test a rule's match (regex or predicate) against the model id.
function matches(rule, model) {
if (!rule.match) return true;
return typeof rule.match === "function" ? rule.match(model) : rule.match.test(model);
}
@@ -25,7 +26,7 @@ export function stripUnsupportedParams(provider, model, body) {
for (const rule of STRIP_RULES) {
if (rule.provider && rule.provider !== provider) continue;
if (!matches(rule, model)) continue;
for (const key of rule.drop) {
for (const key of rule.drop || []) {
if (body[key] !== undefined) delete body[key];
}
// CF Workers AI oneOf root schema only accepts content as plain string (#1926)