Skip to content

fix: forward the same model.parameters keys as the Python SDK - #118

Draft
apucacao wants to merge 6 commits into
mainfrom
fix/forwarding-parity
Draft

apucacao wants to merge 6 commits into
mainfrom
fix/forwarding-parity

Conversation

@apucacao

@apucacao apucacao commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

The JS and Python SDKs have to forward the same model.parameters keys before 1.0. Jeff's review of launchdarkly/python-ai-sdk#107 found that the lists from #73 differ from Python's. The shared lists are now in the cross-SDK spec (launchdarkly/ai-sdks-monorepo#42, TESTING.md §1.12), and Python is moving to them too. This PR makes each JS handler forward exactly those lists.

What changed:

  • Claude Messages: stops forwarding container, inference_geo and metadata.
  • OpenAI Messages: stops forwarding context_management, include, instructions, metadata, moderation, prompt_cache_retention, safety_identifier, store, truncation and user, on both invoke and stream. max_tool_calls is not forwarded: the openai package has no such field on ResponseCreateParamsBase, so the spec cuts it for both SDKs.
  • OpenAI Agents (handler and native graph): stops forwarding context_management, prompt_cache_retention, store and truncation.
  • LangChain ChatOpenAI (both LangChain packages and the LangGraph native graph's default model): stops forwarding audio, disable_streaming, metadata, modalities, output_version, prompt_cache_key, prompt_cache_retention, reasoning, stream_usage, streaming, tags, use_responses_api, user, verbose and zdr_enabled. prompt_cache_key is cut because the Python ChatOpenAI has no such field; OpenAI Messages still forwards it.
  • LangChain ChatAnthropic: stops forwarding context_management, disable_streaming, inference_geo, metadata, output_version, stream_usage, streaming, tags and verbose. It now takes stop as stopSequences and max_tokens_to_sample as maxTokens, because ChatAnthropic has neither field under those names.
  • LangChain ChatBedrockConverse: stops forwarding disable_streaming, guardrail_config, metadata, output_version, stream_usage, streaming, supports_tool_choice_values, tags and verbose.
  • Claude Agents and Vercel: no change.

Following the spec, nested values with the wrong shape are dropped instead of sent. Examples are a thinking without a type, a reasoning that is not an object, or a tool_choice of the wrong type. OpenAI Messages reasoning keeps only effort and summary, as OpenAI Agents already did.

Testing:

  • Each handler has a test that the forwarded keys are exactly the spec's list, and that invoke and stream forward the same keys and values.
  • Every removed key is in that package's __tests__/never-forwarded.ts, so the existing bag tests prove it is gone.
  • New tests cover dropping malformed nested values.
  • yarn test, yarn typecheck and biome check . pass locally.

Note

Overview
Aligns JS provider handlers with the cross-SDK model.parameters allowlists (TESTING.md §1.12) so forwarding matches the Python SDK before 1.0.

Handlers now forward only generation-shaping keys and stop passing retention, attribution, server-side state, and wiring fields that were previously allowed (e.g. Claude Messages: container, inference_geo, metadata; OpenAI Messages/Agents: store, context_management, truncation, etc.; LangChain: reasoning, use_responses_api, guardrail_config, metadata, streaming flags, and more). Malformed nested values (thinking, tool_choice, reasoning, output_config, etc.) are dropped instead of sent; OpenAI Messages trims reasoning to effort/summary. LangChain ChatAnthropic maps max_tokens_to_sample → maxTokens and stop → stopSequences. OpenAI Agents removes context_management transformation from buildModelSettings.

Tests add canonical-key parity for invoke vs stream, expand NEVER_FORWARDED_KEYS, and cover malformed-parameter drops.

Reviewed by Cursor Bugbot for commit 0e963d3. Bugbot is set up for automated code reviews on this repo. Configure here.

…meters

Stop forwarding container, inference_geo and metadata, so the handler
forwards the same model.parameters keys as the Python SDK. Drop a
thinking, tool_choice, cache_control or output_config value of the wrong
shape instead of sending it.
…meters

Stop forwarding context_management, include, instructions, metadata,
moderation, prompt_cache_retention, safety_identifier, store, truncation
and user, so invoke and stream forward the same keys as the Python SDK.
reasoning keeps only effort and summary, and a malformed reasoning or
tool_choice is dropped instead of sent.

max_tool_calls is on the shared list but not on ResponseCreateParamsBase
in the installed openai package, so it is not forwarded.
Stop forwarding context_management, prompt_cache_retention, store and
truncation into ModelSettings, in the handler and the native graph, so
they match the Python SDK. A tool_choice that is not a string is now
dropped instead of passed on.
Narrow the ChatOpenAI, ChatAnthropic and ChatBedrockConverse allowlists,
used by both LangChain packages and the LangGraph native graph's default
model, to the lists the Python SDK forwards. This stops forwarding
LangChain wiring and logging settings (tags, metadata, verbose,
streaming, stream_usage, disable_streaming, output_version), settings
that switch ChatOpenAI to the Responses API (reasoning,
use_responses_api), data location and retention settings (inference_geo,
prompt_cache_retention, zdr_enabled), and audio, modalities, user,
context_management, guardrail_config and supports_tool_choice_values.

ChatAnthropic now also takes stop as stopSequences and
max_tokens_to_sample as maxTokens, since it has neither field under
those names. A malformed thinking, output_config, logit_bias or
performance_config is dropped instead of passed on.
…K list

The list itself is unchanged. The new test proves invoke and stream add
exactly those query options and nothing else.
@apucacao

apucacao commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor 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.

Stale Bugbot comment from a previous run.

The Python ChatOpenAI has no such field, so the cross-SDK list cuts it
for both SDKs. OpenAI Messages still forwards it to the Responses API.
@apucacao

apucacao commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0e963d3. Configure here.

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.

1 participant