Skip to content

Commit fc60e34

Browse files
CopilotdsymeCopilot
authored
Add DefaultEngine constant and replace semantic-default uses of CopilotEngine (#24554)
* Initial plan * Define DefaultEngine constant and update usages from CopilotEngine where used as default Agent-Logs-Url: https://github.com/github/gh-aw/sessions/847c0feb-cf66-4748-81c1-dd045e07daec Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com> * Update pkg/workflow/agentic_engine.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update pkg/cli/add_command.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com> Co-authored-by: Don Syme <dsyme@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b361d25 commit fc60e34

5 files changed

Lines changed: 16 additions & 8 deletions

File tree

pkg/cli/add_command.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,9 @@ func addWorkflowWithTracking(resolved *ResolvedWorkflow, tracker *FileTracker, o
395395

396396
// Handle engine override - add/update the engine field in frontmatter before source so
397397
// the engine declaration appears above the source field in the final file.
398-
// Copilot is the default engine, so we skip adding it to avoid unnecessary noise and
399-
// prevent conflicts during later workflow updates.
400-
if opts.EngineOverride != "" && opts.EngineOverride != string(constants.CopilotEngine) {
398+
// The default engine is omitted to avoid unnecessary noise and prevent conflicts during
399+
// later workflow updates.
400+
if opts.EngineOverride != "" && opts.EngineOverride != string(constants.DefaultEngine) {
401401
updatedContent, err := addEngineToWorkflow(content, opts.EngineOverride)
402402
if err != nil {
403403
if opts.Verbose {

pkg/cli/add_interactive_engine.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (c *AddInteractiveConfig) selectAIEngineAndKey() error {
2323

2424
// Determine default engine based on existing secrets, workflow preference, then environment
2525
// Priority order: flag override > existing secrets > workflow frontmatter > environment > default
26-
defaultEngine := string(constants.CopilotEngine)
26+
defaultEngine := string(constants.DefaultEngine)
2727
workflowSpecifiedEngine := ""
2828

2929
// Check if workflow specifies a preferred engine in frontmatter
@@ -52,12 +52,12 @@ func (c *AddInteractiveConfig) selectAIEngineAndKey() error {
5252
}
5353

5454
// Priority 2: If no existing secret found, use workflow frontmatter preference
55-
if defaultEngine == string(constants.CopilotEngine) && workflowSpecifiedEngine != "" {
55+
if defaultEngine == string(constants.DefaultEngine) && workflowSpecifiedEngine != "" {
5656
defaultEngine = workflowSpecifiedEngine
5757
}
5858

5959
// Priority 3: Check environment variables if no existing secret or workflow preference found
60-
if defaultEngine == string(constants.CopilotEngine) && workflowSpecifiedEngine == "" {
60+
if defaultEngine == string(constants.DefaultEngine) && workflowSpecifiedEngine == "" {
6161
for _, opt := range constants.EngineOptions {
6262
envVar := opt.SecretName
6363
if opt.EnvVarName != "" {

pkg/constants/constants_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ func TestAgenticEngines(t *testing.T) {
107107
if string(GeminiEngine) != "gemini" {
108108
t.Errorf("GeminiEngine constant = %q, want %q", GeminiEngine, "gemini")
109109
}
110+
if DefaultEngine != CopilotEngine {
111+
t.Errorf("DefaultEngine = %q, want CopilotEngine (%q)", DefaultEngine, CopilotEngine)
112+
}
110113
}
111114

112115
func TestDefaultGitHubTools(t *testing.T) {

pkg/constants/engine_constants.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const (
2020
CodexEngine EngineName = "codex"
2121
// GeminiEngine is the Google Gemini engine identifier
2222
GeminiEngine EngineName = "gemini"
23+
24+
// DefaultEngine is the default agentic engine used when no engine is explicitly specified.
25+
// Currently defaults to CopilotEngine.
26+
DefaultEngine EngineName = CopilotEngine
2327
)
2428

2529
// AgenticEngines lists all supported agentic engine names.

pkg/workflow/agentic_engine.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strings"
77
"sync"
88

9+
"github.com/github/gh-aw/pkg/constants"
910
"github.com/github/gh-aw/pkg/logger"
1011
)
1112

@@ -455,9 +456,9 @@ func (r *EngineRegistry) IsValidEngine(id string) bool {
455456
return exists
456457
}
457458

458-
// GetDefaultEngine returns the default engine (Copilot)
459+
// GetDefaultEngine returns the default engine configured by constants.DefaultEngine
459460
func (r *EngineRegistry) GetDefaultEngine() CodingAgentEngine {
460-
return r.engines["copilot"]
461+
return r.engines[string(constants.DefaultEngine)]
461462
}
462463

463464
// GetEngineByPrefix returns an engine that matches the given prefix

0 commit comments

Comments
 (0)