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

Method subagentTools

coderd/x/chatd/subagent.go:532–816  ·  view source on GitHub ↗
(
	ctx context.Context,
	currentChat func() database.Chat,
	currentModelConfigID uuid.UUID,
)

Source from the content-addressed store, hash-verified

530}
531
532func (p *Server) subagentTools(
533 ctx context.Context,
534 currentChat func() database.Chat,
535 currentModelConfigID uuid.UUID,
536) []fantasy.AgentTool {
537 currentChatSnapshot := database.Chat{}
538 if currentChat != nil {
539 currentChatSnapshot = currentChat()
540 }
541
542 spawnAgentDescription := buildSpawnAgentDescription(
543 ctx,
544 p,
545 currentChatSnapshot,
546 )
547
548 return []fantasy.AgentTool{
549 fantasy.NewAgentTool(
550 spawnAgentToolName,
551 spawnAgentDescription,
552 func(ctx context.Context, args spawnAgentArgs, _ fantasy.ToolCall) (fantasy.ToolResponse, error) {
553 if currentChat == nil {
554 return fantasy.NewTextErrorResponse("subagent callbacks are not configured"), nil
555 }
556
557 parent, err := p.loadSubagentSpawnParentChat(ctx, currentChat)
558 if err != nil {
559 return fantasy.NewTextErrorResponse(err.Error()), nil
560 }
561
562 definition, err := resolveSubagentDefinition(
563 ctx,
564 p,
565 parent,
566 args.Type,
567 )
568 if err != nil {
569 return fantasy.NewTextErrorResponse(err.Error()), nil
570 }
571
572 turnParent := currentChatSnapshot
573 if turnParent.ID == uuid.Nil {
574 turnParent = parent
575 }
576
577 options, err := definition.buildOptions(
578 ctx,
579 p,
580 parent,
581 turnParent,
582 currentModelConfigID,
583 args.Prompt,
584 )
585 if err != nil {
586 return fantasy.NewTextErrorResponse(err.Error()), nil
587 }
588
589 childChat, err := p.createChildSubagentChatWithOptions(

Calls 15

stopAndStoreRecordingMethod · 0.95
sendSubagentMessageMethod · 0.95
closeSubagentMethod · 0.95
toolJSONResponseFunction · 0.85
withSubagentTypeFunction · 0.85
parseSubagentToolChatIDFunction · 0.85
isSubagentDescendantFunction · 0.85