Skip to content

chat: align NoSQL query-generation prompt with language service and remove legacy language reference injection#3072

Open
bk201- wants to merge 5 commits into
mainfrom
chat/improve-nosql-query-generation-prompt
Open

chat: align NoSQL query-generation prompt with language service and remove legacy language reference injection#3072
bk201- wants to merge 5 commits into
mainfrom
chat/improve-nosql-query-generation-prompt

Conversation

@bk201-
Copy link
Copy Markdown
Contributor

@bk201- bk201- commented May 26, 2026

Summary

Aligns the AI chat participant’s NoSQL query-generation guidance with the language-service-backed syntax/function rules in src/chat/systemPrompt.ts and removes the separate markdown language-reference injection path.

The prompt is now the single in-repo source of truth for query-generation rules, reducing drift and cutting prompt token usage.

What changed

Prompt/rules updates

  • Updated QUERY_GENERATION_RULES in src/chat/systemPrompt.ts with tighter syntax/function guidance, including:
    • ORDER BY and ORDER BY RANK constraints
    • SELECT VALUE alias restrictions
    • additional operator and function details
    • clarified aggregate/count and array-function guidance
  • Updated comments to indicate the rules are the source of truth for LLM query-generation guidance.

Removed legacy language-reference plumbing

  • Deleted resources/azurecosmosdb-nosql-query-language.md.
  • Removed file-loading/cache logic from src/chat/CosmosDbOperationsService.ts.
  • Removed languageReference from query-generation payload construction and types (src/chat/userPayload.ts).
  • Removed obsolete service initialization usage/import in src/extension.ts.
  • Updated comments in src/chat/queryOneShotExamples.ts to reference QUERY_GENERATION_RULES.

Why this matters

  • Keeps generated queries aligned with the syntax the extension/parser actually supports.
  • Eliminates duplicated and drifting query-language guidance.
  • Reduces token overhead by removing the large markdown reference from chat payloads.

Validation

  • Latest completed branch workflow run is successful.
  • Scope is limited to prompt/rules content updates and removal of obsolete language-reference wiring; no new public API surface was introduced.

Files changed

  • src/chat/systemPrompt.ts
  • src/chat/CosmosDbOperationsService.ts
  • src/chat/userPayload.ts
  • src/chat/queryOneShotExamples.ts
  • src/extension.ts
  • resources/azurecosmosdb-nosql-query-language.md (deleted)

Sync QUERY_GENERATION_SYSTEM_PROMPT with the syntax rules and function catalogue from packages/nosql-language-service:

- ORDER BY: forbid ASC/DESC with ORDER BY RANK, disallow mixing RANK with regular sort keys, note that SELECT aliases cannot be reused in ORDER BY, and list FullTextScore / VectorDistance / RRF as the only valid RANK operands.

- DateTime: add the *Static variants (GetCurrentDateTimeStatic, GetCurrentTimestampStatic, GetCurrentTicksStatic) with a note that they evaluate once per query and are safe inside indexed predicates.

- Full-text / vector search: clarify that FullTextScore is only valid inside ORDER BY RANK, VectorDistance can appear in SELECT or ORDER BY RANK, and RRF combines scores for hybrid search.

- Output rule: any non-query text (notes, caveats, assumptions, TODOs) must be wrapped in -- ... or /* ... */ comments so the entire response parses as a valid Cosmos DB NoSQL query.

- Add full-text and hybrid-search examples to the Examples section.
@bk201- bk201- requested a review from a team as a code owner May 26, 2026 16:25
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

🎉 Build Summary

🔗 Source

📦 Package Information

🧪 Test Results

  • Unit Tests: ✅ success
  • Integration Tests: ✅ success

✅ Build Status

All checks completed successfully!

bk201- and others added 3 commits May 27, 2026 09:19
Sync QUERY_GENERATION_SYSTEM_PROMPT with the syntax rules and function catalogue from packages/nosql-language-service:

- ORDER BY: forbid ASC/DESC with ORDER BY RANK, disallow mixing RANK with regular sort keys, note that SELECT aliases cannot be reused in ORDER BY, and list FullTextScore / VectorDistance / RRF as the only valid RANK operands.

- DateTime: add the *Static variants (GetCurrentDateTimeStatic, GetCurrentTimestampStatic, GetCurrentTicksStatic) with a note that they evaluate once per query and are safe inside indexed predicates.

- Full-text / vector search: clarify that FullTextScore is only valid inside ORDER BY RANK, VectorDistance can appear in SELECT or ORDER BY RANK, and RRF combines scores for hybrid search.

- Output rule: any non-query text (notes, caveats, assumptions, TODOs) must be wrapped in -- ... or /* ... */ comments so the entire response parses as a valid Cosmos DB NoSQL query.

- Add full-text and hybrid-search examples to the Examples section.
…m CosmosDbOperationsService

refactor: update comments to reference new query generation rules in queryOneShotExamples
refactor: simplify user payload by removing language reference property
refactor: clean up extension activation by removing unnecessary CosmosDbOperationsService initialization
@languy
Copy link
Copy Markdown
Contributor

languy commented May 28, 2026

@copilot Rework PR description with latest changes.

Copy link
Copy Markdown
Contributor

Copilot AI commented May 28, 2026

@copilot Rework PR description with latest changes.

Updated description draft (reflecting latest commits):

Summary

This PR now does two things:

  1. aligns the NoSQL query-generation prompt with the language-service-backed syntax/function rules, and
  2. removes the separate markdown language-reference injection path so the prompt has a single in-repo source of truth.

In practice, query guidance now comes from QUERY_GENERATION_RULES in src/chat/systemPrompt.ts rather than loading resources/azurecosmosdb-nosql-query-language.md into user payload context.

What changed

  • src/chat/systemPrompt.ts
    • tightened/expanded QUERY_GENERATION_RULES (operator details, SELECT VALUE alias restrictions, ORDER BY constraints, BETWEEN guidance, function-catalog clarifications including array signatures and COUNT restrictions).
    • updated comment to mark these rules as the single source of truth for LLM syntax guidance.
  • resources/azurecosmosdb-nosql-query-language.md
    • removed.
  • src/chat/CosmosDbOperationsService.ts
    • removed extension-path initialization and file-loading cache for the markdown language reference.
    • stopped attaching languageReference to query-generation payloads.
  • src/chat/userPayload.ts
    • removed languageReference from QueryGenerationPayload and content assembly.
  • src/extension.ts
    • removed CosmosDbOperationsService.initialize(context) call and unused import.
  • src/chat/queryOneShotExamples.ts
    • updated comments to reference QUERY_GENERATION_RULES instead of the deleted markdown file.

Why

  • Prevent prompt drift from language-service-supported syntax.
  • Reduce token overhead by removing the large markdown reference payload.
  • Simplify chat query-generation plumbing by removing now-redundant file I/O and initialization paths.

Validation

  • Branch workflows for this PR are green (latest completed run successful).
  • Changes are localized to prompt/rules content and removal of obsolete language-reference wiring; no external API additions.

Copilot AI changed the title chat: align NoSQL query-generation prompt with language service chat: align NoSQL query-generation prompt with language service and remove legacy language reference injection May 28, 2026
Copilot finished work on behalf of languy May 28, 2026 08:18
Copilot AI requested a review from languy May 28, 2026 08:18
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.

3 participants