Skip to content

Commit cfdf409

Browse files
committed
improved promt
1 parent 3841ea0 commit cfdf409

1 file changed

Lines changed: 63 additions & 14 deletions

File tree

app_dart/lib/src/request_handlers/analyze_logs.dart

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,32 +106,81 @@ final class AnalyzeLogs extends ApiRequestHandler {
106106
if (stdoutLogs.isEmpty) {
107107
throw NotFoundException('Logs Not Found for BuildId: $buildId');
108108
}
109-
String? githubUrl;
110-
for (final tag in build.tags) {
111-
if (tag.key == 'github_link') {
112-
githubUrl = tag.value;
113-
}
109+
String githubUrl;
110+
final githubLinkTag = build.tags.firstWhereOrNull(
111+
(tag) => tag.key == 'github_link',
112+
);
113+
if (githubLinkTag == null) {
114+
log.warn('Could not find github_link tag in build $buildId');
115+
githubUrl = 'http://github.com/$owner/$repo/pull/$prNumber';
116+
} else {
117+
githubUrl = githubLinkTag.value;
114118
}
115119

116120
// 4. Feed text to genkit.
117121
final prompt =
118-
'''
119-
You are a Senior Infrastructure Engineer specializing in the Flutter CI ecosystem.
122+
'''You are a Senior Infrastructure Engineer specializing in the Flutter CI ecosystem.
123+
I will provide you with a link to github pull request and the logs of a failed build step in a LUCI build associated with that change.
124+
125+
## Your task
120126
121-
I will provide you with github pull request and the logs of a failed build step in a LUCI build associated with that change.
127+
### 1. Identify the specific test or command that failed.
122128
123-
Your task is:
129+
### 2. Extract the error message or crash log.
124130
125-
1. Identify the specific test or command that failed.
131+
### 3. Explain the most likely root cause in simple terms.
126132
127-
2. Extract the error message or crash log.
133+
### 4. Suggest a potential fix if possible.
128134
129-
3. Explain the most likely root cause in simple terms.
135+
## Workflow
130136
131-
4. Suggest a potential fix if possible.
137+
### 1. Analyze Raw Log Output
132138
133-
${githubUrl != null && githubUrl.isNotEmpty ? 'Link to GitHub Pull Request: $githubUrl' : ''}
139+
Analyze the raw log output for failure details. Do not skim the output; check the entire log. **The description of findings should include specific details for the failures (e.g., unformatted files, specific test names), not just the top-level command that failed.**
134140
141+
### 2. Look for Failure Patterns
142+
143+
#### Pattern A: Error Blocks (e.g., Linux Analyze)
144+
Search for blocks starting with `╡ERROR #`.
145+
Example:
146+
```
147+
╔═╡ERROR #1╞════════════════════════════════════════════════════════════════════
148+
║ Command: bin/cache/dart-sdk/bin/dart --enable-asserts /b/s/w/ir/x/w/flutter/dev/bots/analyze_snippet_code.dart --verbose
149+
║ Command exited with exit code 255 but expected zero exit code.
150+
║ Working directory: /b/s/w/ir/x/w/flutter
151+
╚═══════════════════════════════════════════════════════════════════════════════
152+
```
153+
154+
#### Pattern B: Task Result JSON
155+
Search for "Task result:" followed by a JSON object.
156+
Example:
157+
```json
158+
Task result:
159+
{
160+
"success": false,
161+
"reason": "Task failed: PathNotFoundException: Cannot open file..."
162+
}
163+
```
164+
165+
#### Pattern C: Failing Tests List
166+
For general Dart tests, look for a list at the end of the log starting with "Failing tests:".
167+
Example:
168+
```
169+
Failing tests:
170+
test/general.shard/cache_test.dart: FontSubset artifacts for all platforms on arm64 hosts
171+
test/general.shard/cache_test.dart: FontSubset artifacts on arm64 linux
172+
```
173+
174+
#### Pattern D: Build Failures
175+
For build failures (e.g., engine tests failing at compile time), look for the following indicators in the logs or API summaries:
176+
- Lines starting with `FAILED:` (indicates a Ninja target failed).
177+
- Compiler error messages (e.g., `error:`, `fatal error:`).
178+
- Linker error messages (e.g., `undefined reference to`).
179+
- Summary messages in the check-runs API output like `1 build failed: [<build_name>]`.
180+
181+
## Links
182+
183+
Link to GitHub Pull Request: $githubUrl
135184
Links to Logs: ${stdoutLogs.join('\n')}
136185
''';
137186

0 commit comments

Comments
 (0)