MCPcopy Create free account
hub / github.com/github/gh-aw / GetEngineByPrefix

Method GetEngineByPrefix

pkg/workflow/agentic_engine.go:651–679  ·  view source on GitHub ↗

GetEngineByPrefix returns an engine that matches the given prefix This is useful for backward compatibility with strings like "codex-experimental"

(prefix string)

Source from the content-addressed store, hash-verified

649// GetEngineByPrefix returns an engine that matches the given prefix
650// This is useful for backward compatibility with strings like "codex-experimental"
651func (r *EngineRegistry) GetEngineByPrefix(prefix string) (CodingAgentEngine, error) {
652 agenticEngineLog.Printf("Looking up engine by prefix: %s", prefix)
653 type engineCandidate struct {
654 id string
655 engine CodingAgentEngine
656 }
657 var candidates []engineCandidate
658 for id, engine := range r.engines {
659 if strings.HasPrefix(prefix, id) {
660 candidates = append(candidates, engineCandidate{id, engine})
661 }
662 }
663 if len(candidates) == 0 {
664 agenticEngineLog.Printf("No engine found matching prefix: %s", prefix)
665 return nil, fmt.Errorf("no engine found matching prefix: %s", prefix)
666 }
667 slices.SortFunc(candidates, func(a, b engineCandidate) int {
668 switch {
669 case a.id < b.id:
670 return -1
671 case a.id > b.id:
672 return 1
673 default:
674 return 0
675 }
676 })
677 agenticEngineLog.Printf("Found %d engine candidate(s) for prefix %s, using: %s", len(candidates), prefix, candidates[0].id)
678 return candidates[0].engine, nil
679}

Callers 4

TestEngineRegistryFunction · 0.95
getAgenticEngineMethod · 0.80
ResolveMethod · 0.80

Calls 2

PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by 1

TestEngineRegistryFunction · 0.76