Skip to content

fix: align prompt role and task strings with resource-file framing (fixes #619)#728

Merged
tnaum-ms merged 1 commit into
microsoft:mainfrom
hanhan761:fix-619-prompt-role-alignment
Jun 24, 2026
Merged

fix: align prompt role and task strings with resource-file framing (fixes #619)#728
tnaum-ms merged 1 commit into
microsoft:mainfrom
hanhan761:fix-619-prompt-role-alignment

Conversation

@hanhan761

@hanhan761 hanhan761 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

The INDEX_ADVISOR_ROLE constant and corresponding service config strings used 'MongoDB API Index Advisor assistant' -- biased toward recommending indexes and inconsistent with the neutral "Query Performance Analyst" framing already present in the resource prompt files.

This PR renames the constant to QUERY_PERFORMANCE_ANALYST_ROLE with the domain-qualified value 'DocumentDB API / MongoDB API Query Performance Analyst', updates all matching task strings, reconciles the inline fallback templates so they are byte-identical to the resource prompt files, and updates snapshots accordingly.

Changes

promptTemplates.ts

  • INDEX_ADVISOR_ROLE renamed to QUERY_PERFORMANCE_ANALYST_ROLE with value 'DocumentDB API / MongoDB API Query Performance Analyst'
  • INDEX_ADVISOR_TASK_FIND/AGGREGATE/COUNT renamed to QUERY_PERFORMANCE_TASK_* with simplified "analyze ... performance" wording (dropped "provide index optimization suggestions")
  • Inline fallback templates reconciled with resource prompt files: removed a misplaced "or confirm that no changes are needed" clause from security instructions; fixed wording divergence in the find template; corrected blank-line drift

promptTemplateService.ts

  • Role strings updated to 'DocumentDB API / MongoDB API Query Performance Analyst' (3 call sites)
  • Task strings updated to match the simplified QUERY_PERFORMANCE_TASK_* wording (3 call sites)

Snapshots

  • promptTemplates.test.ts.snap updated to reflect the new role and task strings

Issue

Fixes #619

Copilot AI review requested due to automatic review settings June 3, 2026 04:15
@hanhan761 hanhan761 requested a review from a team as a code owner June 3, 2026 04:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the LLM “index advisor” prompt persona to a broader “query performance analyst” framing, and introduces an LRU-style cap on schema cache growth to avoid unbounded memory usage.

Changes:

  • Renames prompt role/task strings from “Index Advisor” to “Query Performance Analyst” across prompt configuration sources.
  • Adds a soft max-entry limit (default 100) to SchemaStore with LRU eviction tracking and telemetry for evictions.
  • Simplifies package.json transitive dependency override notes and removes one override entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/services/promptTemplateService.ts Updates prompt role/task strings for Find/Aggregate/Count prompt configs.
src/documentdb/SchemaStore.ts Adds max-entry limit with LRU eviction bookkeeping and telemetry.
src/commands/llmEnhancedCommands/promptTemplates.ts Updates constants for the prompt role/task strings.
package.json Removes an override entry and updates the comment explaining overrides.

Comment thread src/documentdb/SchemaStore.ts Outdated
Comment thread src/documentdb/SchemaStore.ts Outdated
Comment thread src/documentdb/SchemaStore.ts Outdated
Comment thread src/commands/llmEnhancedCommands/promptTemplates.ts Outdated
@tnaum-ms tnaum-ms added the in-triage-queue We've seen your input and will triage it label Jun 4, 2026
@tnaum-ms tnaum-ms added this to the 0.9.1 milestone Jun 23, 2026
…ixes microsoft#619)

Unify the Stage 3 index-advisor prompts so the inline fallback templates
match the authoritative resource prompt files exactly:

- Use the domain-qualified role "DocumentDB API / MongoDB API Query
  Performance Analyst" in the priority-declaration header so it matches the
  prompt body and the resource files.
- Fix the misplaced "or confirm that no changes are needed" clause in the
  TASK INSTRUCTIONS of the find, aggregate, and count templates.
- Reconcile the find "multiple range filters" wording with the resource file.
- Correct blank-line placement so the inline fallbacks are byte-identical to
  the resource files at runtime.
- Update snapshots accordingly.
@tnaum-ms tnaum-ms force-pushed the fix-619-prompt-role-alignment branch from d5b5f48 to a3b53eb Compare June 24, 2026 09:03
@tnaum-ms

Copy link
Copy Markdown
Collaborator

Thank you for this contribution, and as with your last PR, a small course-correction is in order.

The original issue (#619) asked for "neutral" role phrasing, and your PR implemented exactly that. When we reviewed it with the change in hand, though, we realized the issue itself had pointed us in a slightly wrong direction. What we actually want is not a neutral, generic role, but a single unified, domain-qualified one: "DocumentDB API / MongoDB API Query Performance Analyst". That keeps the priority-declaration header consistent with the prompt body and the resource prompt files, instead of making the header more generic than either.

Your PR is what made us look closely at this. While we were in there, we also found a few more inconsistencies between the inline fallback templates and the authoritative resource files: a misplaced "or confirm that no changes are needed" clause in the task instructions, a wording divergence in the find template, and some blank-line drift. Building on your work, we:

  • Unified the role to the domain-qualified phrasing in both the header constant and the service config.
  • Reconciled the inline fallback templates so they are byte-identical to the resource prompt files at runtime.
  • Updated the snapshots accordingly.

So while the literal change here shifted from what the issue first described, your submission is what prompted us to think twice and tighten this part of the codebase up. Thank you for filing it and seeing it through. We really appreciate it.

I have rebased the branch on the latest main and pushed the combined change as a single commit, keeping it attributed to you.

@tnaum-ms tnaum-ms removed the in-triage-queue We've seen your input and will triage it label Jun 24, 2026
@tnaum-ms tnaum-ms enabled auto-merge June 24, 2026 09:27
@tnaum-ms tnaum-ms merged commit 61f43a6 into microsoft:main Jun 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query Insights: Align priority-declaration role with resource-file prompt framing

4 participants