Skip to content

Commit d1dd000

Browse files
committed
Fix: agent sample
1 parent 6eb2a57 commit d1dd000

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

samples/github-helper-agent/main.py

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ async def make_graph():
9292
async with ClientSession(read, write) as session:
9393
tools = await load_mcp_tools(session)
9494

95-
model = ChatAnthropic(model="claude-3-5-sonnet-latest")
95+
model = ChatAnthropic(
96+
model="claude-3-7-sonnet-20250219",
97+
temperature=0.2,
98+
)
9699

97100
# Create the conversation history
98101
async def hydrate_history(input: PullRequestInfo) -> GraphState:
@@ -195,40 +198,36 @@ def pr_prompt(state: GraphState) -> GraphState:
195198
in_reply_to = state.get("in_reply_to")
196199
if in_reply_to:
197200
label = f"{AI_GENERATED_LABEL} [{in_reply_to}]_\n"
198-
command_message = f"The CURRENT command is '{state['command']}' from review comment id #{in_reply_to}. EXECUTE the CURRENT command and provide detailed feedback."
201+
command_message = f"The CURRENT command is '{state['command']}'. EXECUTE the CURRENT command in_reply_to #{in_reply_to} and provide detailed feedback."
199202
else:
200203
label = f"{AI_GENERATED_LABEL}_\n"
201204
command_message = f"The CURRENT command is '{state['command']}. EXECUTE the CURRENT command and provide detailed feedback."
202205

203206
"""Create a prompt that incorporates PR data."""
204-
system_message = f"""You are a professional developer with experience in code reviews and GitHub pull requests.
205-
You are working with repo: {state["owner"]}/{state["repo"]}, PR #{state["pull_number"]}.
206-
207-
IMPORTANT INSTRUCTIONS:
208-
1. ALWAYS get the contents of the changed files in the current PR
209-
2. ALWAYS use the contents of the changed files as context when replying to a user command.
210-
3. ALWAYS start your responses with "{label}" to properly tag your comments.
211-
4. When you reply to a comment, make sure to address the specific request.
212-
5. When reviewing code, be thorough but constructive - point out both issues and good practices.
213-
6. You MUST use the available tools to post your response as a PR comment or perform the PR code review.
214-
215-
COMMANDS YOU SHOULD UNDERSTAND:
216-
- "review": Perform a full code review of the PR
217-
- "summarize": Summarize the changes in the PR
218-
- "explain <file>": Explain what changes were made to a specific file
219-
- "suggest": Suggest improvements to the code
220-
- "test": Suggest appropriate tests for the changes
221-
222-
WORKFLOW:
223-
1. Gather the contents of the changed files for the current PR
224-
2. Analyze the available PR data and understand what the user is asking for
225-
3. Use the appropriate tools to gather any additional information needed
226-
4. Prepare your response based on the request
227-
5. [IMPORTANT] Based on the user's command:
228-
- if the command has a review comment id, REPLY TO THE REVIEW COMMENT WITH THE SPECIFIED ID using tool add_pull_request_review_comment
229-
- else POST PULL REQUEST REVIEW using tool create_pull_request_review
230-
231-
Remember: The user wants specific, actionable feedback and help with their code.
207+
system_message = f"""You are a professional developer and GitHub reviewer.
208+
209+
You are reviewing Pull Request #{state["pull_number"]} in repo {state["owner"]}/{state["repo"]}.
210+
211+
YOU MUST FOLLOW THESE RULES WITHOUT EXCEPTION:
212+
213+
1. ALWAYS get the contents of the changed files BEFORE writing any response.
214+
2. ALWAYS use the contents of the changed files as context.
215+
3. ALWAYS start ALL responses with exactly: "{label}" (no exceptions).
216+
4. ALWAYS POST your responses to GitHub via available tools:
217+
- If `in_reply_to` is provided, REPLY to the existing review comment ID {in_reply_to} using `add_pull_request_review_comment`.
218+
- If no `in_reply_to` or previous tool call failed, POST a new review using `create_pull_request_review`.
219+
220+
COMMANDS you can receive:
221+
- "review": Do a complete code review, pointing out issues and good practices.
222+
- "summarize": Summarize the PR changes.
223+
- "explain <file>": Explain changes made to a specific file.
224+
- "suggest": Suggest improvements.
225+
- "test": Suggest tests for the changes.
226+
227+
IMPORTANT:
228+
- Do not make assumptions.
229+
- Do not skip steps.
230+
- If you cannot complete the command for any reason, you MUST reply with an error comment on GitHub.
232231
233232
{command_message}
234233
"""

samples/github-helper-agent/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "github-helper-agent"
3-
version = "0.0.8"
3+
version = "0.0.10"
44
description = "An automated agent that reviews GitHub pull requests and provides feedback"
55
authors = [{ name = "Cristi Pufu", email = "[email protected]" }]
66
dependencies = [

0 commit comments

Comments
 (0)