Skip to content

Commit 83154a1

Browse files
authored
Merge pull request #24110 from dvdksn/fix-agent-writer-apikey
fix agent writer apikey
2 parents 4bad018 + 4955de6 commit 83154a1

3 files changed

Lines changed: 41 additions & 21 deletions

File tree

.github/pr-reviewer.yml

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ agents:
4040
## ALWAYS Post a Review
4141
4242
You MUST always post a review via the GitHub API, even if no issues were found.
43-
- If no issues: Post an APPROVE with a brief positive message (e.g., "Documentation looks good! No issues found.")
43+
- If no issues: Post a COMMENT with a brief positive message (e.g., "Documentation looks good! No issues found.")
4444
- If issues found: Post COMMENT or REQUEST_CHANGES with inline comments
4545
4646
Users find it confusing when no review comment is posted - they don't know if the review ran.
4747
48+
IMPORTANT: Never use APPROVE - this agent should provide feedback but not count as approval.
49+
4850
## Posting Reviews with Inline Comments
4951
5052
The drafter returns issues in this format:
@@ -68,10 +70,11 @@ agents:
6870
```
6971
7072
Map your verdict to event:
71-
- "APPROVE" - No issues, or only minor/medium issues (this should be the DEFAULT)
72-
- "COMMENT" - Issues worth noting but not blocking (use this for most findings)
73+
- "COMMENT" - No issues or minor/medium issues (this should be the DEFAULT)
7374
- "REQUEST_CHANGES" - ONLY for critical issues that WILL cause harm
7475
76+
Never use "APPROVE" - this agent provides feedback but should not count as approval.
77+
7578
## When to use REQUEST_CHANGES (RARE - think carefully!)
7679
7780
REQUEST_CHANGES should be used sparingly. Only use it for issues that meet ALL criteria:
@@ -220,25 +223,40 @@ agents:
220223
221224
## Line Number Calculation Algorithm
222225
223-
1. Find the hunk header before your target line: `@@ -X,Y +Z,W @@`
224-
- Z is the line number of the FIRST line after the header in the new file
225-
2. Starting from that first line (which is line Z), count through context (` `) and added (`+`) lines
226-
3. SKIP all deleted (`-`) lines - they don't exist in the new file
227-
4. Your target line number = Z + (number of ` ` and `+` lines before your target)
226+
CRITICAL: Use this exact algorithm to avoid off-by-one errors.
227+
228+
1. Find the hunk header: `@@ -X,Y +Z,W @@`
229+
- **USE THE +Z VALUE** (the number after the +, NOT the -X value)
230+
- Z is the 1-indexed line number where the hunk starts in the NEW file
231+
- Z is ALREADY 1-indexed (first line of file is 1, not 0)
232+
- Example: In `@@ -81,11 +82,12 @@`, use Z=82 (not 81!)
228233
229-
Example:
234+
2. For each line after the hunk header, maintain a running line number starting at Z:
235+
- Context line (starts with ` `) → this is current_line_number, increment counter
236+
- Added line (starts with `+`) → this is current_line_number, increment counter
237+
- Deleted line (starts with `-`) → SKIP, do NOT increment counter
238+
239+
3. When you find your target `+` line, the current_line_number IS the line to report.
240+
241+
Example walkthrough:
230242
```
231-
@@ -10,5 +15,7 @@
232-
context line <- This is line 15 (Z from header, offset 0)
233-
context line <- This is line 16 (Z + 1 context line)
234-
+problematic line <- This is line 17 (Z + 2 lines) ← report as LINE: 17
235-
context line <- This is line 18 (Z + 3 lines)
236-
-deleted line <- SKIP - doesn't exist in new file
237-
context line <- This is line 19 (Z + 4 lines, skipped the -)
243+
@@ -10,5 +15,7 @@ <- Z=15, start counting from 15
244+
context line <- Line 15 (current=15, increment to 16)
245+
context line <- Line 16 (current=16, increment to 17)
246+
+problematic line <- Line 17 (current=17, THIS is your target) ← report LINE: 17
247+
context line <- Line 18 (current=18, increment to 19)
248+
-deleted line <- NOT in new file, current stays at 19
249+
context line <- Line 19 (current=19, increment to 20)
238250
```
239251
240-
IMPORTANT: GitHub uses 1-indexed lines. Do NOT use 0-indexed line numbers.
241-
Do NOT say "around line X" - give the exact line number of the problematic `+` line.
252+
ANOTHER WAY TO THINK ABOUT IT:
253+
Line number = Z + (count of ` ` and `+` lines that appear BEFORE your target in the diff)
254+
- "Before" means: lines that come earlier in the hunk, NOT including the target itself
255+
- First line in hunk: Z + 0 lines before it = Z
256+
- Second line in hunk: Z + 1 line before it = Z + 1
257+
- Third line in hunk: Z + 2 lines before it = Z + 2
258+
259+
IMPORTANT: GitHub expects 1-indexed line numbers. Z is already 1-indexed from the diff.
242260
243261
toolsets:
244262
- type: filesystem

.github/workflows/agent-writer.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
run: npm ci
2626

2727
- name: Run agent
28-
uses: docker/cagent-action@v1.1.4
28+
uses: docker/cagent-action@latest
2929
timeout-minutes: 15
3030
with:
31-
cagent-version: v1.20.3
31+
cagent-version: v1.22.0
3232
agent: ./tech_writer.yml
3333
yolo: true
3434
prompt: |
@@ -64,8 +64,8 @@ jobs:
6464
6565
Keep the PR body brief and practical. Don't over-explain or add sections
6666
that aren't needed.
67+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
6768
env:
68-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
6969
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7070

7171
- name: Check for changes

.github/workflows/pr-review.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
if: steps.membership.outputs.is_member == 'true'
8989
uses: docker/cagent-action@latest
9090
with:
91+
cagent-version: v1.22.0
9192
agent: .github/pr-reviewer.yml
9293
prompt: |
9394
Review PR #${{ github.event.pull_request.number }}
@@ -205,6 +206,7 @@ jobs:
205206
if: steps.membership.outputs.is_member == 'true'
206207
uses: docker/cagent-action@latest
207208
with:
209+
cagent-version: v1.22.0
208210
agent: .github/pr-reviewer.yml
209211
prompt: |
210212
Review PR #${{ github.event.issue.number }}

0 commit comments

Comments
 (0)