Enforce dose context before text fast path#575
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
📝 WalkthroughWalkthroughMedication dose query filtering now recognizes more generic terms and detects explicit dose-evidence requests. RAG fast-path decisions use contextual dose, amount, route, and agitation evidence checks, with tests covering accepted and rejected contexts. ChangesMedication dose evidence gating
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant decideTextFastPath
participant isMedicationDoseEvidenceQuery
participant evaluateEvidenceCoverageGate
decideTextFastPath->>isMedicationDoseEvidenceQuery: classify query
isMedicationDoseEvidenceQuery-->>decideTextFastPath: explicit evidence request
decideTextFastPath->>evaluateEvidenceCoverageGate: evaluate contextual dose coverage
evaluateEvidenceCoverageGate-->>decideTextFastPath: accepted decision or failure reason
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (2 errors)
✅ Passed checks (9 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 26c93547d8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/clinical-search.ts`:
- Around line 1147-1152: Expand and make the shared
isMedicationDoseEvidenceQuery detector intent-aware, covering explicit amount,
frequency, and administration wording such as “how much,” “how often,”
“micrograms,” and oral/intramuscular administration. In
src/lib/clinical-search.ts lines 1147-1152 update the shared predicate; in
src/lib/rag.ts lines 2612-2615 ensure every matching explicit query enters the
coverage gate; and in src/lib/rag.ts lines 2929-2931 reuse the shared
amount/route predicates so gate requirements remain consistent.
In `@src/lib/rag.ts`:
- Around line 2953-2962: The failure-reason chain in the acceptance result must
only report missing dose amount evidence when the query requests an amount.
Update the `!hasDoseAmount` branch to also require `asksDoseAmount`, preserving
route-only queries so they can correctly return `missing_route_evidence`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1121ed1f-b25c-4ec5-bf6a-a6646fd962de
📒 Files selected for processing (4)
src/lib/clinical-search.tssrc/lib/rag.tstests/rag-answer-fallback.test.tstests/retrieval-query-variants.test.ts
Summary
medication_dose_riskVerification
npm run eval:rag:offline: 21 files, 265 tests passedReview resolution
Fixes the P1 inline finding at #571 discussion
r3569692474by preventing mixed opioid-context/unrelated-dose evidence from bypassingevaluateEvidenceCoverageGate.