(t *testing.T)
| 1560 | } |
| 1561 | |
| 1562 | func TestEmitStartupInfo(t *testing.T) { |
| 1563 | t.Parallel() |
| 1564 | |
| 1565 | // Create a simple agent with mock provider |
| 1566 | prov := &mockProvider{id: "test/startup-model", stream: &mockStream{}} |
| 1567 | root := agent.New("startup-test-agent", "You are a startup test agent", |
| 1568 | agent.WithModel(prov), |
| 1569 | agent.WithDescription("This is a startup test agent"), |
| 1570 | agent.WithWelcomeMessage("Welcome!"), |
| 1571 | ) |
| 1572 | other := agent.New("other-agent", "You are another agent", |
| 1573 | agent.WithModel(prov), |
| 1574 | agent.WithDescription("This is another agent"), |
| 1575 | ) |
| 1576 | tm := team.New(team.WithAgents(root, other)) |
| 1577 | |
| 1578 | rt, err := NewLocalRuntime(t.Context(), tm, WithCurrentAgent("startup-test-agent"), WithModelStore(mockModelStore{})) |
| 1579 | require.NoError(t, err) |
| 1580 | |
| 1581 | // Create a channel to collect events |
| 1582 | events := make(chan Event, 10) |
| 1583 | |
| 1584 | // Call EmitStartupInfo |
| 1585 | rt.EmitStartupInfo(t.Context(), nil, NewChannelSink(events)) |
| 1586 | close(events) |
| 1587 | |
| 1588 | // Collect events |
| 1589 | var collectedEvents []Event |
| 1590 | for event := range events { |
| 1591 | collectedEvents = append(collectedEvents, event) |
| 1592 | } |
| 1593 | |
| 1594 | // Verify expected events are emitted |
| 1595 | expectedEvents := []Event{ |
| 1596 | AgentInfo("startup-test-agent", "test/startup-model", "This is a startup test agent", "Welcome!"), |
| 1597 | TeamInfo([]AgentDetails{ |
| 1598 | {Name: "startup-test-agent", Description: "This is a startup test agent", Provider: "test", Model: "startup-model"}, |
| 1599 | {Name: "other-agent", Description: "This is another agent", Provider: "test", Model: "startup-model"}, |
| 1600 | }, "startup-test-agent"), |
| 1601 | ToolsetInfo(0, false, "startup-test-agent"), // No tools configured |
| 1602 | } |
| 1603 | |
| 1604 | assertEventsEqual(t, expectedEvents, collectedEvents) |
| 1605 | |
| 1606 | // Test that calling EmitStartupInfo again doesn't emit duplicate events |
| 1607 | events2 := make(chan Event, 10) |
| 1608 | rt.EmitStartupInfo(t.Context(), nil, NewChannelSink(events2)) |
| 1609 | close(events2) |
| 1610 | |
| 1611 | var collectedEvents2 []Event |
| 1612 | for event := range events2 { |
| 1613 | collectedEvents2 = append(collectedEvents2, event) |
| 1614 | } |
| 1615 | |
| 1616 | // Should be empty due to deduplication |
| 1617 | require.Empty(t, collectedEvents2, "EmitStartupInfo should not emit duplicate events") |
| 1618 | } |
| 1619 |
nothing calls this directly
no test coverage detected