Skip to content

fix(ai): recover query matches outside the selected category - #783

Draft
izadoesdev wants to merge 2 commits into
stagingfrom
codex/query-capability-discovery
Draft

fix(ai): recover query matches outside the selected category#783
izadoesdev wants to merge 2 commits into
stagingfrom
codex/query-capability-discovery

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Sep 10, 2026

Copy link
Copy Markdown
Member

A category-scoped search can miss an existing analytics builder. For example, retention under Custom Events returns zero results even though identified_profile_retention exists under Profiles. Discovery now returns separately labeled outsideCategory matches after a scoped keyword miss, preserving the scoped count, actual category labels, substring matching and full query contracts.

The final change is limited to the discovery tool and its regression tests: 13 production lines added, six removed. It uses the existing catalog and performs no I/O.

Validation: root lint, all 33 typecheck tasks and the full 27-task test suite pass. The AI package reports 724 passed, 229 skipped, zero failed. Three behavioral checks reproduce failures on the frozen reference and pass here; native contract coverage also verifies selectors, ordering, genuine misses, complete browsing and existing search behavior. Independent read-only review found no actionable regressions.

We ran 48 live attempts across two frozen paired experiments with the same configured openai/gpt-5.6-terra gateway alias, native MCP configuration, tool schemas and synthetic data. The first experiment recovered retention in 4/4 attempts versus 0/4. The second compared catalog compaction against the final simpler fallback:

Second paired experiment Compact version Final fallback
Requested data answers completed 9/10 10/10
Correct retention answers 4/4 4/4
Greeting controls without tools 2/2 2/2
Model steps 44 37
Discovery calls 21 14
Observed input tokens, including cache 519,230 437,594
Median attempt latency 12.08s 10.39s

Compaction repeatedly required three discovery calls for property questions versus one with full contracts. The final version emits more discovery-response bytes but uses 15.7% fewer input tokens in the paired sample. Cache usage differs, so this is not an established monetary saving. The fixed tool-definition payload remains about 50 KB per model step.

Each experiment uses six known synthetic cases with two repetitions, alternating which version runs first and reversing case order for repeat two. SQL/schema/profile alternatives are deliberately unavailable, so the compact version's missing checkout answer does not prove a production regression. All attempts and traces are retained; no failures were selectively replaced. This is a small diagnostic sample, not a production success rate or a live Sazabi comparison.

Scope and integration: based on current staging a080d7abd, with no source overlap or merge dependency on #782 or #751. Both evaluation arms explicitly compose #782's earlier conversation/schema repair at f61250448; only discovery differs within each pair. Final source is identical to the evaluated fallback (SHA-256 d76442b4407b18fe56c2c711fab7d981ae090311ec33d0c5bd4e95dabc6c3a66). No model, main prompt, authorization, storage or deployment changes.

AI-assisted implementation and evaluation, directed by the maintainer. Draft for review.

@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
databuddy-status Ready Ready Preview Sep 10, 2026 10:42am UTC
2 Skipped Deployments
Project Deployment Actions Updated
dashboard Skipped Skipped Sep 10, 2026 10:42am UTC
documentation Skipped Skipped Sep 10, 2026 10:42am UTC

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: c236c751-4759-4461-b167-2624debe95c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@unkey-deploy

unkey-deploy Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
links (preview) Ready Visit Preview Inspect Sep 10, 2026 10:42am

@izadoesdev izadoesdev changed the title fix(ai): make query discovery recover across categories fix(ai): recover query matches outside the selected category Sep 10, 2026
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.

1 participant