Skip to content

fix: honor defaultHeaders null for helper method header#1857

Open
Genmin wants to merge 1 commit intoopenai:masterfrom
Genmin:fix/helper-method-default-header-null
Open

fix: honor defaultHeaders null for helper method header#1857
Genmin wants to merge 1 commit intoopenai:masterfrom
Genmin:fix/helper-method-default-header-null

Conversation

@Genmin
Copy link
Copy Markdown

@Genmin Genmin commented Apr 29, 2026

Fixes #1499.

Helper-method headers were previously injected as ordinary per-request headers by helpers such as runTools(), stream(), and chat.completions.parse(). Since per-request headers are merged after defaultHeaders, users could not suppress X-Stainless-Helper-Method with defaultHeaders: { 'x-stainless-helper-method': null } even though that works for the other Stainless telemetry headers.

This moves helper-method markers into internal request metadata and emits the header from the client’s internal header block, before defaultHeaders are applied. Existing helper telemetry remains present by default, while explicit default-header nulls can now remove it consistently.

Validation:

  • yarn fix src/client.ts src/lib/ChatCompletionRunner.ts src/lib/ChatCompletionStreamingRunner.ts src/lib/ChatCompletionStream.ts src/lib/responses/ResponseStream.ts src/lib/AssistantStream.ts src/resources/chat/completions/completions.ts tests/lib/ChatCompletionRunFunctions.test.ts
  • yarn test tests/lib/ChatCompletionRunFunctions.test.ts

@Genmin Genmin requested a review from a team as a code owner April 29, 2026 23:12
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.

Setting x-stainless-helper-method to null in defaultHeaders gets ignored

1 participant