Skip to content

Recover capped and empty compaction summaries - #20

Merged
hawkff merged 1 commit into
mainfrom
fix/compaction-recovery
Oct 8, 2026
Merged

hawkff merged 1 commit into
mainfrom
fix/compaction-recovery

Conversation

@hawkff

@hawkff hawkff commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Limit compaction thinking to low without changing chat settings. Retry capped or empty summaries once, count both attempts' usage, and reject incomplete checkpoints.

Keep Pi's native history selection, file tracking, cancellation, and transient retries. Update the Pi development dependencies to 1.1.0 and document the behavior against CLIProxyAPI 8.0.22.

Summary by CodeRabbit

  • New Features
    • Compaction summaries can recover from capped or empty responses with a retry, while incomplete results are not saved.
    • Compaction requests limit reasoning to low or minimal and preserve usage information across retries.
  • Documentation
    • Updated documented target versions and added details about compaction behavior, retained history, usage, and retry conditions.

Note

Add withCompactionRecovery to retry capped and empty compaction summaries

  • Adds a compaction recovery wrapper in compaction.ts that applies only to requests whose signal is a registered compaction signal. It forces low reasoning, removes chat thinking budgets, and caps the output allowance by the model limit.
  • Retries once with a larger allowance when the first summary is length-limited or has no text. Usage and costs from both attempts are combined. Aborts, tool calls, provider errors, and invalid summaries become errors instead of saved checkpoints.
  • The extension records compaction signals in a session-before-compaction listener and passes them to the provider in index.ts; provider.ts routes the wrapper onto the simple stream only.
  • Raises Pi package dependencies to the 1.1.0 range and updates README.md with a Compaction section.
  • Risk: empty or thinking-only summaries that fail the retry now surface as errors where they previously became text checkpoints; check withCompactionRecovery in compaction.ts for consumers relying on old empty-summary behavior.

Macroscope summarized 9dd18f1.

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable defects were established.

Summary

Adds recovery for capped or empty compaction summaries without changing chat settings.

  • Marks compaction requests through session_before_compact.
  • Limits thinking to low and retries eligible summaries once.
  • Adds both attempts’ usage to the final response.
  • Adds tests for native compaction behavior and updates Pi development dependencies to 1.1.0.

No actionable issues were established. Tests were not run; dependencies were not installed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Provider request] --> B{Marked compaction signal?}
    B -->|No| C[Original stream unchanged]
    B -->|Yes| D[Limit thinking and output budget]
    D --> E[Request summary]
    E --> F{Empty or capped with room to grow?}
    F -->|Yes, not cancelled, no tool calls| G[Retry once]
    G --> H[Add usage from both attempts]
    F -->|No| I[Check final response]
    H --> I
    I --> J[Return final result to Pi compactor]
Loading

Reviews (1) · Last reviewed commit: "Recover capped and empty compaction summ..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f0555876-2144-4d55-8fbc-d18496847dd9
📥 Commits

Reviewing files that changed from the base of the PR and between 7f78429 and 9dd18f1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • README.md
  • extensions/index.ts
  • package.json
  • src/compaction.ts
  • src/provider.ts
  • test/compaction.test.ts
  • test/package.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The extension now identifies compaction requests through their abort signals and routes them through a provider stream wrapper. The wrapper retries qualifying incomplete summaries and reports completion or failure. Tests and documentation cover the recovery behavior and its constraints.

Changes

Compaction recovery

Layer / File(s) Summary
Compaction signal routing
package.json, extensions/index.ts, src/provider.ts
The extension records session_before_compact abort signals and passes the set to the provider. Routed streamSimple calls use the recovery wrapper. Pi development dependency ranges were updated to ^1.1.0.
Recovery behavior and validation
src/compaction.ts, test/compaction.test.ts, test/package.test.ts, README.md
The wrapper applies bounded summary settings and retries eligible incomplete responses once. Tests cover retry conditions, usage aggregation, integration scenarios, and package contents. The README documents the behavior, limitations, and updated target versions.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Pi
  participant Extension as extensions/index.ts
  participant Provider as createCliproxyProvider
  participant Recovery as withCompactionRecovery
  participant Stream as provider streamSimple
  Pi->>Extension: session_before_compact(abortSignal)
  Extension->>Extension: record abortSignal in WeakSet
  Extension->>Provider: pass compactionSignals
  Provider->>Recovery: wrap streamSimple
  Pi->>Recovery: request compaction summary
  Recovery->>Stream: send request with bounded summary settings
  Stream-->>Recovery: return response
  alt response is capped or empty and retry is allowed
    Recovery->>Stream: retry with increased output allowance
    Stream-->>Recovery: return retry response
  end
  Recovery-->>Pi: emit completion or error
Loading

Merge Risk: ⚪ Minimal · up to 9dd18

This change limits compaction thinking to low and retries capped or empty summaries once. Incomplete checkpoints are rejected rather than saved. No merge-blocking risk was identified in the supplied context.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: recovery for capped and empty compaction summaries.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hawkff
hawkff merged commit 9727edf into main Oct 8, 2026
6 checks passed
@hawkff
hawkff deleted the fix/compaction-recovery branch October 8, 2026 23:07
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