[PR #5261] lsp: budget diagnostics to cap token noise #11311

Closed
opened 2026-02-16 18:16:07 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5261

State: closed
Merged: No


Summary

  • Cap LSP diagnostics to reduce token/latency overhead while keeping high-signal errors
  • Limits: 50 diags per file, 8 KB total payload, messages trimmed to 200 chars, deduped; summary when truncated
  • Tests: diagnostics budget caps + preserves highest-severity; typecheck

Benchmarks

  • Synthetic (300 noisy diags + 5 errors): 70,742 chars → 8,116 chars (~88.5% reduction); noisy kept 33 entries (incl. top severity + summary); clean kept 5/5.
  • Live OpenRouter API agent(gpt-4o-mini) end-to-end:
    • Prompt: raw 70,742 chars → budgeted 8,116 chars
    • Tokens/cost: raw prompt 13,109 / completion 1,396 / total 14,505;
      budgeted prompt 1,619 / completion 493 / total 2,112 (≈85% fewer total tokens). Cost: /bin/zsh.00188235 → /bin/zsh.00046185 (~75% cheaper)
    • Latency: raw ~25.2s → budgeted ~9.4s (≈2.7× faster)
    • Response quality: top severity items preserved; budgeted output still lists the real errors (err-0..err-4) plus top warn-* entries.

Tests

  • bun test packages/opencode/test/lsp/diagnostics-budget.test.ts
  • bun test packages/opencode/test/lsp/diagnostics-budget-agent-signal.test.ts
  • bun run typecheck
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5261 **State:** closed **Merged:** No --- ## Summary - Cap LSP diagnostics to reduce token/latency overhead while keeping high-signal errors - Limits: 50 diags per file, 8 KB total payload, messages trimmed to 200 chars, deduped; summary when truncated - Tests: diagnostics budget caps + preserves highest-severity; typecheck ## Benchmarks - Synthetic (300 noisy diags + 5 errors): 70,742 chars → 8,116 chars (~88.5% reduction); noisy kept 33 entries (incl. top severity + summary); clean kept 5/5. - Live OpenRouter API agent(gpt-4o-mini) end-to-end: - Prompt: raw 70,742 chars → budgeted 8,116 chars - Tokens/cost: raw prompt 13,109 / completion 1,396 / total 14,505; budgeted prompt 1,619 / completion 493 / total 2,112 (≈85% fewer total tokens). Cost: /bin/zsh.00188235 → /bin/zsh.00046185 (~75% cheaper) - Latency: raw ~25.2s → budgeted ~9.4s (≈2.7× faster) - Response quality: top severity items preserved; budgeted output still lists the real errors (err-0..err-4) plus top warn-* entries. ## Tests - bun test packages/opencode/test/lsp/diagnostics-budget.test.ts - bun test packages/opencode/test/lsp/diagnostics-budget-agent-signal.test.ts - bun run typecheck
yindo added the pull-request label 2026-02-16 18:16:07 -05:00
yindo closed this issue 2026-02-16 18:16:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11311