Skip to content

Commit 56af92f

Browse files
Drop unverifiable max_tokens assertion from BYOK wire model E2E test
The OpenAI BYOK provider code path in the CLI does not echo the configured maxOutputTokens as max_tokens on the wire request body (it's used internally for token budgeting and only appears on Anthropic-style requests). The new wire model E2E test asserted on max_tokens in the captured chat completion request, which always returned undefined/nil and failed across all four SDKs. Rename the test to `should forward provider wire model'' and drop the wire-side max_tokens assertion. The test still sets maxOutputTokens to confirm the SDK serializes the field without errors; per-SDK unit tests already cover ProviderConfig serialization in detail. Also drop the now-unused MaxTokens field from the Go and .NET harness ChatCompletionRequest types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c434f4d commit 56af92f

7 files changed

Lines changed: 36 additions & 22 deletions

File tree

dotnet/test/E2E/SessionConfigE2ETests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,15 @@ public async Task Should_Forward_Custom_Provider_Headers_On_Resume()
178178
}
179179

180180
[Fact]
181-
public async Task Should_Forward_Provider_Wire_Model_And_Max_Output_Tokens()
181+
public async Task Should_Forward_Provider_Wire_Model()
182182
{
183+
// Verifies that ProviderConfig.WireModel overrides the model name sent to
184+
// the provider API, while SessionConfig.Model still drives runtime
185+
// configuration lookup (capabilities, prompts, reasoning behavior).
186+
// MaxOutputTokens is also set here to confirm the SDK accepts it without
187+
// serialization errors; the CLI does not echo it as `max_tokens` on the
188+
// OpenAI-style wire request, so we don't assert on it directly (see unit
189+
// tests for serialization coverage).
183190
var session = await CreateSessionAsync(new SessionConfig
184191
{
185192
Model = "claude-sonnet-4.5",
@@ -197,7 +204,6 @@ public async Task Should_Forward_Provider_Wire_Model_And_Max_Output_Tokens()
197204

198205
var exchange = Assert.Single(await Ctx.GetExchangesAsync());
199206
Assert.Equal("test-wire-model", exchange.Request.Model);
200-
Assert.Equal(1024, exchange.Request.MaxTokens);
201207

202208
await session.DisposeAsync();
203209
}

dotnet/test/Harness/CapiProxy.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ public record ParsedHttpExchange(
206206
public record ChatCompletionRequest(
207207
string Model,
208208
List<ChatCompletionMessage> Messages,
209-
List<ChatCompletionTool>? Tools,
210-
[property: JsonPropertyName("max_tokens")] int? MaxTokens = null);
209+
List<ChatCompletionTool>? Tools);
211210

212211
public record ChatCompletionMessage(
213212
string Role,

go/internal/e2e/session_config_e2e_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,14 @@ func TestSessionConfigExtrasE2E(t *testing.T) {
323323
}
324324
})
325325

326-
t.Run("should forward provider wire model and max output tokens", func(t *testing.T) {
326+
t.Run("should forward provider wire model", func(t *testing.T) {
327+
// Verifies that ProviderConfig.WireModel overrides the model name sent to
328+
// the provider API, while SessionConfig.Model still drives runtime
329+
// configuration lookup (capabilities, prompts, reasoning behavior).
330+
// MaxOutputTokens is also set here to confirm the SDK accepts it without
331+
// serialization errors; the CLI does not echo it as `max_tokens` on the
332+
// OpenAI-style wire request, so we don't assert on it directly (see unit
333+
// tests for serialization coverage).
327334
ctx.ConfigureForTest(t)
328335

329336
maxOutputTokens := 1024
@@ -357,13 +364,6 @@ func TestSessionConfigExtrasE2E(t *testing.T) {
357364
if exchanges[0].Request.Model != "test-wire-model" {
358365
t.Errorf("Expected request model to be 'test-wire-model', got %q", exchanges[0].Request.Model)
359366
}
360-
if exchanges[0].Request.MaxTokens == nil || *exchanges[0].Request.MaxTokens != 1024 {
361-
got := "nil"
362-
if exchanges[0].Request.MaxTokens != nil {
363-
got = fmt.Sprintf("%d", *exchanges[0].Request.MaxTokens)
364-
}
365-
t.Errorf("Expected request max_tokens to be 1024, got %s", got)
366-
}
367367
})
368368

369369
t.Run("should use provider model id as wire model", func(t *testing.T) {

go/internal/e2e/testharness/proxy.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,9 @@ type ParsedHttpExchange struct {
167167

168168
// ChatCompletionRequest represents an OpenAI chat completion request.
169169
type ChatCompletionRequest struct {
170-
Model string `json:"model"`
171-
Messages []ChatCompletionMessage `json:"messages"`
172-
Tools []ChatCompletionTool `json:"tools,omitempty"`
173-
MaxTokens *int `json:"max_tokens,omitempty"`
170+
Model string `json:"model"`
171+
Messages []ChatCompletionMessage `json:"messages"`
172+
Tools []ChatCompletionTool `json:"tools,omitempty"`
174173
}
175174

176175
// ChatCompletionMessage represents a message in the chat completion request.

nodejs/test/e2e/session_config.e2e.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,14 @@ describe("Session Configuration", async () => {
325325
await session2.disconnect();
326326
});
327327

328-
it("should forward provider wire model and max output tokens", async () => {
328+
it("should forward provider wire model", async () => {
329+
// Verifies that ProviderConfig.wireModel overrides the model name sent to
330+
// the provider API, while SessionConfig.model still drives runtime
331+
// configuration lookup (capabilities, prompts, reasoning behavior).
332+
// maxOutputTokens is also set here to confirm the SDK accepts it without
333+
// serialization errors; the CLI does not echo it as `max_tokens` on the
334+
// OpenAI-style wire request, so we don't assert on it directly (see unit
335+
// tests for serialization coverage).
329336
const session = await client.createSession({
330337
onPermissionRequest: approveAll,
331338
model: "claude-sonnet-4.5",
@@ -343,7 +350,6 @@ describe("Session Configuration", async () => {
343350
const exchanges = await openAiEndpoint.getExchanges();
344351
expect(exchanges.length).toBe(1);
345352
expect(exchanges[0].request.model).toBe("test-wire-model");
346-
expect((exchanges[0].request as { max_tokens?: number }).max_tokens).toBe(1024);
347353

348354
await session.disconnect();
349355
});

python/e2e/test_session_config_e2e.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,14 @@ async def test_should_forward_custom_provider_headers_on_resume(self, ctx: E2ETe
236236
await session2.disconnect()
237237
await session1.disconnect()
238238

239-
async def test_should_forward_provider_wire_model_and_max_output_tokens( # noqa: E501
240-
self, ctx: E2ETestContext
241-
):
239+
async def test_should_forward_provider_wire_model(self, ctx: E2ETestContext):
240+
# Verifies that ProviderConfig.wire_model overrides the model name sent
241+
# to the provider API, while SessionConfig.model still drives runtime
242+
# configuration lookup (capabilities, prompts, reasoning behavior).
243+
# max_output_tokens is also set here to confirm the SDK accepts it
244+
# without serialization errors; the CLI does not echo it as
245+
# `max_tokens` on the OpenAI-style wire request, so we don't assert on
246+
# it directly (see unit tests for serialization coverage).
242247
session = await ctx.client.create_session(
243248
on_permission_request=PermissionHandler.approve_all,
244249
model="claude-sonnet-4.5",
@@ -257,7 +262,6 @@ async def test_should_forward_provider_wire_model_and_max_output_tokens( # noqa
257262
assert len(exchanges) == 1
258263
request = exchanges[0]["request"]
259264
assert request["model"] == "test-wire-model"
260-
assert request.get("max_tokens") == 1024
261265

262266
await session.disconnect()
263267

test/snapshots/session_config/should_forward_provider_wire_model_and_max_output_tokens.yaml renamed to test/snapshots/session_config/should_forward_provider_wire_model.yaml

File renamed without changes.

0 commit comments

Comments
 (0)