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

Function TestPlanModeSubagentChatExcludesAskUserQuestion

coderd/x/chatd/chatd_test.go:471–636  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

469}
470
471func TestPlanModeSubagentChatExcludesAskUserQuestion(t *testing.T) {
472 t.Parallel()
473
474 ctx := testutil.Context(t, testutil.WaitLong)
475 deploymentValues := directChatRoutingDeploymentValues(t)
476 client := coderdtest.New(t, &coderdtest.Options{
477 DeploymentValues: deploymentValues,
478 IncludeProvisionerDaemon: true,
479 })
480 user := coderdtest.CreateFirstUser(t, client)
481 expClient := codersdk.NewExperimentalClient(client)
482
483 agentToken := uuid.NewString()
484 version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
485 Parse: echo.ParseComplete,
486 ProvisionPlan: echo.PlanComplete,
487 ProvisionApply: echo.ApplyComplete,
488 ProvisionGraph: echo.ProvisionGraphWithAgent(agentToken),
489 })
490 coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
491 coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
492
493 _ = agenttest.New(t, client.URL, agentToken)
494
495 // Start an external MCP server whose tools should remain available to the
496 // root plan-mode chat but stay hidden from plan-mode subagents.
497 mcpSrv := mcpserver.NewMCPServer("plan-root-mcp", "1.0.0")
498 mcpSrv.AddTools(mcpserver.ServerTool{
499 Tool: mcpgo.NewTool("echo",
500 mcpgo.WithDescription("Echoes the input"),
501 mcpgo.WithString("input",
502 mcpgo.Description("The input string"),
503 mcpgo.Required(),
504 ),
505 ),
506 Handler: func(_ context.Context, req mcpgo.CallToolRequest) (*mcpgo.CallToolResult, error) {
507 input, _ := req.GetArguments()["input"].(string)
508 return mcpgo.NewToolResultText("echo: " + input), nil
509 },
510 })
511 mcpTS := httptest.NewServer(mcpserver.NewStreamableHTTPServer(mcpSrv))
512 t.Cleanup(mcpTS.Close)
513
514 mcpConfig, err := client.CreateMCPServerConfig(ctx, codersdk.CreateMCPServerConfigRequest{
515 DisplayName: "Plan Root MCP",
516 Slug: "plan-root-mcp",
517 Transport: "streamable_http",
518 URL: mcpTS.URL,
519 AuthType: "none",
520 Availability: "default_off",
521 Enabled: true,
522 AllowInPlanMode: true,
523 })
524 require.NoError(t, err)
525
526 var toolsMu sync.Mutex
527 toolsByCall := make([][]string, 0, 2)
528 requestsByCall := make([]recordedOpenAIRequest, 0, 2)

Callers

nothing calls this directly

Calls 15

CreateChatMethod · 0.95
GetChatMethod · 0.95
ContextFunction · 0.92
NewFunction · 0.92
CreateFirstUserFunction · 0.92
NewExperimentalClientFunction · 0.92
CreateTemplateVersionFunction · 0.92
ProvisionGraphWithAgentFunction · 0.92
CreateTemplateFunction · 0.92
NewFunction · 0.92
NewOpenAIFunction · 0.92

Tested by

no test coverage detected