Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5712364
fix(electron): bump electron 42→43 + build better-sqlite3 from source…
diegosouzapw Jul 8, 2026
44d501a
deps: bump the development group across 1 directory with 6 updates (#…
dependabot[bot] Jul 8, 2026
9cd18bf
fix(proxy): force CONNECT tunnel for HTTP proxied requests (undici 8.…
diegosouzapw Jul 8, 2026
4bc8cde
feat(db): add provider param filter config store (key_value namespace)
ThongAccount Jul 8, 2026
8c66807
feat(proxy): add detectUnsupportedParam regex for auto-learning
ThongAccount Jul 8, 2026
e135594
feat(proxy): extend stripUnsupportedParams with config-driven denylis…
ThongAccount Jul 8, 2026
bca5485
feat(proxy): wire auto-learn of unsupported params into 400-downgrade…
ThongAccount Jul 8, 2026
f5ba160
test: add tests for provider param filter denylist/allowlist/auto-learn
ThongAccount Jul 8, 2026
da4ca30
feat(proxy): add global auto-learn flag for unsupported params
ThongAccount Jul 8, 2026
0f319ac
fix: apply PR#6649 review feedback — model-scoped auto-learn and prec…
ThongAccount Jul 8, 2026
00ac985
feat(ui): add provider-level param filter section to detail page
ThongAccount Jul 8, 2026
3f42b1f
feat(ui): add model-level param filter fields in compat popover
ThongAccount Jul 8, 2026
f19e2ff
chore: gitignore .claude-flow/
ThongAccount Jul 8, 2026
d776002
Merge remote-tracking branch 'origin/release/v3.8.47' into feat/6625-…
diegosouzapw Jul 8, 2026
aa1c9e3
fix(param-filters): review follow-ups — auth gate, error sanitization…
ThongAccount Jul 8, 2026
1324dc5
chore(param-filters): drop unrelated main-drift from the fork branch …
diegosouzapw Jul 8, 2026
e01ed7f
refactor(param-filters): split oversized functions — keep complexity …
ThongAccount Jul 8, 2026
964ac81
refactor(param-filters): decompose config parser helpers — keep cogni…
ThongAccount Jul 8, 2026
2a97832
Merge remote-tracking branch 'origin/release/v3.8.47' into feat/6625-…
diegosouzapw Jul 8, 2026
7f9aa3c
fix(changelog): restore sibling #6648 bullet eaten by merge auto-reso…
ThongAccount Jul 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"electron-updater": "^6.8.9"
},
"devDependencies": {
"electron": "^42.5.1",
"electron": "^43.1.0",
"electron-builder": "^26.15.3"
},
"overrides": {
Expand All @@ -42,6 +42,7 @@
"appId": "online.omniroute.desktop",
"productName": "OmniRoute",
"copyright": "Copyright © 2025 OmniRoute",
"buildDependenciesFromSource": true,
"directories": {
"output": "dist-electron",
"buildResources": "assets"
Expand Down
20 changes: 20 additions & 0 deletions open-sse/config/providerFieldStrips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ export function findOffendingField(bodyText: string): string | null {
return null;
}

/**
* Regex to extract an unsupported parameter name from upstream 400 error text.
* Matches:
* - "Unsupported parameter(s): thinking"
* - "Unsupported parameter: max_tokens"
* - "Unsupported parameter 'reasoning_budget'"
*/
export const UNSUPPORTED_PARAM_RE =
/unsupported\s+parameter\w*(?:\s*\(s\))?[:\s]+["'`]?(\w+)["'`]?/i;

/**
* Extract a single unsupported parameter name from a 400 error body,
* or null if the error does not match the known pattern.
*/
export function detectUnsupportedParam(bodyText: string): string | null {
if (typeof bodyText !== "string" || !bodyText) return null;
const match = UNSUPPORTED_PARAM_RE.exec(bodyText);
return match?.[1] ?? null;
}

/** Immutably drop request fields Groq rejects with a 400. */
export function stripGroqUnsupportedFields<T extends Record<string, unknown>>(body: T): T {
if (!body || typeof body !== "object") return body;
Expand Down
44 changes: 43 additions & 1 deletion open-sse/executors/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ import {
normalizeAnthropicHeaderVariants,
} from "../config/anthropicHeaders.ts";
import { applyContextEditingToBody } from "../config/contextEditing.ts";
import { findOffendingField, stripGroqUnsupportedFields } from "../config/providerFieldStrips.ts";
import {
findOffendingField,
detectUnsupportedParam,
stripGroqUnsupportedFields,
} from "../config/providerFieldStrips.ts";
import {
getParamFilterConfig,
addParamToBlocklist,
isAutoLearnGloballyEnabled,
} from "@/lib/db/paramFilters";
import { applyFingerprint, isCliCompatEnabled } from "../config/cliFingerprints.ts";
import { supportsClaudeMaxEffort, supportsXHighEffort } from "../config/providerModels.ts";
import { getThinkingBudgetConfig, ThinkingMode } from "../services/thinkingBudget.ts";
Expand Down Expand Up @@ -1261,6 +1270,39 @@ export class BaseExecutor {
`Upstream 400 rejected ${offending} on ${url} — retrying without it`
);
response = await fetchWithStartTimeout(url, { ...fetchOptions, body: retryBody });
} else {
// Auto-learn: detect "Unsupported parameter" errors and persist to DB
// when the provider config has autoLearn enabled (#6625).
const autoLearned = detectUnsupportedParam(errText);
if (
autoLearned &&
!strippedFields.has(autoLearned) &&
(transformedBody as Record<string, unknown>)[autoLearned] !== undefined
) {
try {
const config = getParamFilterConfig(this.provider);
const shouldAutoLearn = isAutoLearnGloballyEnabled() || config?.autoLearn === true;
if (shouldAutoLearn) {
strippedFields.add(autoLearned);
addParamToBlocklist(this.provider, autoLearned);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

When auto-learning an unsupported parameter, it is currently added to the provider-level blocklist globally.

For multi-model providers (such as NVIDIA NIM, Groq, or OpenRouter), different models have completely different parameter support. Auto-learning a parameter at the provider level because one model rejected it will incorrectly strip that parameter from other models under the same provider that actually support it.

Since addParamToBlocklist supports a model parameter, and model is available in the execution context, we should scope the auto-learned parameter to the specific model.

Suggested change
addParamToBlocklist(this.provider, autoLearned);
addParamToBlocklist(this.provider, autoLearned, model);

@ThongAccount ThongAccount Jul 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0f319ac. Changed addParamToBlocklist(this.provider, autoLearned) to addParamToBlocklist(this.provider, autoLearned, model) so auto-learn scopes to the specific model that triggered the 400, preventing provider-level pollution.

delete (transformedBody as Record<string, unknown>)[autoLearned];
let retryBody = JSON.stringify(transformedBody);
if (isClaudeCodeCompatible(this.provider) || this.provider === "claude") {
retryBody = await signRequestBody(retryBody);
}
log?.info?.(
"AUTO_LEARN",
`Auto-learned "${autoLearned}" for provider ${this.provider} from 400 on ${url} — retrying`
);
Comment on lines +1293 to +1296

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Update the log message to include the model name so that operators can easily see which specific model triggered the auto-learning behavior.

Suggested change
log?.info?.(
"AUTO_LEARN",
`Auto-learned "${autoLearned}" for provider ${this.provider} from 400 on ${url} — retrying`
);
log?.info?.(
"AUTO_LEARN",
`Auto-learned "${autoLearned}" for provider ${this.provider} (model: ${model}) from 400 on ${url} — retrying`
);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0f319ac. Log message now includes model: Auto-learned "X" for provider Y (model: Z) …

response = await fetchWithStartTimeout(url, { ...fetchOptions, body: retryBody });
}
} catch (learnError) {
log?.warn?.(
"AUTO_LEARN",
`Failed to persist auto-learned param "${autoLearned}" for ${this.provider}: ${String(learnError)}`
);
}
}
}
}

Expand Down
64 changes: 64 additions & 0 deletions open-sse/translator/paramSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// introduces new keys and never throws on null/undefined bodies — call sites
// can chain it without extra guards.

import { getParamFilterConfig } from "@/lib/db/paramFilters";

type StripRule = {
provider?: string;
match: RegExp | ((model: string) => boolean);
Expand Down Expand Up @@ -56,15 +58,77 @@ export function stripUnsupportedParams<T>(
): T {
if (!model || !body || typeof body !== "object") return body;
const rec = body as unknown as Record<string, unknown>;
// Snapshot the original body before any mutations so the allowlist can
// restore params that were stripped by hardcoded or config-driven denylist.
const snapshot = { ...rec };

// Phase 1: Hardcoded rules (unchanged)
for (const rule of STRIP_RULES) {
if (rule.provider && rule.provider !== provider) continue;
if (!matches(rule, model)) continue;
for (const key of rule.drop) {
if (rec[key] !== undefined) delete rec[key];
}
}

// Phase 2: Config-driven rules from DB
applyConfigFilters(provider, model, rec, snapshot);

return body;
}

/**
* Apply config-driven denylist + allowlist rules from the DB-backed
* ProviderParamFilter store. Order of operations:
* 1. Provider-level denylist
* 2. Model-level denylist
* 3. Provider-level allowlist (restores from snapshot)
* 4. Model-level allowlist (restores from snapshot)
*
* The allowlist only restores keys that were present in the original request
* (the snapshot). It never introduces new params the client didn't send.
*/
export function applyConfigFilters(
provider: string | null | undefined,
model: string | null | undefined,
body: Record<string, unknown>,
snapshot: Record<string, unknown>
): void {
if (!provider || !body) return;
const config = getParamFilterConfig(provider);
if (!config) return;

// 1. Provider-level denylist
for (const key of config.block) {
delete body[key];
}

// 2. Model-level denylist
const modelCfg = config.models?.[model ?? ""];
if (modelCfg?.block) {
for (const key of modelCfg.block) {
delete body[key];
}
}

// 3. Provider-level allowlist — restore from snapshot if key existed in original
if (config.allow.length > 0) {
for (const key of config.allow) {
if (key in snapshot) {
body[key] = snapshot[key];
}
}
}

// 4. Model-level allowlist
if (modelCfg?.allow) {
for (const key of modelCfg.allow) {
if (key in snapshot) {
body[key] = snapshot[key];
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current order of operations applies all denylists first, followed by all allowlists:

  1. Provider-level denylist
  2. Model-level denylist
  3. Provider-level allowlist
  4. Model-level allowlist

This creates a bug where a provider-level allowlist (step 3) will restore a parameter that was explicitly blocked by a more specific model-level denylist (step 2). Model-level configurations are more specific and should always take precedence over provider-level configurations.

The correct hierarchical order of operations should be:

  1. Provider-level denylist
  2. Provider-level allowlist
  3. Model-level denylist
  4. Model-level allowlist

This ensures that model-level denylists can successfully override provider-level allowlists.

  // 1. Provider-level denylist
  for (const key of config.block) {
    delete body[key];
  }

  // 2. Provider-level allowlist — restore from snapshot if key existed in original
  if (config.allow.length > 0) {
    for (const key of config.allow) {
      if (key in snapshot) {
        body[key] = snapshot[key];
      }
    }
  }

  // 3. Model-level denylist
  const modelCfg = config.models?.[model ?? ""];
  if (modelCfg?.block) {
    for (const key of modelCfg.block) {
      delete body[key];
    }
  }

  // 4. Model-level allowlist
  if (modelCfg?.allow) {
    for (const key of modelCfg.allow) {
      if (key in snapshot) {
        body[key] = snapshot[key];
      }
    }
  }

@ThongAccount ThongAccount Jul 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0f319ac. Reordered applyConfigFilters so model-level operations run AFTER provider-level operations:

  1. Provider denylist
  2. Provider allowlist
  3. Model denylist (overrides provider allowlist)
  4. Model allowlist (most specific wins)

Added regression test verifying model denylist beats provider allowlist.

}

// Exported for unit tests only — do not import from production code.
export const __STRIP_RULES_FOR_TEST: ReadonlyArray<StripRule> = STRIP_RULES;
6 changes: 6 additions & 0 deletions open-sse/utils/proxyDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,12 @@ export function createProxyDispatcher(proxyUrl: string): Dispatcher {
// valid; the cast suppresses the spurious missing-`port` error.
dispatcher = new ProxyAgent({
uri: cleanUri,
// undici 8.6+ forwards plain-HTTP requests through the proxy as an origin
// request (GET http://host/…) instead of a CONNECT tunnel; upstream proxies
// that only speak CONNECT then reject it (501). OmniRoute tunnels ALL proxied
// traffic (HTTP + HTTPS) via CONNECT, so force tunneling. Unknown option on
// undici <8.6 → silently ignored (that version already tunneled by default).
proxyTunnel: true,
...proxyDispatcherOptions,
...(family !== null
? { proxyTls: { family, autoSelectFamily: false } as ProxyAgent.Options["proxyTls"] }
Expand Down
Loading