Skip to content

fix: trigger compaction before continue after session error recovery (fixes #390)#2766

Merged
code-yeongyu merged 1 commit intodevfrom
fix/issue-390
Mar 23, 2026
Merged

fix: trigger compaction before continue after session error recovery (fixes #390)#2766
code-yeongyu merged 1 commit intodevfrom
fix/issue-390

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented Mar 23, 2026

Problem

After session error recovery, "continue" is sent to resume without compaction, potentially causing duplicate continuation or oversized context.

Fix

Trigger compaction before sending "continue" in the session error recovery handler.

Fixes #390

Automated fix by Sisyphus (oh-my-opencode)


Summary by cubic

Trigger compaction before resuming after session error recovery to prevent duplicate continuation and oversized context. If compaction fails, we still resume. Fixes #390.

  • Bug Fixes
    • Call session.summarize before session.prompt in the recovery path; log failures without blocking resume.
    • Add tests to verify summarize-before-prompt order and fallback when compaction errors.

Written for commit 4c4760a. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Confidence score: 2/5

  • There is a high-confidence, user-facing failure in src/plugin/event.ts: the summarize request body omits providerID and modelID, which is expected to trigger a 400 Bad Request.
  • Given the severity (9/10) and certainty (10/10), this is likely to break core summarize behavior rather than a minor edge case, so merge risk is high until addressed.
  • Pay close attention to src/plugin/event.ts - missing required payload fields for the summarize API call can cause immediate request failures.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/plugin/event.ts">

<violation number="1" location="src/plugin/event.ts:507">
P0: Custom agent: **Opencode Compatibility**

The `summarize` API call will fail with a 400 Bad Request because `providerID` and `modelID` are missing from the request body payload.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +507 to +511
// Trigger compaction before sending "continue" to avoid double-sending continuation
await pluginContext.client.session
.summarize({
path: { id: sessionID },
body: { auto: true },
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0: Custom agent: Opencode Compatibility

The summarize API call will fail with a 400 Bad Request because providerID and modelID are missing from the request body payload.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/plugin/event.ts, line 507:

<comment>The `summarize` API call will fail with a 400 Bad Request because `providerID` and `modelID` are missing from the request body payload.</comment>

<file context>
@@ -502,6 +504,17 @@ export function createEventHandler(args: {
             sessionID === getMainSessionID() &&
             !hooks.stopContinuationGuard?.isStopped(sessionID)
           ) {
+            // Trigger compaction before sending "continue" to avoid double-sending continuation
+            await pluginContext.client.session
+              .summarize({
</file context>
Suggested change
// Trigger compaction before sending "continue" to avoid double-sending continuation
await pluginContext.client.session
.summarize({
path: { id: sessionID },
body: { auto: true },
// Trigger compaction before sending "continue" to avoid double-sending continuation
const providerID = resolveFallbackProviderID(sessionID, props?.providerID as string | undefined);
const modelID = (props?.modelID as string | undefined) || lastKnownModelBySession.get(sessionID)?.modelID || getSessionModel(sessionID)?.modelID || "claude-opus-4-6";
await pluginContext.client.session
.summarize({
path: { id: sessionID },
body: { providerID, modelID, auto: true },
Fix with Cubic

@code-yeongyu code-yeongyu merged commit 6a56c0e into dev Mar 23, 2026
8 checks passed
@code-yeongyu code-yeongyu deleted the fix/issue-390 branch March 23, 2026 09:39
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.

Bug: 'continue' sent without compaction after session error recovery

1 participant