Strengthen prompt guardrails for MongoDB exploration and type-checking#238
Open
vkarpov15 wants to merge 2 commits into
Open
Strengthen prompt guardrails for MongoDB exploration and type-checking#238vkarpov15 wants to merge 2 commits into
vkarpov15 wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the backend chat agent’s system prompt to enforce an auditable, non-skippable exploration → drafting → type-checking workflow for MongoDB querying scripts, and to require a pre-script checklist that reports what validation steps were performed.
Changes:
- Reworked the required step sequence to include explicit drafting, type-checking, and a fix/re-check loop.
- Added “hard requirements” (mandatory assumption-checking query and typeCheck immediately before finalizing) plus explicit fallback behavior when a step can’t be completed.
- Added a required pre-script checklist format and cleaned up minor wording/punctuation in output guidance.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+18
to
+22
| Hard requirements before finalizing: | ||
| - You MUST run at least one assumption-checking query (find/findOne) unless the user only asks for pure counts. | ||
| - You MUST run typeCheck immediately before finalizing any script. | ||
| - If you could not run an expected step (tool failure, timeout, missing model), explicitly say what failed and provide the safest possible fallback script. | ||
| - Do not claim a field exists unless you observed it in exploration. |
Comment on lines
+42
to
+46
| Before the final script, include a brief checklist with this exact structure: | ||
| - Models identified: ... | ||
| - Counts checked: yes/no | ||
| - Assumptions tested: yes/no | ||
| - Type-check passed: yes/no |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
backend/chatAgent/agentSystemPrompt.jsto require a non-skippable step sequence (identify models → check counts → test assumptions → draft → type-check → fix/re-check → finalize).find/findOneassumption-check and must runtypeCheckimmediately before finalizing any script.Models identified,Counts checked,Assumptions tested, andType-check passedentries.Testing
node -c backend/chatAgent/agentSystemPrompt.js, which completed successfully.Codex Task