Skip to content

Strengthen prompt guardrails for MongoDB exploration and type-checking#238

Open
vkarpov15 wants to merge 2 commits into
mainfrom
codex/analyze-agentsystemprompt.js-for-improvements
Open

Strengthen prompt guardrails for MongoDB exploration and type-checking#238
vkarpov15 wants to merge 2 commits into
mainfrom
codex/analyze-agentsystemprompt.js-for-improvements

Conversation

@vkarpov15
Copy link
Copy Markdown
Member

Motivation

  • Improve reliability of the data-querying agent by preventing skipped exploration steps and missed type-checks.
  • Make the agent's workflow auditable so responses include evidence that assumptions were validated and scripts were type-checked.

Description

  • Updated backend/chatAgent/agentSystemPrompt.js to require a non-skippable step sequence (identify models → check counts → test assumptions → draft → type-check → fix/re-check → finalize).
  • Added explicit hard requirements that the agent must run at least one find/findOne assumption-check and must run typeCheck immediately before finalizing any script.
  • Added fallback guidance to require explicit disclosure when a step cannot be completed (tool failure, timeout, or missing model) and to return a safest-possible fallback script.
  • Added a pre-script checklist that must appear before the final script with: Models identified, Counts checked, Assumptions tested, and Type-check passed entries.

Testing

  • Ran a syntax check with node -c backend/chatAgent/agentSystemPrompt.js, which completed successfully.

Codex Task

Copilot AI review requested due to automatic review settings May 4, 2026 21:16
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio Ready Ready Preview, Comment May 6, 2026 0:03am

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread backend/chatAgent/agentSystemPrompt.js Outdated
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants