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

Function TestOpenAIReasoningRoundTripStoreFalse

coderd/x/chatd/integration_test.go:482–618  ·  view source on GitHub ↗

TestOpenAIReasoningRoundTripStoreFalse is an integration test that verifies follow-up messages succeed when reasoning items were created with store: false, where OpenAI response item IDs are ephemeral and are not persisted on OpenAI's servers. It sends a query to a reasoning model, waits for complet

(t *testing.T)

Source from the content-addressed store, hash-verified

480//
481// The test requires OPENAI_TEST_API_KEY to be set.
482func TestOpenAIReasoningRoundTripStoreFalse(t *testing.T) {
483 t.Parallel()
484
485 apiKey := os.Getenv("OPENAI_TEST_API_KEY")
486 if apiKey == "" {
487 t.Skip("OPENAI_TEST_API_KEY not set; skipping OpenAI integration test")
488 }
489 baseURL := os.Getenv("OPENAI_BASE_URL")
490
491 ctx := testutil.Context(t, testutil.WaitSuperLong)
492
493 // Stand up a full coderd.
494 deploymentValues := coderdtest.DeploymentValues(t)
495 client := coderdtest.New(t, &coderdtest.Options{
496 DeploymentValues: deploymentValues,
497 })
498 user := coderdtest.CreateFirstUser(t, client)
499 expClient := codersdk.NewExperimentalClient(client)
500
501 provider := createIntegrationAIProvider(
502 ctx, t, expClient, codersdk.AIProviderTypeOpenAI, apiKey, baseURL,
503 )
504
505 // Create a model config for a reasoning model with Store: false.
506 // Using o4-mini because it always produces reasoning items.
507 contextLimit := int64(200000)
508 isDefault := true
509 reasoningSummary := "auto"
510 _, err := expClient.CreateChatModelConfig(ctx, codersdk.CreateChatModelConfigRequest{
511 Provider: string(provider.Type),
512 AIProviderID: &provider.ID,
513 Model: "o4-mini",
514 ContextLimit: &contextLimit,
515 IsDefault: &isDefault,
516 ModelConfig: &codersdk.ChatModelCallConfig{
517 ProviderOptions: &codersdk.ChatModelProviderOptions{
518 OpenAI: &codersdk.ChatModelOpenAIProviderOptions{
519 Store: ptr.Ref(false),
520 ReasoningSummary: &reasoningSummary,
521 },
522 },
523 },
524 })
525 require.NoError(t, err)
526
527 // --- Step 1: Send a message that triggers reasoning ---
528 t.Log("Creating chat with reasoning query...")
529 chat, err := expClient.CreateChat(ctx, codersdk.CreateChatRequest{
530 OrganizationID: user.OrganizationID,
531 Content: []codersdk.ChatInputPart{
532 {
533 Type: codersdk.ChatInputPartTypeText,
534 Text: "What is 2+2? Be brief.",
535 },
536 },
537 })
538 require.NoError(t, err)
539 t.Logf("Chat created: %s (status=%s)", chat.ID, chat.Status)

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