MCPcopy
hub / github.com/docker/docker-agent / TestTransferTaskPromptExcludesParents

Function TestTransferTaskPromptExcludesParents

pkg/session/session_test.go:574–611  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

572}
573
574func TestTransferTaskPromptExcludesParents(t *testing.T) {
575 t.Parallel()
576
577 // Build hierarchy: planner -> root -> librarian
578 // root's sub-agents: [librarian]
579 // root's parents: [planner] (set by planner listing root as a sub-agent)
580 librarian := agent.New("librarian", "", agent.WithDescription("Library agent"))
581 root := agent.New("root", "You are the root agent",
582 agent.WithDescription("Root agent"),
583 )
584 planner := agent.New("planner", "",
585 agent.WithDescription("Planner agent"),
586 )
587 // Connect: root -> librarian (root has librarian as sub-agent)
588 agent.WithSubAgents(librarian)(root)
589 // Connect: planner -> root (planner has root as sub-agent, making root's parent = planner)
590 agent.WithSubAgents(root)(planner)
591
592 // Verify parent relationship was established
593 require.Len(t, root.Parents(), 1)
594 assert.Equal(t, "planner", root.Parents()[0].Name())
595
596 s := New()
597 messages := s.GetMessages(root)
598
599 // Find the system message about sub-agents
600 var subAgentMsg string
601 for _, msg := range messages {
602 if msg.Role == chat.MessageRoleSystem && strings.Contains(msg.Content, "transfer_task") {
603 subAgentMsg = msg.Content
604 break
605 }
606 }
607
608 require.NotEmpty(t, subAgentMsg, "should have a sub-agent system message")
609 assert.Contains(t, subAgentMsg, "librarian", "should list librarian as a valid sub-agent")
610 assert.NotContains(t, subAgentMsg, "planner", "should NOT list parent agent planner as a valid transfer target")
611}
612
613func TestNormalizeMessageContent(t *testing.T) {
614 t.Parallel()

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
WithDescriptionFunction · 0.92
WithSubAgentsFunction · 0.92
ParentsMethod · 0.80
GetMessagesMethod · 0.80
NewFunction · 0.70
LenMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected