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

Function findAgentOutputFile

pkg/cli/logs_utils.go:94–116  ·  view source on GitHub ↗

findAgentOutputFile searches for a file named agent_output.json within the logDir tree. Returns the first path found (depth-first) and a boolean indicating success.

(logDir string)

Source from the content-addressed store, hash-verified

92// findAgentOutputFile searches for a file named agent_output.json within the logDir tree.
93// Returns the first path found (depth-first) and a boolean indicating success.
94func findAgentOutputFile(logDir string) (string, bool) {
95 var foundPath string
96 if walkErr := filepath.Walk(logDir, func(path string, info os.FileInfo, err error) error {
97 if err != nil {
98 logsUtilsLog.Printf("walk error at %s: %v", path, err)
99 return nil
100 }
101 if info == nil {
102 return nil
103 }
104 if !info.IsDir() && strings.EqualFold(info.Name(), constants.AgentOutputArtifactName) {
105 foundPath = path
106 return errWalkStop
107 }
108 return nil
109 }); walkErr != nil && !errors.Is(walkErr, errWalkStop) {
110 fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("filesystem error walking %s: %v", logDir, walkErr)))
111 }
112 if foundPath == "" {
113 return "", false
114 }
115 return foundPath, true
116}
117
118// findAgentLogFile searches for agent logs within the logDir.
119// It uses engine.GetLogFileForParsing() to determine which log file to use:

Callers 4

extractLogMetricsFunction · 0.85
extractNoopsFromRunFunction · 0.85

Calls 2

FormatWarningMessageFunction · 0.92
PrintfMethod · 0.45

Tested by

no test coverage detected