Skip to content

Commit 804db06

Browse files
authored
Merge pull request #857 from dgageot/fix-848
Fix #848
2 parents cd77de9 + 588ea92 commit 804db06

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

pkg/runtime/runtime_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,6 @@ func TestProcessToolCalls_UnknownTool_NoToolResultMessage(t *testing.T) {
728728
}
729729

730730
func TestEmitStartupInfo(t *testing.T) {
731-
t.Skip("This test is flaky. See #848 for details.")
732-
733731
// Create a simple agent with mock provider
734732
prov := &mockProvider{id: "test/startup-model", stream: &mockStream{}}
735733
root := agent.New("startup-test-agent", "You are a startup test agent",
@@ -759,7 +757,7 @@ func TestEmitStartupInfo(t *testing.T) {
759757
// Verify expected events are emitted
760758
expectedEvents := []Event{
761759
AgentInfo("startup-test-agent", "test/startup-model", "This is a startup test agent"),
762-
TeamInfo([]string{"startup-test-agent", "other-agent"}, "startup-test-agent"),
760+
TeamInfo([]string{"other-agent", "startup-test-agent"}, "startup-test-agent"),
763761
ToolsetInfo(0, "startup-test-agent"), // No tools configured
764762
}
765763

pkg/team/team.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"slices"
78
"strings"
89

910
"github.com/docker/cagent/pkg/agent"
@@ -31,7 +32,9 @@ func WithAgents(agents ...*agent.Agent) Opt {
3132
}
3233

3334
func New(opts ...Opt) *Team {
34-
t := &Team{agents: make(map[string]*agent.Agent)}
35+
t := &Team{
36+
agents: make(map[string]*agent.Agent),
37+
}
3538
for _, opt := range opts {
3639
opt(t)
3740
}
@@ -43,22 +46,18 @@ func (t *Team) AgentNames() []string {
4346
for name := range t.agents {
4447
names = append(names, name)
4548
}
49+
slices.Sort(names)
4650
return names
4751
}
4852

4953
func (t *Team) Agent(name string) (*agent.Agent, error) {
50-
if len(t.agents) == 0 {
54+
if t.Size() == 0 {
5155
return nil, errors.New("no agents loaded; ensure your agent configuration defines at least one agent")
5256
}
5357

5458
found, ok := t.agents[name]
5559
if !ok {
56-
var names []string
57-
for n := range t.agents {
58-
names = append(names, n)
59-
}
60-
61-
return nil, fmt.Errorf("agent not found: %s (available agents: %s)", name, strings.Join(names, ", "))
60+
return nil, fmt.Errorf("agent not found: %s (available agents: %s)", name, strings.Join(t.AgentNames(), ", "))
6261
}
6362

6463
return found, nil

0 commit comments

Comments
 (0)