Skip to content

Add OpenCode skill waste detectors (closes #54)#160

Merged
willwashburn merged 4 commits intomainfrom
feat/opencode-skill-waste-detectors
Apr 28, 2026
Merged

Add OpenCode skill waste detectors (closes #54)#160
willwashburn merged 4 commits intomainfrom
feat/opencode-skill-waste-detectors

Conversation

@willwashburn
Copy link
Copy Markdown
Member

@willwashburn willwashburn commented Apr 28, 2026

Summary

  • Two new burn waste --patterns detectors gated to source === 'opencode':
    • opencode-skill-recall — flags repeated skill({name}) calls whose content is not deduplicated by OpenCode, reporting call count, turn range, and cost.
    • opencode-skill-pruning — tracks skill tool results that ride in the cache indefinitely (prune-protected by OpenCode's compaction), reporting riding turns, last cached turn, and cost.
  • ToolCall.skillName populated by the OpenCode reader so downstream detectors can group skill invocations without re-parsing args.
  • burn diagnose renders the new pattern types; burn waste --patterns --json includes them in output.
  • SessionPatternSummary gains skillRecallDupCount and skillPruningProtectionCount.

Files changed

Package Changes
@relayburn/reader ToolCall.skillName field; OpenCode reader extracts skill name from tool input
@relayburn/analyze SkillRecallDup + SkillPruningProtection interfaces + detectors; detectPatterns, PatternsResult, SessionPatternSummary extended
@relayburn/cli PATTERN_KINDS gains opencode-skill-recall and opencode-skill-pruning; rendering tables; burn diagnose updated

Tests

634 tests pass (8 new test cases for the skill detectors).


Open in Devin Review

Two new burn waste --patterns detectors gated to source === 'opencode':

- opencode-skill-recall: flags repeated skill({name}) calls whose content
  is not deduplicated by the agent, reporting callCount, turn range, and cost.
- opencode-skill-pruning: tracks skill tool results that ride in the cache
  indefinitely (prune-protected by OpenCode's compaction), reporting
  ridingTurns, lastCachedTurnIndex, and cost.

Also populates ToolCall.skillName in the OpenCode reader so downstream
detectors can group skill invocations without re-parsing args.
devin-ai-integration[bot]

This comment was marked as resolved.

Estimates the fixed prefix tax (system prompt + skill catalog) on the
first turn of an OpenCode session by subtracting the first user message
size from cacheCreate. Reports estimatedSystemPromptTokens, ridingTurns,
and total cost. Requires userTurnsBySession in DetectPatternsOptions.

New pattern kind: opencode-system-prompt. Renders in burn waste --patterns
and burn diagnose alongside the other detectors.
devin-ai-integration[bot]

This comment was marked as resolved.

- `burn diagnose` now passes `userTurnsBySession` into `detectPatterns`,
  so the OpenCode system-prompt-tax detector actually runs (the diagnose
  call was previously silently emitting `(none)` because the detector
  bails when user-turn data is absent).
- Drop the dead `compactionTurnIndexes` set built but never used in
  `detectSkillPruningProtectionForSession`; skill tool results are
  prune-protected, so compaction boundaries don't bound riding-turn
  counts. The function no longer takes a `compactions` parameter.
devin-ai-integration[bot]

This comment was marked as resolved.

`detectSystemPromptTaxForSession` was iterating over every turn including
the first when computing `ridingTurns`. The header comment says
"subsequent" — and the sister `detectSkillPruningProtectionForSession`
correctly skips its anchor turn. On a resumed OpenCode session the first
turn can carry `cacheRead > 0`, which would otherwise inflate both the
riding count and totalCost. Added a regression test for the resumed-session
shape.
@willwashburn willwashburn merged commit e2260e1 into main Apr 28, 2026
2 checks passed
@willwashburn willwashburn deleted the feat/opencode-skill-waste-detectors branch April 28, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant