(t *testing.T)
| 572 | } |
| 573 | |
| 574 | func 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 | |
| 613 | func TestNormalizeMessageContent(t *testing.T) { |
| 614 | t.Parallel() |
nothing calls this directly
no test coverage detected