Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Notes from a 2 AM On-Call: When Cursor Plugin Context Windows Silently Truncate

说明与用途

Cursor 插件因令牌限制而忽略了 e2e 目录,导致在重构 Pydantic 模型后生产环境崩溃。通过将 e2e 包含在上下文、提高令牌上限并添加 pre‑commit 检查,避免了后续故障。

问题

Cursor AI plugin omitted critical e2e tests from context due to token budget, causing a production crash after refactoring Pydantic models.

结果

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%.

工作流

  • 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.

证据

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

来源

  • 记录日期: 2026-10-18T23:41:07.294Z