Skip to content

Commit ece58e2

Browse files
committed
fix: strengthen RLM prompt to prevent hallucinated commands
1 parent 3bb87c3 commit ece58e2

File tree

3 files changed

+30
-38
lines changed

3 files changed

+30
-38
lines changed

npx/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "asyncreview",
3-
"version": "0.5.7",
3+
"version": "0.5.8",
44
"description": "AI-powered GitHub PR/Issue reviews from the command line",
55
"type": "module",
66
"bin": {

npx/python/cli/virtual_runner.py

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,65 +24,57 @@
2424

2525
# Tool usage instructions for the model - simplified and clear
2626
AGENTIC_TOOLS_PROMPT = """
27-
## REPOSITORY ACCESS COMMANDS
27+
## AVAILABLE COMMANDS (USE ONLY THESE!)
2828
29-
You can access ANY file in the repository (not just the diff). Use these commands:
29+
⚠️ **ONLY these 3 commands exist. Any other command will NOT work:**
3030
31-
### STEP 1: Find file paths with SEARCH_CODE
31+
| Command | Purpose | Example |
32+
|---------|---------|---------|
33+
| `SEARCH_CODE:term` | Find files by name/content | `print("SEARCH_CODE:rlm.py")` |
34+
| `FETCH_FILE:path` | Read file contents | `print("FETCH_FILE:dspy/predict/rlm.py")` |
35+
| `LIST_DIR:path` | List directory contents | `print("LIST_DIR:dspy/predict")` |
36+
37+
### ❌ FORBIDDEN - These commands DO NOT EXIST:
38+
- `READ_FILE` - WRONG! Use `FETCH_FILE` instead
39+
- `READ_CODE` - WRONG! Use `FETCH_FILE` instead
40+
- `GET_FILE` - WRONG! Use `FETCH_FILE` instead
41+
- `LIST_FILES` - WRONG! Use `LIST_DIR` instead
42+
- `open()` / `os.path` - WRONG! Won't work in sandbox
43+
- Any other command not listed above
44+
45+
---
46+
47+
### SEARCH_CODE - Find files by name or content
3248
```python
33-
# CORRECT - no quotes around the search term after the colon
3449
print("SEARCH_CODE:rlm.py")
3550
print("SEARCH_CODE:enable_tool_optimization")
36-
print("SEARCH_CODE:llm_query_batched")
37-
38-
# WRONG - do NOT add extra quotes or parentheses
39-
# print("SEARCH_CODE:rlm.py")") # ❌ Extra quote/paren
40-
# print("SEARCH_CODE:'rlm.py'") # ❌ Quoted search term
4151
```
4252
Results appear in `search_results` on your NEXT step.
4353
44-
### STEP 2: Fetch files with FETCH_FILE
54+
### FETCH_FILE - Read file contents (NOT read_file, NOT read_code!)
4555
```python
46-
# CORRECT - exact path, no extra quotes
4756
print("FETCH_FILE:dspy/predict/rlm.py")
4857
print("FETCH_FILE:tests/predict/test_rlm.py")
49-
50-
# WRONG - do NOT add extra quotes or parentheses
51-
# print("FETCH_FILE:dspy/predict/rlm.py")") # ❌ Extra quote/paren
5258
```
5359
Content appears in `repo_files['dspy/predict/rlm.py']` on your NEXT step.
5460
55-
### STEP 3: List directories with LIST_DIR
61+
### LIST_DIR - List directory contents
5662
```python
57-
# CORRECT - use LIST_DIR (NOT LIST_FILES!)
5863
print("LIST_DIR:dspy/predict")
59-
print("LIST_DIR:dspy/predict/") # trailing slash is OK
6064
print("LIST_DIR:tests")
61-
62-
# WRONG - do NOT use these non-existent commands
63-
# print("LIST_FILES:dspy/predict") # ❌ No such command as LIST_FILES
64-
# print("LIST_DIRECTORY:dspy/predict") # ❌ Wrong name
65-
# print("LS:dspy/predict") # ❌ Not supported
6665
```
67-
Entries appear in `repo_dirs['dspy/predict']` on your NEXT step as a list of dicts with 'path', 'type', and 'size'.
66+
Entries appear in `repo_dirs['dspy/predict']` on your NEXT step.
6867
69-
### IMPORTANT NOTES:
70-
- Commands print EXACTLY as shown, the system intercepts them
71-
- The command is `LIST_DIR` not `LIST_FILES` or `LIST_DIRECTORY`
72-
- Do NOT try os.walk() or open() - those won't work
73-
- Data becomes available on your NEXT step
74-
- Check `repo_files`, `repo_dirs`, `search_results` dicts
75-
- SYNTAX: Make sure print statements are properly closed with exactly ONE `")`
76-
77-
### WORKFLOW EXAMPLE (finding if rlm.py contains X):
78-
Step 1: `print("LIST_DIR:dspy/predict")` → get directory contents
79-
Step 2: Check `repo_dirs['dspy/predict']` for file list, then `print("FETCH_FILE:dspy/predict/rlm.py")`
80-
Step 3: Check `repo_files['dspy/predict/rlm.py']` for content
68+
### WORKFLOW:
69+
1. `print("SEARCH_CODE:filename")` → find paths
70+
2. `print("FETCH_FILE:path/to/file.py")` → read content
71+
3. Check `repo_files['path/to/file.py']` in next step
8172
"""
8273

8374

8475

8576

77+
8678
class VirtualReviewRunner:
8779
"""Run RLM code reviews on GitHub PRs without a local repository.
8880

0 commit comments

Comments
 (0)