fix(chat): restrict Ask DRIFT citations to grounded insights - #5
Conversation
Make live Ask DRIFT responses structured so the model reports the Insight IDs it used and the API cites only those sources. Add malformed-response and subset-citation coverage, bump source and frontend metadata to 0.8.1, and synchronize release records while keeping hosted v0.8.0 verification explicit.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR tightens DRIFT’s live /chat grounding by making the model return a structured payload that explicitly lists which Insight IDs it actually used, and then restricting citations/grounded IDs to that subset (with a safe fallback when none are returned). It also bumps the project version to 0.8.1 and synchronizes documentation/release records around the patch.
Changes:
- Enforce structured live-chat responses (
answer+grounded_insight_ids) with strict validation and filtering to the supplied Insight window. - Restrict
/chatcitations and returnedgrounded_insight_idsto the grounded subset (fallback to full retrieval window when none are returned). - Add regression tests for subset-citation behavior, malformed/blank structured responses, router schema forwarding, and lifespan integration; bump versions + update docs/changelog.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Bumps backend package version to 0.8.1. |
| pyproject.toml | Updates backend project version to 0.8.1. |
| backend/agents/briefing.py | Introduces strict structured chat output schema + parsing; returns grounded IDs alongside text. |
| backend/core/model_router.py | Adds optional text_format to request strict JSON schema responses via the Responses API. |
| backend/main.py | Filters /chat citations/grounded IDs to the grounded subset with fallback behavior. |
| tests/unit/test_live_chat.py | Expands unit coverage for structured output, subset filtering, malformed/blank responses, and schema forwarding. |
| tests/integration/test_lifespan.py | Updates integration to reflect structured live-chat output. |
| frontend/package.json | Bumps frontend version to 0.8.1. |
| frontend/package-lock.json | Bumps frontend lock metadata to 0.8.1. |
| README.md | Synchronizes initiative count and records the v0.8.1 source patch boundary. |
| docs/RUNBOOK.md | Documents v0.8.1 as source-only patch pending hosted verification; updates initiative count. |
| docs/BUILD_SEQUENCE.md | Records v0.8.1 patch and adds planning notes for targeted releases. |
| docs/ARCHITECTURE.md | Documents structured grounding ID behavior and hosted-verification boundary. |
| docs/adr/008-live-grounded-chat.md | Adds dated implementation addendum describing structured grounding/citation filtering. |
| CHANGELOG.md | Adds 0.8.1 entry describing grounding/citation fix and related test coverage; clarifies planned targets. |
| AGENTS.md | Synchronizes status notes for the v0.8.1 source patch and documentation session. |
Files not reviewed (1)
- frontend/package-lock.json: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| supplied_ids = {insight.id for insight in relevant_insights if insight.id is not None} | ||
| grounded_ids = [ | ||
| insight_id for insight_id in payload.grounded_insight_ids if insight_id in supplied_ids | ||
| ] | ||
| return GroundedAnswer(payload.answer.strip(), grounded_ids) |
What changed
Why
A question-specific answer could previously present every retrieved source link, including unrelated Insights. This patch makes the citation set answer-specific while preserving the retrieve-first, evidence-only boundary.
Validation
Hosted verification remains explicitly at v0.8.0 until deployment is independently checked. Unrelated v0.9.0 planning and screenshot changes remain outside this PR.