From c8f5a0acc50e836dbb8418414c003bab36ca113d Mon Sep 17 00:00:00 2001 From: Gal Shubeli Date: Wed, 7 Jan 2026 16:03:07 +0200 Subject: [PATCH 1/3] reasonin-output --- api/agents/analysis_agent.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/api/agents/analysis_agent.py b/api/agents/analysis_agent.py index c7bccc8a..94c80bb5 100644 --- a/api/agents/analysis_agent.py +++ b/api/agents/analysis_agent.py @@ -282,14 +282,13 @@ def _build_prompt( # pylint: disable=too-many-arguments, too-many-positional-a ```json {{ "is_sql_translatable": true or false, - "instructions_comments": ("Comments about any part of the instructions, " - "especially if they are unclear, impossible, " - "or partially met"), + "query_analysis": "OUTPUT: .\\nOUTPUT GRAIN: .\\nMETRIC: .\\nGRAIN CHECK: .\\nAGGREGATION DECISION: (NONE unless explicitly requested).\\nRANKING/LIMIT: .\\nFILTERS: (each predicate must be a concrete SQL condition using =, >, <, BETWEEN, IN; do NOT use LIKE/contains unless explicitly requested).", "explanation": ("Detailed explanation why the query can or cannot be " "translated, mentioning instructions explicitly and " "referencing conversation history if relevant"), - "sql_query": ("High-level SQL query (you must to applying instructions " - "and use previous answers if the question is a continuation)"), + "sql_query": ("ONE valid SQL query for the target database that follows " + "all rules above (use previous answers only if the question " + "is a continuation)"), "tables_used": ["list", "of", "tables", "used", "in", "the", "query", "with", "the", "relationships", "between", "them"], "missing_information": ["list", "of", "missing", "information"], From 9e9863c99e63af63d71f59247de8e110087c52fe Mon Sep 17 00:00:00 2001 From: Gal Shubeli Date: Wed, 7 Jan 2026 16:06:34 +0200 Subject: [PATCH 2/3] lint-fix --- api/agents/analysis_agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/agents/analysis_agent.py b/api/agents/analysis_agent.py index 94c80bb5..6ca1cbc3 100644 --- a/api/agents/analysis_agent.py +++ b/api/agents/analysis_agent.py @@ -167,7 +167,7 @@ def _format_foreign_keys(self, foreign_keys: dict) -> str: return fk_str - def _build_prompt( # pylint: disable=too-many-arguments, too-many-positional-arguments + def _build_prompt( # pylint: disable=too-many-arguments, too-many-positional-arguments, disable=line-too-long self, user_input: str, formatted_schema: str, db_description: str, instructions, memory_context: str | None = None, database_type: str | None = None, From 3a96f50140b2e6af9f9e49d39e63ee56ad8cd013 Mon Sep 17 00:00:00 2001 From: Gal Shubeli Date: Wed, 7 Jan 2026 16:11:04 +0200 Subject: [PATCH 3/3] rm-instructions-comments --- api/agents/analysis_agent.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/api/agents/analysis_agent.py b/api/agents/analysis_agent.py index 6ca1cbc3..cf288e57 100644 --- a/api/agents/analysis_agent.py +++ b/api/agents/analysis_agent.py @@ -254,8 +254,6 @@ def _build_prompt( # pylint: disable=too-many-arguments, too-many-positional-a - Analyze the query's translatability into SQL according to the instructions. - Apply the instructions explicitly. - You MUST NEVER use application-level identifiers that are email-based or encoded emails. - - If you CANNOT apply instructions in the SQL, explain why under - "instructions_comments", "explanation" and reduce your confidence. - Penalize confidence appropriately if any part of the instructions is unmet. - When there several tables that can be used to answer the question, you can combine them in a single SQL query. - Use the memory context to inform your SQL generation, considering user preferences and previous database interactions.