You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/agents/code-review-and-fix.agent.md
+57-42Lines changed: 57 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
description: "Review PRs, files, or directories in opentelemetry-java-instrumentation. Apply safe fixes directly; report unfixable issues in the summary only."
2
+
description: "Review PRs, files, or directories in opentelemetry-java-instrumentation. Apply safe fixes directly, record concise reasons for each applied change, and report unfixable issues in the requested output format."
3
3
tools: [read, edit, execute, search]
4
4
---
5
5
@@ -9,9 +9,13 @@ Primary responsibilities:
9
9
10
10
- Review code against repository standards and established patterns.
Issues that cannot be fixed are reported only in the final summary table.
14
-
- Produce a compact summary table of fixed and unresolved items at the end.
14
+
Issues that cannot be fixed are reported only in the final output.
15
+
- Produce only the output format requested by the caller. Do not assume or add a default output format.
16
+
- Use only the tools actually exposed by the runtime. Do not assume helper or companion tools exist.
17
+
- When a command-execution step fails for tool-related reasons, first re-evaluate the declared tools and retry with a different valid execution strategy before concluding that the environment cannot complete the task.
18
+
- Distinguish between command failure and inability to observe command completion or final status. Do not collapse these into the same explanation.
15
19
16
20
Do not stop until all in-scope files are reviewed and fixed where possible.
17
21
@@ -99,8 +103,14 @@ For each file in scope:
99
103
5. For each issue found, use this decision order:
100
104
- Fix now if deterministic, low-risk, and verifiable by local reasoning or targeted checks.
101
105
- If uncertain, potentially breaking, or requiring product/design intent, do not fix — record
102
-
the issue for the summary table instead.
106
+
the issue for the final output instead.
103
107
-**Do not insert any inline comments into source files.**
108
+
6. For every applied fix, record enough information to explain it later:
109
+
- file path
110
+
- category
111
+
- concise description of the change
112
+
- concise reason grounded in the relevant repository rule or review guideline
113
+
- first relevant line number when the caller asks for line-oriented output
104
114
105
115
Auto-fix boundaries:
106
116
@@ -206,6 +216,10 @@ Auto-fix boundaries:
206
216
method actually returns `null`, instead of adding a null guard in the caller/callee.
207
217
When justifying `@Nullable` on a parameter, cite the concrete null-passing caller or
208
218
upstream contract. Do not justify it merely because the method guards against null.
219
+
For every nullability change you report, explain the concrete runtime null source or
220
+
flow: which caller can pass `null`, which branch returns `null`, or which optional
221
+
value may be absent. Do not use abstract justifications such as "nullable contract"
222
+
unless you also name that concrete null-producing path.
209
223
**Exception — test files**: do not add `@Nullable` in test code.
210
224
If a PR adds `@Nullable` to test files, flag it for removal.
211
225
**Exception**: when the method overrides an interface from the upstream OpenTelemetry
@@ -231,7 +245,7 @@ Auto-fix boundaries:
231
245
add the correctly named/shaped method with the implementation, deprecate the old method
232
246
to delegate to the new one, and add a `@deprecated` Javadoc tag naming the replacement.
233
247
For stable modules, annotate instead: the fix requires a broader compatibility decision.
234
-
- Do not auto-fix (report in summary instead):
248
+
- Do not auto-fix (report in the final output instead):
235
249
- missing `testExperimental` task — when experimental flags are set unconditionally
236
250
on all test tasks instead of being isolated in a dedicated task
237
251
- behavior-changing logic without clear intent
@@ -244,20 +258,38 @@ Auto-fix boundaries:
244
258
fix these, because on modern JDKs these are typically cached at the call site rather
245
259
than allocated on every invocation
246
260
247
-
Comment formatting rules:
261
+
Output content rules:
248
262
249
-
-**File column**: use only the simple class name without the `.java` extension
250
-
and at most one line number (e.g., `FooClient:42`). For multiple locations,
251
-
list only the first line and note the others in the Note column
252
-
(e.g., Note: "… also lines 77, 95").
253
-
- Include reason for non-fix and, when possible, a concrete next action.
263
+
-Include a reason for every non-fix and, when possible, a concrete next action.
264
+
- When the caller requests structured output, use repository-relative file paths.
265
+
- When the caller requests line-oriented output, use the first relevant changed line as the line hint.
266
+
- When writing structured output to a file, write only the requested payload. Do not wrap it in Markdown fences,
267
+
add headings, or include extra commentary before or after it.
254
268
255
269
### Phase 4: Validate and Report
256
270
257
271
**All Gradle commands in this phase must use timeout `0` (no timeout). Builds and tests in
258
272
this repository can take several minutes — never treat slow output as a hang. Always wait
259
273
for completion.**
260
274
275
+
**Validation must be strictly serial. Never start more than one Gradle command at a time**
276
+
whether through separate tool calls, parallel tool requests, or any mode that leaves an
277
+
earlier Gradle invocation running in the background. Do not launch the next Gradle command
278
+
until the previous one has definitively completed and you have observed its final exit
279
+
status. If a prior run may still be active, first wait for it or confirm its completion
280
+
before proceeding.
281
+
282
+
If a command-execution attempt fails for tool-related reasons, follow this recovery loop before
283
+
reporting a limitation:
284
+
285
+
1. Re-check the tools declared for this agent and the runtime behavior you have actually observed.
286
+
2. Retry using a different valid execution strategy that does not depend on the failed assumption.
287
+
3. Only report a validation limitation after at least one concrete alternate approach has also failed
288
+
or no alternate approach exists in the declared tool set.
289
+
4. If validation still cannot be completed, the summary and any unresolved item must name the
290
+
attempted command or validation step and say whether it failed or whether completion or final
291
+
status could not be confirmed.
292
+
261
293
**Never pipe Gradle output through `tail`, `head`, `grep`, or any other command** (e.g.,
262
294
`./gradlew :foo:check 2>&1 | tail -30`). Piping masks the Gradle exit code because the
263
295
shell reports the exit code of the last pipe segment, not Gradle. A failing build will
@@ -273,6 +305,9 @@ Execute these steps strictly in order — do not reorder:
0 commit comments