Skip to content

fix: ChatOpenAI baseOptions additional parameters not applied to model#6174

Closed
BOOPATB wants to merge 2 commits intoFlowiseAI:mainfrom
BOOPATB:feat/stop-sequences-openai
Closed

fix: ChatOpenAI baseOptions additional parameters not applied to model#6174
BOOPATB wants to merge 2 commits intoFlowiseAI:mainfrom
BOOPATB:feat/stop-sequences-openai

Conversation

@BOOPATB
Copy link
Copy Markdown

@BOOPATB BOOPATB commented Apr 8, 2026

Problem

Fixes #2499

BaseOptions JSON input in the ChatOpenAI node was only being passed as
defaultHeaders inside configuration, meaning any model-level parameters
(e.g. stop, top_p) were silently ignored and never sent to the API.

Root Cause

In ChatOpenAI.ts, parsedBaseOptions was unconditionally assigned to
configuration.defaultHeaders, with no path to merge params into the model object.
Additionally, the merge happened after the reasoning model cleanup block, meaning
it could have re-introduced stop/temperature that were intentionally deleted.

Fix

  • Destructure parsedBaseOptions into { defaultHeaders, baseURL, ...modelParams }
  • Spread modelParams directly into obj so params like stop reach the model
  • Move the baseOptions merge to before the reasoning model block so cleanup still works correctly
  • Update the BaseOptions field description to reflect its actual capability

Testing

  • Set { "stop": ["<|im_end|>"] } in BaseOptions on a ChatOpenAI node
  • Confirm the stop sequence is respected in the model response
  • Confirm reasoning models (o-series) still correctly strip stop/temperature
  • Confirm defaultHeaders and baseURL inside BaseOptions still work for custom endpoints

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the ChatOpenAI component to allow more flexible model parameter configuration via the baseOptions field and reorders the initialization logic to ensure reasoning model constraints are applied correctly. I have identified a security risk regarding mass assignment from user-provided JSON and a concern regarding inconsistent indentation introduced in the refactor.

Comment on lines +279 to +281
const { defaultHeaders, baseURL, ...modelParams } = parsedBaseOptions
// Spread extra model params (e.g. stop, top_p) into obj
Object.assign(obj, modelParams)
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.

security-high high

Avoid mass assignment from user-provided JSON to the model configuration object. Directly spreading modelParams into obj allows users to overwrite sensitive fields like apiKey or openAIApiKey, which are intended to be managed via credentials. Please explicitly exclude these sensitive fields to prevent potential security issues or unexpected behavior.

Suggested change
const { defaultHeaders, baseURL, ...modelParams } = parsedBaseOptions
// Spread extra model params (e.g. stop, top_p) into obj
Object.assign(obj, modelParams)
const { defaultHeaders, baseURL, apiKey, openAIApiKey, configuration, ...modelParams } = parsedBaseOptions
// Spread extra model params (e.g. stop, top_p) into obj
Object.assign(obj, modelParams)
References
  1. Avoid mass assignment from request bodies to entities. Instead of using a generic assignment like Object.assign(entity, body), explicitly map allowed properties.

@BOOPATB BOOPATB changed the title fix: ChatOpenAI baseOptions additional parameters not applied to modelfix: apply baseOptions as model params instead of only headers in Cha… fix: ChatOpenAI baseOptions additional parameters not applied to model Apr 8, 2026
@BOOPATB
Copy link
Copy Markdown
Author

BOOPATB commented Apr 8, 2026

Fixes #2499

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.

[BUG] Additional Parameters did not take effect.

2 participants