Skip to content

🤖 feat: add per-model provider modelParameters overrides#2743

Merged
ethanndickson merged 1 commit into
mainfrom
model-params-bkse
Mar 4, 2026
Merged

🤖 feat: add per-model provider modelParameters overrides#2743
ethanndickson merged 1 commit into
mainfrom
model-params-bkse

Conversation

@ethanndickson

Copy link
Copy Markdown
Member

Summary

Add config-driven per-model parameter overrides from ~/.mux/providers.jsonc and thread them through the chat streaming path so standard call settings (for example max_output_tokens, temperature, and top_p) are applied at request time, while provider-specific extra keys are safely merged into provider options.

Closes #2574

Background

Users need a way to tune model request parameters without code changes or UI additions. This adds a providers-config surface that supports exact model entries plus wildcard fallbacks and keeps runtime behavior defensive for hand-edited config.

Implementation

  • Added shared schemas and types for modelParameters in provider config, including a single snake_case→AI SDK call-settings mapping source of truth.
  • Added resolveModelParameterOverrides(...) with precedence:
    1. effective model id
    2. canonical model id
    3. "*" wildcard
  • Split resolved values into:
    • standard call settings (mapped to SDK keys)
    • providerExtras (unknown keys)
  • Integrated override resolution in AIService.streamMessage() and:
    • deep-merged providerExtras under the provider namespace
    • preserved Mux-built provider options as conflict winners
    • passed resolved standard settings through startStream(..., callSettingsOverrides)
  • Threaded call settings through StreamManager request construction and into streamText(...), with explicit precedence for maxOutputTokens:
    1. explicit per-request value
    2. config override
    3. model stats fallback
  • Added debug logs for resolved overrides under MUX_DEBUG_LLM_REQUEST=1.

Validation

  • make static-check
  • bun test src/common/config/schemas/providersConfig.test.ts src/common/utils/ai/modelParameterOverrides.test.ts src/node/services/streamManager.test.ts src/node/services/aiService.test.ts

Risks

  • Medium/contained: the change touches the main chat stream assembly path and provider option composition.
  • Mitigations:
    • provider extras are namespace-scoped and merged under existing Mux options
    • standard keys are type-constrained and defensively validated at resolution time
    • precedence behavior is covered by focused unit tests

Generated with mux • Model: openai:gpt-5.3-codex • Thinking: xhigh • Cost: $13.96

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe31b1f296

ℹ️ 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".

Comment thread src/common/utils/ai/modelParameterOverrides.ts Outdated
Comment thread src/common/utils/ai/modelParameterOverrides.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5681743456

ℹ️ 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".

Comment thread src/common/utils/ai/modelParameterOverrides.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d503eae9b

ℹ️ 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".

Comment thread src/common/utils/ai/modelParameterOverrides.ts
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ 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".

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90d9d93a8e

ℹ️ 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".

Comment thread src/node/services/aiService.ts Outdated
Add modelParameters support to providers.jsonc, allowing users to
override max_output_tokens, temperature, top_p, and other settings
per model or via wildcard (*) fallback.

- Schema module with standard parameter shape and compile-time mapping
- Resolver with effective → canonical → wildcard precedence
- StreamManager threading for call settings overrides
- AIService integration with provider extras deep-merge
- Colon-safe model ID parsing via getModelName()
- Schema-backed runtime validation (invalid values silently dropped)
- Prototype-safe standard-key detection via Object.hasOwn()
- Plain-object guard for malformed config entries

Closes #2574
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review
Please take another look.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ 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".

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ 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".

@ethanndickson ethanndickson added this pull request to the merge queue Mar 4, 2026
Merged via the queue into main with commit 125478c Mar 4, 2026
23 checks passed
@ethanndickson ethanndickson deleted the model-params-bkse branch March 4, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow users to define custom API parameters per model (e.g. max_output_tokens)

1 participant