MCPcopy Index your code
hub / github.com/docker/docker-agent / reachableFirstAvailableModels

Function reachableFirstAvailableModels

pkg/config/first_available.go:67–124  ·  view source on GitHub ↗
(cfg *latest.Config, selectors map[string]bool)

Source from the content-addressed store, hash-verified

65}
66
67func reachableFirstAvailableModels(cfg *latest.Config, selectors map[string]bool) map[string]bool {
68 reachable := map[string]bool{}
69 seen := map[string]bool{}
70
71 hasRootReference := false
72
73 var visit func(string)
74 visit = func(ref string) {
75 ref = strings.TrimSpace(ref)
76 if ref == "" || seen[ref] {
77 return
78 }
79 hasRootReference = true
80 seen[ref] = true
81
82 model, exists := cfg.Models[ref]
83 if !exists {
84 return
85 }
86 if selectors[ref] {
87 reachable[ref] = true
88 return
89 }
90 for _, rule := range model.Routing {
91 visit(rule.Model)
92 }
93 }
94
95 for _, agent := range cfg.Agents {
96 if agent.Harness == nil {
97 for ref := range strings.SplitSeq(agent.Model, ",") {
98 visit(ref)
99 }
100 for _, ref := range agent.GetFallbackModels() {
101 visit(ref)
102 }
103 }
104
105 for _, toolset := range agent.Toolsets {
106 visit(toolset.Model)
107 if toolset.RAGConfig != nil && toolset.RAGConfig.Results.Reranking != nil {
108 visit(toolset.RAGConfig.Results.Reranking.Model)
109 }
110 }
111
112 for _, skill := range agent.Skills.Inline {
113 if skill.Context == "fork" {
114 visit(skill.Model)
115 }
116 }
117 }
118
119 if !hasRootReference {
120 return selectors
121 }
122
123 return reachable
124}

Callers 1

Calls 1

GetFallbackModelsMethod · 0.45

Tested by

no test coverage detected