WrenAI icon indicating copy to clipboard operation
WrenAI copied to clipboard

fix(wren-ai-service): Validate the SQL generated for recommended ques…

Open JakeCowton opened this issue 4 months ago • 2 comments

Currently the SQL generated for recommended questions does not check if the SQL is valid.

This PR runs a configurable number of retries to fix any invalid SQL, bringing it inline with how SQL for regular asks are generated.

Summary by CodeRabbit

  • New Features
    • Added automatic SQL correction retries in the Ask flow to recover from invalid SQL generations and improve answer success rates.
    • Introduced a configurable retry limit for SQL correction, allowing fine-tuning of reliability and performance.
    • Enhanced robustness of question recommendations without changing existing user workflows or UI.

JakeCowton avatar Sep 04 '25 14:09 JakeCowton

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely and accurately summarizes the primary change—adding validation for SQL generated for recommended questions—using a conventional-commit prefix and clear wording that matches the PR objectives and code changes (SQL correction pipeline and retry configuration).
✨ Finishing touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d02d54ff43fbbb7dfb3fc67d133318fc517a62bc and b6a0686b7506c32d47a8bc194b1238d315889640.

📒 Files selected for processing (1)
  • wren-ai-service/src/globals.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • wren-ai-service/src/globals.py

[!TIP]

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

coderabbitai[bot] avatar Sep 04 '25 14:09 coderabbitai[bot]

@JakeCowton thanks for contribution, I'll take a look in a few days

cyyeh avatar Sep 05 '25 02:09 cyyeh