Skip to content

Feat/deepagent sql construction - #391

Draft
tomer-levin-nv wants to merge 6 commits into
mainfrom
feat/deepagent-sql-construction
Draft

tomer-levin-nv wants to merge 6 commits into
mainfrom
feat/deepagent-sql-construction

Conversation

@tomer-levin-nv

Copy link
Copy Markdown
Collaborator

No description provided.

ftatiana-nv and others added 3 commits October 19, 2026 10:30
Construction was one LLM call that never saw the database: a wrong filter
literal or a misread question could only be caught downstream, after the
query had already failed validation. These arms let the model look before it
commits, swapped in behind the existing construct_sql_from_candidates node so
validation, execution and reconstruction cannot tell which one ran.

- sql_agent/loop.py bounds a tool-calling conversation on turns, database
  calls and wall clock at once, returning the best query seen rather than
  nothing when any of them expires.
- sql_agent/deep.py holds several readings of a question, probes for the
  evidence separating them and prefers the query that assumes less, which is
  the only thing the candidate-pool measurement left room for. It returns
  structured output rather than calling a submit tool, removing both the
  missed-termination and the collapsed-argument failure modes.
- sql_agent/tools.py is the shared toolbox; elaboration.py and the submission
  gate apply the checks that catch scoring errors to every submission, since
  a check the model may decline is not a check.
- Arms are off unless SQL_AGENT_ENABLED or SQL_DEEP_AGENT_ENABLED says
  otherwise, so an unconfigured run keeps today's single call and the arms can
  be A/B'd rather than branched.
- state carries reasoning_llm so construction can take the strong model while
  the rest of the graph stays on the cheap one.
…nstruction

# Conflicts:
#	auto_ontology/dal/custom_analyses.py
#	auto_ontology/retrieval/text_to_sql/agents/sql_from_semantic.py
#	auto_ontology/retrieval/text_to_sql/main.py
#	auto_ontology/retrieval/text_to_sql/state.py
#	auto_ontology/server/datasources/service.py
#	auto_ontology/utils/llm_invoke.py
#	pyproject.toml
@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

ensemble.py groups the deep agent's candidate SQL by the rows each one
returns and votes over the groups; config.py carries the arm switches and
weights, and the graph wires the pool through the construction node.
… into feat/deepagent-sql-construction

# Conflicts:
#	auto_ontology/retrieval/text_to_sql/tests/test_sql_reconstruction.py
The configuration behind the full BIRD dev Gym run (1,115 vs 1,078 for the
schema-only control, +37 over 1,534 questions).

- Submission gate: add the wording check, which flags an unused column whose
  description shares a 3+ word phrase with the question. On a 165-question
  slice the deep agent scored 104 with it and 98 without.
- Deep agent: bounce a gated submission back up to SQL_AGENT_MAX_BOUNCES
  times instead of accepting the first answer, and merge the leading system
  messages into one block so the endpoint's prompt cache applies.
- Prompts: date without the time of day, so the prompt prefix is cacheable;
  the "Semantically Important Columns" section off unless
  SQL_SEMANTIC_COLUMNS is set; shorter guidance for the example SQL pairs.
- main.py: keep the full-pipeline retry, and fall back to the reasoning
  client when no non-reasoning model is configured instead of handing every
  node a null client.
@liofnv liofnv added the enhancement New feature or request label Nov 15, 2026
@cafzal

cafzal commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

@tomer-levin-nv, suggestion: close, or rebuild on ReAct. #488 removed text_to_sql_graph, sql_from_semantic, sql_from_tables, and candidates_preparation, which this draft changes. If deep-agent SQL construction still adds something over the ReAct loop, it could fit as a tool or a mode in react/.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants