Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The ACMM level pack now places the reviewer on the inference gateway the operator moved the other agents onto from the dashboard, instead of leaving it on copilot (#14678).
29 changes: 28 additions & 1 deletion src/pkg/dashboard/api_packs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,22 +1173,49 @@ type agentBackendVote struct {

// hiveAgentBackends snapshots the backend of every enabled agent, keyed by
// name, for hiveGatewayBackend.
//
// An agent's backend is the one it actually runs on: a live BackendOverride
// wins over its config backend, exactly as the dashboard's agent cards and
// config dialog show it (#14678). The override is replayed from
// /data/hive-state.json before the boot-time pack apply, so a hive whose
// operator moved scanner/quality/guide onto LiteLLM through an override saw
// LiteLLM on every card while this vote still read their pack-owned copilot
// config backend, found no gateway, and left the reviewer on copilot. An
// override differing from the config backend is an explicit placement, so it
// counts as an operator pick.
func (s *Server) hiveAgentBackends() map[string]agentBackendVote {
backends := map[string]agentBackendVote{}
for name, agent := range s.deps.Config.Agents {
if !agent.Enabled || s.deps.Config.IsAgentRemoved(name) {
continue
}
backend := strings.TrimSpace(agent.Backend)
backends[name] = agentBackendVote{
vote := agentBackendVote{
backend: backend,
operatorOwned: agent.BackendIsOperatorOwned() || s.unownedGatewayBackend(agent),
packCLI: agent.BackendIsPackOwned() && config.IsCLIBackend(backend),
}
if override := s.agentBackendOverride(name); override != "" && !strings.EqualFold(override, backend) {
vote = agentBackendVote{backend: override, operatorOwned: true}
}
backends[name] = vote
}
return backends
}

// agentBackendOverride is name's live BackendOverride, or "" when the agent
// has none or is not in the manager's process table.
func (s *Server) agentBackendOverride(name string) string {
if s.deps.AgentMgr == nil {
return ""
}
proc, err := s.deps.AgentMgr.GetStatus(name)
if err != nil || proc == nil {
return ""
}
return strings.TrimSpace(proc.BackendOverride)
}

// unownedGatewayBackend reports whether agent sits on an inference backend or
// configured gateway with no backend_owner stamp. A pack only ever writes a
// subscription CLI, and stamps a gateway it moved an agent onto as pack-owned,
Expand Down
41 changes: 41 additions & 0 deletions src/pkg/dashboard/pack_gateway_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,3 +447,44 @@ func TestApplyPackUnownedCLIBackendsDoNotChooseGateway(t *testing.T) {
t.Errorf("reviewer moved onto %q with no gateway picked", got.Backend)
}
}

// TestApplyPackFollowsGatewayBackendOverrides covers the second #14678 reopen:
// the operator's agents ran on LiteLLM through a live BackendOverride (replayed
// from hive-state.json before the boot-time pack apply) while their config
// backend was still the pack's copilot. The dashboard showed LiteLLM on every
// card, but the pack read only the config backend, found no gateway, and kept
// the L2 reviewer on copilot.
func TestApplyPackFollowsGatewayBackendOverrides(t *testing.T) {
for _, tt := range []struct {
name string
reviewer *config.AgentConfig
}{
{"reviewer created by the level", nil},
{"pack-owned copilot reviewer repaired", &config.AgentConfig{
ID: "reviewer", Role: "reviewer", Enabled: true,
Backend: "copilot", BackendOwner: config.FieldOwnerPack,
Model: "claude-fable-5", ModelOwner: config.FieldOwnerPack,
}},
} {
t.Run(tt.name, func(t *testing.T) {
srv := newFullServer(t)
for _, name := range []string{"scanner", "quality", "guide"} {
a := packCLIAgent(name)
srv.deps.Config.Agents[name] = a
srv.deps.AgentMgr.AddAgent(name, a)
if err := srv.deps.AgentMgr.SetBackendOverride(name, "litellm"); err != nil {
t.Fatalf("SetBackendOverride(%s): %v", name, err)
}
}
if tt.reviewer != nil {
srv.deps.Config.Agents["reviewer"] = *tt.reviewer
}
if _, err := srv.ApplyPack(2); err != nil {
t.Fatalf("ApplyPack(2): %v", err)
}
if got := srv.deps.Config.Agents["reviewer"]; got.Backend != "litellm" || got.Model != "" {
t.Errorf("reviewer backend=%q model=%q, want litellm with no model like the agents the operator moved", got.Backend, got.Model)
}
})
}
}
Loading