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

Method closeSubagent

coderd/x/chatd/subagent.go:1382–1409  ·  view source on GitHub ↗
(
	ctx context.Context,
	parentChatID uuid.UUID,
	targetChatID uuid.UUID,
)

Source from the content-addressed store, hash-verified

1380}
1381
1382func (p *Server) closeSubagent(
1383 ctx context.Context,
1384 parentChatID uuid.UUID,
1385 targetChatID uuid.UUID,
1386) (database.Chat, error) {
1387 isDescendant, err := isSubagentDescendant(ctx, p.db, parentChatID, targetChatID)
1388 if err != nil {
1389 return database.Chat{}, err
1390 }
1391 if !isDescendant {
1392 return database.Chat{}, ErrSubagentNotDescendant
1393 }
1394
1395 targetChat, err := p.db.GetChatByID(ctx, targetChatID)
1396 if err != nil {
1397 return database.Chat{}, xerrors.Errorf("get target chat: %w", err)
1398 }
1399
1400 if targetChat.Status == database.ChatStatusWaiting {
1401 return targetChat, nil
1402 }
1403
1404 updatedChat := p.InterruptChat(ctx, targetChat)
1405 if updatedChat.Status != database.ChatStatusWaiting {
1406 return database.Chat{}, xerrors.New("set target chat waiting")
1407 }
1408 return updatedChat, nil
1409}
1410
1411func (p *Server) checkSubagentCompletion(
1412 ctx context.Context,

Callers 1

subagentToolsMethod · 0.95

Calls 5

InterruptChatMethod · 0.95
isSubagentDescendantFunction · 0.85
GetChatByIDMethod · 0.65
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected