Fix model tool prompt

* Fix NLQ system prompt to work with models that prioritize text instructions over tool calls.

The previous prompt told the model to "Return ONLY the JSON object, nothing else"
while also providing tool definitions. Models like Qwen 3.5 would follow the text
instruction and never use tools. The updated prompt clearly separates the tool-use
phase from the final JSON response phase, and explicitly instructs the model to
call tools directly rather than describing them in text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Update release notes for NLQ prompt fix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix issue number in release notes for NLQ prompt fix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dave Page
2026-03-16 12:10:02 +05:30
committed by GitHub
co-authored by Claude Opus 4.6
parent b3aa78c0a5
commit c8cb744ffd
2 changed files with 16 additions and 7 deletions
+1
View File
@@ -29,6 +29,7 @@ Housekeeping
Bug fixes
*********
| `Issue #9729 <https://github.com/pgadmin-org/pgadmin4/issues/9729>`_ - Fixed an issue where some LLM models would not use database tools in the AI assistant, instead returning text descriptions of tool calls.
| `Issue #9279 <https://github.com/pgadmin-org/pgadmin4/issues/9279>`_ - Fixed an issue where OAuth2 authentication fails with 'object has no attribute' if OAUTH2_AUTO_CREATE_USER is False.
| `Issue #9392 <https://github.com/pgadmin-org/pgadmin4/issues/9392>`_ - Ensure that the Geometry Viewer refreshes when re-running queries or switching geometry columns, preventing stale data from being displayed.
| `Issue #9721 <https://github.com/pgadmin-org/pgadmin4/issues/9721>`_ - Fixed an issue where permissions page is not completely accessible on full scroll.
+15 -7
View File
@@ -13,12 +13,19 @@ NLQ_SYSTEM_PROMPT = """You are a PostgreSQL SQL expert \
integrated into pgAdmin 4.
Your task is to generate SQL queries based on natural language requests.
You have access to database inspection tools:
- get_database_schema: Get list of schemas, tables, and views in the database
You have access to tools for inspecting the database. ALWAYS use \
them when you need to understand the database structure:
- get_database_schema: Get list of schemas, tables, and views \
in the database. Call this first to discover what's available.
- get_table_columns: Get column details for a specific table.
- get_table_info: Get detailed column, constraint, and \
index information for a table
index information for a table.
- execute_sql_query: Run read-only queries to understand \
data structure (SELECT only)
data structure (SELECT only).
IMPORTANT: You MUST use these tools by calling them directly \
(not by describing them in text). Start by calling \
get_database_schema to discover available tables.
Guidelines:
- Use get_database_schema to discover available tables before writing queries
@@ -28,11 +35,12 @@ Guidelines:
- Use explicit column names instead of SELECT *
- For UPDATE/DELETE, always include WHERE clauses
Your response MUST be a JSON object in this exact format:
Once you have explored the database structure using the tools above, \
provide your final answer as a JSON object in this exact format:
{"sql": "YOUR SQL QUERY HERE", "explanation": "Brief explanation"}
Rules:
- Return ONLY the JSON object, nothing else
Rules for the final response:
- Return ONLY the JSON object, no other text
- No markdown code blocks
- If you need clarification, set "sql" to null and put \
your question in "explanation"