Conversation
- Updated `JULES_SYSTEM_PROMPT` in `src/mycoder/triage_agent.py` to match the new "Goat Principle" and output specifications.
- Adapted prompt variables for Python format (e.g., `!{echo $VAR}` -> `{var}`).
- Enhanced JSON parsing in `triage_issues_with_llm` to strictly extract the JSON array using `re.search` (handling potential extra text like generated shell commands).
- Reformatted code with Black.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
🤖 Hi @milhy545, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
Summary of ChangesHello @milhy545, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Jules triage agent by refining its system prompt and improving its ability to parse responses from large language models. The updates aim to make the agent more robust in handling varied LLM outputs and clearer in its instructions, particularly regarding the generation of shell commands and adherence to the "Goat Principle." Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the system prompt for the Jules triage agent and improves the JSON parsing logic to handle mixed-content responses from the LLM, aiming to have the LLM generate a shell command in addition to JSON output. However, the new prompt instructions introduce a significant security risk by asking the LLM to generate shell commands using untrusted data. Furthermore, the current regex-based parsing logic is fragile due to its greedy pattern (.*), which can lead to JSONDecodeError and is susceptible to denial-of-service attacks via crafted input. It's recommended to remove shell command generation from the prompt and implement a more robust JSON extraction method.
| Final Command Construction | ||
| Generate the final shell command to write the JSON to the environment variable. Ensure the JSON string is single-quoted to handle special characters correctly. """ |
There was a problem hiding this comment.
The updated system prompt instructs the LLM to generate a shell command that includes triaged issue data. This is a dangerous pattern because the issue data (e.g., explanations) is untrusted and can be crafted by an attacker to perform command injection. The prompt's instruction to 'Ensure the JSON string is single-quoted' is insufficient to prevent injection, as an attacker can include a single quote in the input to close the string and append malicious commands (e.g., '; rm -rf /; '). While the current script attempts to strip this command using a regex, the inclusion of this instruction in the prompt is a significant security risk, especially if the prompt is reused in contexts where the output is executed or if the parsing logic fails.
| json_match = re.search(r"\[.*\]", content, re.DOTALL) | ||
| if json_match: | ||
| content = json_match.group(0) |
There was a problem hiding this comment.
The current parsing logic uses a greedy regular expression r"[.*]" which can lead to JSONDecodeError and is susceptible to denial-of-service attacks. If the LLM's response contains brackets outside the intended JSON array, this regex will incorrectly capture extra text, causing json.loads() to fail. An attacker could exploit this by crafting input with brackets to disrupt the triage agent's parsing. A more robust, non-greedy approach is recommended to accurately extract the JSON array.
# Use a non-greedy match to find the first JSON-like array structure
json_match = re.search(r"[\s*\{.*?\}\s*]", content, re.DOTALL)| import logging | ||
| import os | ||
| import sys | ||
| import re |
There was a problem hiding this comment.
- Updated `tests/unit/test_triage_agent.py` to expect "Final Command Construction" in the prompt, resolving the CI failure in `test_prompt_construction`. - Verified that the updated prompt logic aligns with the new requirements. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Updated the system prompt for the Jules triage agent as requested. The prompt now emphasizes the "Goat Principle" (Functionality > Aesthetics) and includes instructions for generating a final shell command.
To support the new prompt instructions (which request non-JSON output alongside the JSON array), the
triage_issues_with_llmfunction was updated to use regular expressions (re.search(r'\[.*\]', ...)withre.DOTALL) to extract the JSON payload from the LLM's response, making the agent more robust against mixed-content responses.Verified syntax and formatting via
py_compileandblack.PR created automatically by Jules for task 951697047889080792 started by @milhy545