@@ -9,8 +9,11 @@ import (
99 "time"
1010
1111 "github.com/githubnext/gh-aw/pkg/constants"
12+ "github.com/githubnext/gh-aw/pkg/logger"
1213)
1314
15+ var codexEngineLog = logger .New ("workflow:codex_engine" )
16+
1417// Pre-compiled regexes for Codex log parsing (performance optimization)
1518var (
1619 codexToolCallOldFormat = regexp .MustCompile (`\] tool ([^(]+)\(` )
@@ -43,6 +46,7 @@ func NewCodexEngine() *CodexEngine {
4346}
4447
4548func (e * CodexEngine ) GetInstallationSteps (workflowData * WorkflowData ) []GitHubActionStep {
49+ codexEngineLog .Printf ("Generating installation steps for Codex engine: workflow=%s" , workflowData .Name )
4650 var steps []GitHubActionStep
4751
4852 // Add secret validation step - Codex supports both CODEX_API_KEY and OPENAI_API_KEY as fallback
@@ -76,6 +80,13 @@ func (e *CodexEngine) GetDeclaredOutputFiles() []string {
7680
7781// GetExecutionSteps returns the GitHub Actions steps for executing Codex
7882func (e * CodexEngine ) GetExecutionSteps (workflowData * WorkflowData , logFile string ) []GitHubActionStep {
83+ model := ""
84+ if workflowData .EngineConfig != nil && workflowData .EngineConfig .Model != "" {
85+ model = workflowData .EngineConfig .Model
86+ }
87+ codexEngineLog .Printf ("Building Codex execution steps: workflow=%s, model=%s, has_agent_file=%v" ,
88+ workflowData .Name , model , workflowData .AgentFile != "" )
89+
7990 // Handle custom steps if they exist in engine config
8091 steps := InjectCustomEngineSteps (workflowData , e .convertStepToYAML )
8192
@@ -269,6 +280,10 @@ func (e *CodexEngine) renderShellEnvironmentPolicy(yaml *strings.Builder, tools
269280}
270281
271282func (e * CodexEngine ) RenderMCPConfig (yaml * strings.Builder , tools map [string ]any , mcpTools []string , workflowData * WorkflowData ) {
283+ if codexEngineLog .Enabled () {
284+ codexEngineLog .Printf ("Rendering MCP config for Codex: mcp_tools=%v, tool_count=%d" , mcpTools , len (tools ))
285+ }
286+
272287 yaml .WriteString (" cat > /tmp/gh-aw/mcp-config/config.toml << EOF\n " )
273288
274289 // Add history configuration to disable persistence
@@ -325,6 +340,8 @@ func (e *CodexEngine) RenderMCPConfig(yaml *strings.Builder, tools map[string]an
325340
326341// ParseLogMetrics implements engine-specific log parsing for Codex
327342func (e * CodexEngine ) ParseLogMetrics (logContent string , verbose bool ) LogMetrics {
343+ codexEngineLog .Printf ("Parsing Codex log metrics: log_size=%d bytes, lines=%d" , len (logContent ), len (strings .Split (logContent , "\n " )))
344+
328345 var metrics LogMetrics
329346 var totalTokenUsage int
330347
@@ -395,6 +412,9 @@ func (e *CodexEngine) ParseLogMetrics(logContent string, verbose bool) LogMetric
395412 metrics .Errors = CountErrorsAndWarningsWithPatterns (logContent , errorPatterns )
396413 }
397414
415+ codexEngineLog .Printf ("Parsed Codex metrics: turns=%d, token_usage=%d, tool_calls=%d, errors=%d" ,
416+ metrics .Turns , metrics .TokenUsage , len (metrics .ToolCalls ), len (metrics .Errors ))
417+
398418 return metrics
399419}
400420
0 commit comments