TestPromoteQueuedWhileRequiresActionMixedTools guards against duplicating already-resolved built-in tool results: synthetic results must be scoped to dynamic tool names only.
(t *testing.T)
| 9360 | // duplicating already-resolved built-in tool results: synthetic |
| 9361 | // results must be scoped to dynamic tool names only. |
| 9362 | func TestPromoteQueuedWhileRequiresActionMixedTools(t *testing.T) { |
| 9363 | t.Parallel() |
| 9364 | |
| 9365 | db, ps := dbtestutil.NewDB(t) |
| 9366 | ctx := testutil.Context(t, testutil.WaitLong) |
| 9367 | |
| 9368 | var streamedCallCount atomic.Int32 |
| 9369 | openAIURL := chattest.NewOpenAI(t, func(req *chattest.OpenAIRequest) chattest.OpenAIResponse { |
| 9370 | if !req.Stream { |
| 9371 | return chattest.OpenAINonStreamingResponse("mixed-tools-promote") |
| 9372 | } |
| 9373 | if streamedCallCount.Add(1) == 1 { |
| 9374 | builtinChunk := chattest.OpenAIToolCallChunk( |
| 9375 | "read_file", |
| 9376 | `{"path":"/tmp/test.txt"}`, |
| 9377 | ) |
| 9378 | dynamicChunk := chattest.OpenAIToolCallChunk( |
| 9379 | "my_dynamic_tool", |
| 9380 | `{"input":"hello world"}`, |
| 9381 | ) |
| 9382 | mergedChunk := builtinChunk |
| 9383 | dynCall := dynamicChunk.Choices[0].ToolCalls[0] |
| 9384 | dynCall.Index = 1 |
| 9385 | mergedChunk.Choices[0].ToolCalls = append( |
| 9386 | mergedChunk.Choices[0].ToolCalls, |
| 9387 | dynCall, |
| 9388 | ) |
| 9389 | return chattest.OpenAIStreamingResponse(mergedChunk) |
| 9390 | } |
| 9391 | return chattest.OpenAIStreamingResponse( |
| 9392 | chattest.OpenAITextChunks("Resumed after mixed-tool promotion.")..., |
| 9393 | ) |
| 9394 | }) |
| 9395 | |
| 9396 | user, org, model := seedChatDependenciesWithProvider(t, db, "openai-compat", openAIURL) |
| 9397 | server := newActiveTestServer(t, db, ps) |
| 9398 | |
| 9399 | dynamicToolsJSON, err := json.Marshal([]mcpgo.Tool{{ |
| 9400 | Name: "my_dynamic_tool", |
| 9401 | Description: "A test dynamic tool.", |
| 9402 | InputSchema: mcpgo.ToolInputSchema{ |
| 9403 | Type: "object", |
| 9404 | Properties: map[string]any{ |
| 9405 | "input": map[string]any{"type": "string"}, |
| 9406 | }, |
| 9407 | Required: []string{"input"}, |
| 9408 | }, |
| 9409 | }}) |
| 9410 | require.NoError(t, err) |
| 9411 | |
| 9412 | chat, err := server.CreateChat(ctx, chatd.CreateOptions{ |
| 9413 | OrganizationID: org.ID, |
| 9414 | OwnerID: user.ID, |
| 9415 | Title: "promote-while-requires-action-mixed", |
| 9416 | ModelConfigID: model.ID, |
| 9417 | InitialUserContent: []codersdk.ChatMessagePart{ |
| 9418 | codersdk.ChatMessageText("Call both tools."), |
| 9419 | }, |
nothing calls this directly
no test coverage detected