Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Claude CLI-backed agent and begins shifting agent I/O toward writing structured JSON to a response file (instead of stdout), with shared JSON parsing utilities and related prompt/executor updates.
Changes:
- Introduces
ClaudeCLIAgentand registers it in the agent factory. - Adds shared JSON response parsing utilities and refactors Gemini CLI parsing to use them.
- Updates system prompts and execution flow in preparation for response-file based outputs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/mergai/prompts/system_prompt_resolve.md | Changes output instructions to response-file/Write-tool based JSON output. |
| src/mergai/prompts/system_prompt_describe.md | Changes output instructions to response-file/Write-tool based JSON output. |
| src/mergai/app.py | Forces YOLO for describe() to support Claude CLI writing a response file. |
| src/mergai/agents/response_utils.py | Adds shared helpers to extract/parse JSON from agent outputs. |
| src/mergai/agents/gemini_cli.py | Refactors response parsing toward shared utilities and response-file support (currently broken). |
| src/mergai/agents/factory.py | Registers the new claude-cli agent type. |
| src/mergai/agents/claude_cli.py | Adds the Claude CLI agent implementation (stream-json parsing, session reading, optional response-file read). |
| src/mergai/agent_executor.py | Moves prompt files into state dir and starts adding response-file path handling/validation flow (currently broken). |
Comments suppressed due to low confidence (2)
src/mergai/agents/gemini_cli.py:189
- This block still calls
fix_response_json(...), but that helper was removed from this file and is no longer imported. It will crash at runtime; it looks like the intent is to useparse_response_json(result)(or skip parsing if the response was read from a file).
try:
result = fix_response_json(response)
version = self.get_version()
except AgentError as e:
src/mergai/agent_executor.py:191
- A
response_pathis created, but it’s never passed to the agent and the prompt never mentions it, so the updated system prompts (“file path will be provided”) can’t be satisfied. If response-file mode is required, include the path incurrent_promptand pass it to agents that support it (or update the baseAgent.runinterface to acceptresponse_file).
# Create response file path in state_dir (same location as prompt)
# state_dir is typically .cache/mergai which is gitignored
response_filename = self._generate_response_filename()
response_path = self.state_dir / response_filename
current_prompt = (
f"See @{prompt_path} make sure the output is in specified format"
)
error = None
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- gemini_cli.py: Add fallback to stdout parsing when response file is missing or contains invalid JSON, instead of failing immediately - agent_executor.py: Fix retry loop to execute all attempts (was breaking before final attempt). Preserve file instructions across retries by appending error context to base prompt instead of replacing it. - response_utils.py: Add explicit type check for response before calling extract_json_block() to avoid TypeError from re.search on non-strings. Also simplified exception handling to only catch JSONDecodeError.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add ClaudeCLIAgent for integration with Claude Code CLI - Support JSON streaming output and session management - Support both yolo mode and limited write permissions (acceptEdits) - Parse token usage statistics and cost information - Implement file-based response pattern across all agents - Agents write JSON responses to designated files in state_dir - Add response_file and allowed_write_paths parameters to Agent.run() - Provides more reliable JSON parsing than stdout extraction - Extract shared response parsing utilities to response_utils.py - Move JSON block extraction and parsing from gemini_cli.py - Support both direct JSON and markdown-wrapped formats - Update system prompts to instruct agents to write to response files - Improve validation error messages to list modified files
No description provided.