Skip to content

fix: suppress nudge when all content is protected - #158

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-07-18_suppress-nudge-no-compressible
Closed

ranxianglei wants to merge 2 commits into
masterfrom
2026-07-18_suppress-nudge-no-compressible

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Summary

When all context is protected (e.g., user puts read in protectedTools and all messages contain read calls), the nudge still fires uselessly — model receives "go compress" but has nothing to compress.

PR #147's filterSuppressed only handles the case where compressible ranges exist but are filtered out. This PR adds the missing case: compressible.length === 0 && protected.length > 0 → all protected → suppress nudge.

Emergency override (98% context) still fires regardless.

Fix

lib/messages/inject/inject.ts:

const allProtected = contextRanges.compressible.length === 0 && contextRanges.protected.length > 0
const nothingToCompress = filterSuppressed || allProtected
const shouldInject = nudgeAllowed && (!nothingToCompress || emergencyOverride)

The protected.length > 0 check distinguishes "all protected" from "no refs assigned yet" (both arrays empty — edge case, not suppression).

Tests

  • "nudge suppressed when all content is protected (nothing to compress)"
  • "emergency override fires even when all content is protected"

752/752 tests pass.

ranxianglei and others added 2 commits July 18, 2026 21:54
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
ranxianglei added a commit that referenced this pull request Jul 18, 2026
…io A coverage

Dual-agent review (Oracle #2) found that 4 "all protected" tests included
userMsg("u1", ...) which made compressible non-empty, so tests passed via
filterSuppressed instead of the allProtected branch added in PR #158.

Fix: remove userMsg from allProtected tests so compressible is genuinely empty.
Add Scenario A test: voluntary compress after suppression correctly skips
proportional baseline adjustment (wasNudgeTriggered=false).
ranxianglei added a commit that referenced this pull request Jul 18, 2026
* fix: suppress nudge when all content is protected (nothing to compress)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

* docs: devlog for suppress-nudge-no-compressible

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

* fix: advance nudge baseline when suppressed for discrete 5% check intervals

When nudge is triggered but suppressed (nothing to compress), advance the baseline to currentTokens so the next check fires at +5% instead of every turn. Also clear pending nudge (lastNudgeShownTokens) so threshold resets to full.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

* docs: devlog for compressible-growth baseline advance

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

* test: fix allProtected tests to exercise intended branch + add Scenario A coverage

Dual-agent review (Oracle #2) found that 4 "all protected" tests included
userMsg("u1", ...) which made compressible non-empty, so tests passed via
filterSuppressed instead of the allProtected branch added in PR #158.

Fix: remove userMsg from allProtected tests so compressible is genuinely empty.
Add Scenario A test: voluntary compress after suppression correctly skips
proportional baseline adjustment (wasNudgeTriggered=false).

---------

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@ranxianglei

Copy link
Copy Markdown
Owner Author

Superseded by #159#159's branch was based on this PR and the squash merge included all of #158's commits + test fixes + Scenario A coverage. Closing in favor of #159 which is now merged to master.

@ranxianglei
ranxianglei deleted the 2026-07-18_suppress-nudge-no-compressible branch July 18, 2026 14:53
ranxianglei added a commit that referenced this pull request Jul 18, 2026
…rotected label + nudge fixes (#160)

* release: v1.12.10-dev.1 — protected label + nudge suppression + discrete intervals

Bundles PRs #157 (protected label accuracy), #158 (allProtected suppress), #159 (discrete 5% check intervals). Prerelease for testing on npm dev tag.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

* chore: remove stray Gitea API dump from release branch

* docs: changelog includes PR #73 (decompress range mode) and #155 (token classification)

---------

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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