fix: require explicit RAG scope before generators use docs - #1161
Conversation
Stop agent/skill generation from silently reading the persisted local index, and make the UI attach/detach session context deliberately so prior-session documents cannot contaminate a new request. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Update frontend assertions for enable_context_retrieval so Smoke matches the explicit context-scope behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
Update hybrid/API assertions for enable_context_retrieval=False by default and opt into retrieval only in success-path context tests. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Stale comment
PR Risk Assessment (Automation) — Re-evaluation
Risk level: Low (unchanged)
Code review required: No
Decision: Prior approval retained — no re-approval postedTrigger
PR synchronized after prior approval (
98c1c91). New HEAD:2b41a12.Delta since last approval
Only test files changed in the new commit:
tests/test_agent_generator.py— addenable_context_retrieval=Falseto mock expectationstests/test_hybrid.py— passenable_context_retrieval=Truewhere RAG retrieval is exercisedtests/test_multi_agent.py— expectcontext=Nonewhen retrieval is off; add opt-in flag to API mockstests/test_skills_generator.py— addenable_context_retrieval=Falseto mock expectationsNo production code, infra, auth, or schema changes in the delta.
Full PR evidence (production surface)
9 non-test files modified:
api/routes/generators.py—enable_context_retrievaldefaults tofalseon agent/skill generator requestsapp/llm_engine/hybrid.py— gatescontext_strategist.process()behind opt-in flag (mirrors compile pattern)web/app/hooks/useContextManager.ts+ContextManager.tsx— session-scoped attach/detach; library visible but inactive until attachedweb/app/hooks/useCompiler.ts,page.tsx,agent-generator/page.tsx,skills-generator/page.tsx— wirecontextAttachedinto requests; shared context stateweb/lib/api/types.ts— type annotation onlyWhy Low (risk did not increase)
- Conservative behavioral change: defaults to less context sent to LLMs, not more
- Established pattern: extends existing compile RAG opt-in design to generators
- Limited blast radius: scoped to RAG context scoping across three related UI flows; no auth, billing, infra, or deployment changes
- Strong test coverage: dedicated API tests, context-generation updates, frontend scope tests; latest commit tightens mock alignment
Reviewer assignment
Not required at Low risk. No CODEOWNERS file. 0 reviewers currently assigned.
CI
All checks passing (Smoke, Analyze, CodeQL, Snyk, GitGuardian, VS Code Extension, PR Tests).
Automated risk assessment — conclusions derived from diff evidence only.
Sent by Cursor Automation: Assign PR reviewers
There was a problem hiding this comment.
Stale comment
PR Risk Assessment (Automation) — Re-evaluation
Risk level: Low (unchanged)
Code review required: No
Decision: Prior approval retained — no new approval posted (already approved on98c1c91)Trigger
PR synchronized (
synchronize). New HEAD:31dc335(mergemainintofix/rag-explicit-context-scope-1155).Delta since last assessment (
2b41a12)The new commit is a merge from
mainonly — it brings upstream CI/tests/security fixes already onmaininto the branch. Comparingorigin/main...HEADstill shows 29 files / +614 −46, identical in scope to the prior assessment (RAG explicit scope work only). No additional PR-authored production logic in this sync.Evidence (production surface)
Area Change api/routes/generators.pyenable_context_retrievaldefaults tofalsefor agent/skill generator requestsapp/llm_engine/hybrid.pyGates context_strategist.process()behind opt-in flag (mirrors compile)web/app/hooks/useContextManager.ts+ContextManager.tsxSession attach/detach; library visible but inactive until attached web/app/hooks/useCompiler.ts,page.tsx, generator pagesWire contextAttached→enable_context_retrieval/ compile flagweb/lib/api/types.tsType annotation only Why Low (risk did not increase)
- Conservative default: less persisted RAG content sent to LLMs unless the user opts in
- Cohesive, limited domain: RAG scope across compiler + agent/skill generators; no auth, billing, infra, or schema changes
- Substantial automated tests:
test_generator_rag_opt_in_api.py, context-generation updates, frontend scope tests- Merge sync: does not expand the merge-to-
maindiff beyond the aboveReviewers
Not required at Low risk. No
CODEOWNERSfile. 0 requested reviewers (under the 2-reviewer cap).CI
Checks were in progress at assessment time (Smoke, CodeQL Analyze, VS Code Extension); Snyk and GitGuardian already green.
Slack
Automation has no Slack channel configured for this run (
slackChannelIdnull); summary delivered via this PR review only.
Automated risk assessment — conclusions derived from diff evidence only.
Sent by Cursor Automation: Assign PR reviewers
There was a problem hiding this comment.
PR Risk Assessment (Automation) — Re-evaluation
Risk level: Low (unchanged)
Code review required: No
Decision: Prior approval retained — no new approval posted (already approved on 98c1c91)
Trigger
PR synchronized (synchronize). New HEAD: 5146e1e (merge main into fix/rag-explicit-context-scope-1155).
Delta since last assessment (31dc335)
New commit merges upstream main into the branch. Comparing 31dc335..5146e1e touches 9 files (+186 lines), including merged-from-main generator error-artifact handling (_raise_if_generator_error_artifact in api/routes/generators.py, web/lib/generatorErrorArtifact.ts, client asserts on agent/skill pages) plus matching tests.
origin/main...HEAD remains 29 files (+614 −46) — same PR-authored scope as prior runs (explicit RAG scope for compile + generators). The merge does not widen the merge-to-main diff.
Evidence (production surface)
| Area | Change |
|---|---|
api/routes/generators.py |
enable_context_retrieval defaults to false; passes flag into hybrid generators |
app/llm_engine/hybrid.py |
Gates context_strategist.process() behind opt-in (mirrors existing compile path) |
web/app/hooks/useContextManager.ts + ContextManager.tsx |
Session attach/detach; library visible but inactive until attached |
web/app/hooks/useCompiler.ts, page.tsx, generator pages |
Wire contextAttached → retrieval flags on compile/generate requests |
web/lib/api/types.ts |
Type annotation only |
Why Low (risk did not increase)
- Conservative default: less persisted RAG content sent to LLMs unless the user explicitly attaches context
- Established pattern: extends existing compile
enable_context_retrievaldesign to agent/skill generators - Cohesive domain: RAG scoping across related UI flows; no auth, billing, infra, deployment, or schema changes
- Merged safety fix: error-as-markdown generator responses are rejected server- and client-side (from
main; reduces mistaken export of failures) - Strong automated tests:
test_generator_rag_opt_in_api.py, context-generation updates, frontend scope tests
Reviewers
Not required at Low risk. No CODEOWNERS file. 0 requested reviewers.
CI
CodeQL, Analyze, Snyk, GitGuardian, and Vercel green; Smoke and VS Code Extension still pending at assessment time.
Slack
No Slack destination is configured for this automation run; summary delivered via this PR review only.
Automated risk assessment — conclusions derived from diff evidence only.
Sent by Cursor Automation: Assign PR reviewers


Summary
enable_context_retrievalto off (same opt-in pattern as compile), so cloud-backed generation cannot silently inherit stale local index content.Small related improvement
Test plan
python -m pytest tests/test_generator_rag_opt_in_api.py tests/test_context_generation.py -qcd web && npm run test -- --run app/hooks/useContextManager.test.tsx app/components/__tests__/ContextManager.test.tsx app/__tests__/page-rag-context-scope.test.tsx app/agent-generator/page.test.tsx app/skills-generator/page.test.tsxMade with Cursor