MCPcopy Index your code
hub / github.com/coder/coder / TestOpenAIReasoningRoundTrip

Function TestOpenAIReasoningRoundTrip

coderd/x/chatd/integration_test.go:331–466  ·  view source on GitHub ↗

TestOpenAIReasoningRoundTrip is an integration test that verifies reasoning items from OpenAI's Responses API survive the full persist → reconstruct → re-send cycle when Store: true. It sends a query to a reasoning model, waits for completion, then sends a follow-up message. If reasoning items are s

(t *testing.T)

Source from the content-addressed store, hash-verified

329//
330// The test requires OPENAI_TEST_API_KEY to be set.
331func TestOpenAIReasoningRoundTrip(t *testing.T) {
332 t.Parallel()
333
334 apiKey := os.Getenv("OPENAI_TEST_API_KEY")
335 if apiKey == "" {
336 t.Skip("OPENAI_TEST_API_KEY not set; skipping OpenAI integration test")
337 }
338 baseURL := os.Getenv("OPENAI_BASE_URL")
339
340 ctx := testutil.Context(t, testutil.WaitSuperLong)
341
342 // Stand up a full coderd.
343 deploymentValues := coderdtest.DeploymentValues(t)
344 client := coderdtest.New(t, &coderdtest.Options{
345 DeploymentValues: deploymentValues,
346 })
347 user := coderdtest.CreateFirstUser(t, client)
348 expClient := codersdk.NewExperimentalClient(client)
349
350 provider := createIntegrationAIProvider(
351 ctx, t, expClient, codersdk.AIProviderTypeOpenAI, apiKey, baseURL,
352 )
353
354 // Create a model config for a reasoning model with Store: true
355 // (the default). Using o4-mini because it always produces
356 // reasoning items.
357 contextLimit := int64(200000)
358 isDefault := true
359 reasoningSummary := "auto"
360 _, err := expClient.CreateChatModelConfig(ctx, codersdk.CreateChatModelConfigRequest{
361 Provider: string(provider.Type),
362 AIProviderID: &provider.ID,
363 Model: "o4-mini",
364 ContextLimit: &contextLimit,
365 IsDefault: &isDefault,
366 ModelConfig: &codersdk.ChatModelCallConfig{
367 ProviderOptions: &codersdk.ChatModelProviderOptions{
368 OpenAI: &codersdk.ChatModelOpenAIProviderOptions{
369 Store: ptr.Ref(true),
370 ReasoningSummary: &reasoningSummary,
371 },
372 },
373 },
374 })
375 require.NoError(t, err)
376
377 // --- Step 1: Send a message that triggers reasoning ---
378 t.Log("Creating chat with reasoning query...")
379 chat, err := expClient.CreateChat(ctx, codersdk.CreateChatRequest{
380 OrganizationID: user.OrganizationID,
381 Content: []codersdk.ChatInputPart{
382 {
383 Type: codersdk.ChatInputPartTypeText,
384 Text: "What is 2+2? Be brief.",
385 },
386 },
387 })
388 require.NoError(t, err)

Callers

nothing calls this directly

Calls 15

CreateChatModelConfigMethod · 0.95
CreateChatMethod · 0.95
StreamChatMethod · 0.95
GetChatMethod · 0.95
GetChatMessagesMethod · 0.95
CreateChatMessageMethod · 0.95
ContextFunction · 0.92
DeploymentValuesFunction · 0.92
NewFunction · 0.92
CreateFirstUserFunction · 0.92
NewExperimentalClientFunction · 0.92
RefFunction · 0.92

Tested by

no test coverage detected