Notes from a 2 AM On-Call: When Cursor Plugin Context Windows Silently Truncate
Description and use
Cursor plugin omitted the e2e directory from context due to token limits, causing a production crash after refactoring Pydantic models. Adding e2e to context, raising token limit, and a pre‑commit check prevented further failures.
Problem
Cursor AI plugin omitted critical e2e tests from context due to token budget, causing a production crash after refactoring Pydantic models.
Outcome
By ensuring the e2e test directory is included in the Cursor plugin context and adding a pre‑commit gate, the team prevented silent context truncation and avoided production crashes. Token budget adjustments and relay caching reduced refactor costs by 60%.
Workflow
- Configure Cursor plugin with "includeTests": true and maxTokens 4096.
- Run CI tests; plugin indexes unit tests but omits e2e/ due to token limit.
- Deploy to production; crash occurs on first request.
- Investigate logs; identify missing e2e test case causing schema failure.
- Update .cursorrules to enforce e2e coverage and increase maxTokens to 8192.
- Add "includePaths": ["e2e/"] to plugin manifest.
- Add pre‑commit hook to fail if e2e/ is missing from context.
- Re‑run CI; verify Show Context panel includes e2e/.
- Deploy again; service runs correctly.
- Benchmark token usage across providers; adopt B‑Lost relay for cost savings.
Evidence
our integration test that exercised the actual production schema path lived in a separate e2e/ directory outside the plugin's default file tree traversal
Cursor plugins use a breadth-first file traversal with token budget enforcement. When you hit maxTokens, later directories get silently omitted from context—no warning, no error.
The 3-line fix in .cursorrules: 1. ALWAYS run pytest e2e/ -v before claiming tests pass 2. Verify e2e/ directory is in working set via 'Show Context' panel 3. Reject any schema change if e2e coverage drops below baseline
- Record date: 2026-10-18T23:41:07.294Z