Update MCP response to improve agent's answers - #319
Conversation
At the moment agent doesn't cite the sources which were used to answer the queries. Also in case of access issues, agent should give that as hint to the user. Update the mcp tool descriptions and skills with the same Signed-off-by: vinamra28 <vinjain@redhat.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
📝 WalkthroughWalkthroughThe MCP tool descriptions and unstructured-data skill guidance now explain access-related empty results and require citations that use ChangesCitation and access guidance
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/mcp/tools/get_chunks.go`:
- Around line 48-50: Make citation guidance conditional on verified
source-bearing success: in internal/mcp/tools/get_chunks.go lines 48-50, require
a citation only when the successful result includes a file_id and keep error
responses citation-free; in internal/mcp/tools/get_processed_document.go lines
46-47, do not treat an echoed request file_id as proof of successful retrieval;
in skills/unstructured-data-mcp-skill.md lines 15-17, require citations only
when source content and a returned file_id are both available.
- Around line 48-49: Update the empty-result guidance in
internal/mcp/tools/get_chunks.go lines 48-49 to present missing access as one
possible cause, not the default explanation or an automatic request for access;
retain the requirement to cite file_id and provide Google Drive URLs in the
specified format. Apply the same uncertainty guidance in
skills/unstructured-data-mcp-skill.md lines 14-17, correcting the grammar and
capitalizing “Google Drive” and “URL”.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7735716f-1776-49b3-a2bd-8f70dd1b3d7b
📒 Files selected for processing (3)
internal/mcp/tools/get_chunks.gointernal/mcp/tools/get_processed_document.goskills/unstructured-data-mcp-skill.md
| If no matching chunks are found, it could be because the user does not have access to the original source file — suggest they request access to it. | ||
| Always cite sources: include file_id in your answer so the user can visit the source file. For Google Drive sources, provide the URL as https://drive.google.com/file/d/<file_id>/view. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use neutral guidance for empty search results.
The tools return no access-status signal. An empty result can mean no relevant match or missing source access, so the agent cannot identify access as the cause.
internal/mcp/tools/get_chunks.go#L48-L49: Present missing access as one possible cause instead of defaulting to an access request.skills/unstructured-data-mcp-skill.md#L14-L17: State the same uncertainty, correct the grammar, and capitalizeGoogle DriveandURL.
📍 Affects 2 files
internal/mcp/tools/get_chunks.go#L48-L49(this comment)skills/unstructured-data-mcp-skill.md#L14-L17
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/mcp/tools/get_chunks.go` around lines 48 - 49, Update the
empty-result guidance in internal/mcp/tools/get_chunks.go lines 48-49 to present
missing access as one possible cause, not the default explanation or an
automatic request for access; retain the requirement to cite file_id and provide
Google Drive URLs in the specified format. Apply the same uncertainty guidance
in skills/unstructured-data-mcp-skill.md lines 14-17, correcting the grammar and
capitalizing “Google Drive” and “URL”.
Source: Linters/SAST tools
| If no matching chunks are found, it could be because the user does not have access to the original source file — suggest they request access to it. | ||
| Always cite sources: include file_id in your answer so the user can visit the source file. For Google Drive sources, provide the URL as https://drive.google.com/file/d/<file_id>/view. | ||
| On error: report the exact error to the user and STOP. Do NOT retry with other pipelines. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Make citation requirements conditional on source-bearing success responses.
The current “always cite” rules conflict with error and empty-result behavior. These paths can return no verified file_id, so agents may fabricate a citation.
internal/mcp/tools/get_chunks.go#L48-L50: Require citations only when a successful result returns afile_id; keep errors citation-free.internal/mcp/tools/get_processed_document.go#L46-L47: Do not treat an echoed requestfile_idas proof that document retrieval succeeded.skills/unstructured-data-mcp-skill.md#L15-L17: Require citations only when source content and a returnedfile_idare available.
📍 Affects 3 files
internal/mcp/tools/get_chunks.go#L48-L50(this comment)internal/mcp/tools/get_processed_document.go#L46-L47skills/unstructured-data-mcp-skill.md#L15-L17
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/mcp/tools/get_chunks.go` around lines 48 - 50, Make citation
guidance conditional on verified source-bearing success: in
internal/mcp/tools/get_chunks.go lines 48-50, require a citation only when the
successful result includes a file_id and keep error responses citation-free; in
internal/mcp/tools/get_processed_document.go lines 46-47, do not treat an echoed
request file_id as proof of successful retrieval; in
skills/unstructured-data-mcp-skill.md lines 15-17, require citations only when
source content and a returned file_id are both available.
At the moment agent doesn't cite the sources which were used to answer the queries. Also in case of access issues, agent should give that as hint to the user.
Update the mcp tool descriptions and skills with the same
Summary by CodeRabbit