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

Method parseCodexToolCallsWithSequence

pkg/workflow/codex_logs.go:95–197  ·  view source on GitHub ↗

parseCodexToolCallsWithSequence extracts tool call information from Codex log lines and returns tool name

(line string, toolCallMap map[string]*ToolCallInfo)

Source from the content-addressed store, hash-verified

93
94// parseCodexToolCallsWithSequence extracts tool call information from Codex log lines and returns tool name
95func (e *CodexEngine) parseCodexToolCallsWithSequence(line string, toolCallMap map[string]*ToolCallInfo) string {
96 trimmedLine := strings.TrimSpace(line)
97
98 // Parse tool calls: "] tool provider.method(...)" (old format)
99 // or "tool provider.method(...)" (new Rust format)
100 var toolName string
101
102 // Try old format first: "] tool provider.method(...)"
103 if strings.Contains(line, "] tool ") && strings.Contains(line, "(") {
104 if match := codexToolCallOldFormat.FindStringSubmatch(line); len(match) > 1 {
105 toolName = strings.TrimSpace(match[1])
106 }
107 }
108
109 // Try new Rust format: "tool provider.method(...)"
110 if toolName == "" && strings.HasPrefix(trimmedLine, "tool ") && strings.Contains(trimmedLine, "(") {
111 if match := codexToolCallNewFormat.FindStringSubmatch(trimmedLine); len(match) > 1 {
112 toolName = strings.TrimSpace(match[1])
113 }
114 }
115
116 if toolName != "" {
117 prettifiedName := PrettifyToolName(toolName)
118
119 // For Codex, format provider.method as provider_method (avoiding colons)
120 if strings.Contains(toolName, ".") {
121 parts := strings.Split(toolName, ".")
122 if len(parts) >= 2 {
123 provider := parts[0]
124 method := strings.Join(parts[1:], "_")
125 prettifiedName = fmt.Sprintf("%s_%s", provider, method)
126 }
127 }
128
129 // Initialize or update tool call info
130 if toolInfo, exists := toolCallMap[prettifiedName]; exists {
131 toolInfo.CallCount++
132 } else {
133 toolCallMap[prettifiedName] = &ToolCallInfo{
134 Name: prettifiedName,
135 CallCount: 1,
136 MaxOutputSize: 0, // Will be updated when output is extracted from result lines
137 MaxDuration: 0, // Will be updated when duration is found
138 }
139 }
140
141 return prettifiedName
142 }
143
144 // Parse exec commands: "] exec command" (old format)
145 // or "exec command in" (new Rust format) - treat as bash calls
146 var execCommand string
147
148 // Try old format: "] exec command in"
149 if strings.Contains(line, "] exec ") {
150 if match := codexExecCommandOldFormat.FindStringSubmatch(line); len(match) > 1 {
151 execCommand = strings.TrimSpace(match[1])
152 }

Callers 1

ParseLogMetricsMethod · 0.95

Calls 3

PrettifyToolNameFunction · 0.85
ShortenCommandFunction · 0.85

Tested by

no test coverage detected