Skip to content

Commit 8ffa57e

Browse files
authored
Merge pull request #595 from rumpl/no-filter
Always return all the agents
2 parents 83ab408 + c5090b4 commit 8ffa57e

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

pkg/server/server.go

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -793,19 +793,40 @@ func (s *Server) getAgents(c echo.Context) error {
793793
slog.Error("Failed to refresh agents from disk", "error", err)
794794
}
795795

796-
var agents []api.Agent
796+
// DO NOT, under any circumstance, replace this with "var agents []api.Agent",
797+
// we want to return an empty slice if there are no agents, not nil.
798+
agents := []api.Agent{}
799+
797800
for id, t := range s.teams {
798801
a, err := t.Agent("root")
799802
if err != nil {
800-
slog.Error("Agent root not found", "team", id)
801-
continue
803+
switch {
804+
case t.Size() > 1:
805+
agents = append(agents, api.Agent{
806+
Name: id,
807+
Multi: true,
808+
})
809+
case t.Size() == 1:
810+
a, err = t.Agent(t.AgentNames()[0])
811+
if err != nil {
812+
return echo.NewHTTPError(http.StatusInternalServerError, "failed to get agent")
813+
}
814+
agents = append(agents, api.Agent{
815+
Name: id,
816+
Description: a.Description(),
817+
Multi: false,
818+
})
819+
default:
820+
slog.Warn("Team has no agents", "team", id)
821+
continue
822+
}
823+
} else {
824+
agents = append(agents, api.Agent{
825+
Name: id,
826+
Description: a.Description(),
827+
Multi: a.HasSubAgents(),
828+
})
802829
}
803-
804-
agents = append(agents, api.Agent{
805-
Name: id,
806-
Description: a.Description(),
807-
Multi: a.HasSubAgents(),
808-
})
809830
}
810831

811832
// Sort agents by name

0 commit comments

Comments
 (0)