Skip to content

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

@code-yeongyu

Description

@code-yeongyu

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

Summary

When session recovery handles certain errors (thinking block, tool result missing), it sends "continue" to resume the session without any compaction occurring. This can be confusing to users who see "Continue" appear unexpectedly.

Root Cause

src/index.ts lines 604-612:

if (event.type === "session.error") {
  // ...
  if (recovered && sessionID && sessionID === getMainSessionID()) {
    await ctx.client.session
      .prompt({
        path: { id: sessionID },
        body: { parts: [{ type: "text", text: "continue" }] },
        query: { directory: ctx.directory },
      })
      .catch(() => {});
  }
}

Affected Error Types

  • thinking_block_order - thinking block structure errors
  • thinking_disabled_violation - thinking blocks when thinking is disabled
  • tool_result_missing - missing tool results after ESC/abort

Flow

  1. Session error occurs (e.g., thinking block issue)
  2. sessionRecovery.handleSessionRecovery() fixes the message structure
  3. If recovery succeeds → "continue" is sent
  4. No compaction happened, but user sees "Continue" appear

Potential Duplicate Issue

Additionally, when experimental.auto_resume is enabled:

  1. session-recovery/index.ts lines 396-400, 403-407 already call resumeSession() which sends "[session recovered - continuing previous task]"
  2. Then index.ts line 608 ALSO sends "continue"
  3. This could result in double resume messages

Questions to Resolve

  1. Should "continue" be sent after session error recovery at all?
  2. If yes, should it be conditional on experimental.auto_resume?
  3. Should the duplicate with resumeSession() inside handleSessionRecovery() be resolved?

Suggested Fix Options

Option A: Remove the "continue" from index.ts entirely, rely on auto_resume in session-recovery

// Remove lines 604-612 from index.ts
// Let session-recovery handle resumption when auto_resume is enabled

Option B: Make it conditional on NOT having auto_resume

if (recovered && sessionID && sessionID === getMainSessionID()) {
  // Only send continue if auto_resume didn't already handle it
  if (!pluginConfig.experimental?.auto_resume) {
    await ctx.client.session.prompt({...})
  }
}

Option C: Add a toast notification so user understands what happened

if (recovered && sessionID && sessionID === getMainSessionID()) {
  await ctx.client.tui.showToast({
    body: {
      title: "Session Recovered",
      message: "Fixed message structure issue. Resuming...",
      variant: "success",
      duration: 2000,
    },
  }).catch(() => {});
  await ctx.client.session.prompt({...})
}

Environment

  • oh-my-opencode version: latest (dev branch)
  • Discovered: 2025-01-01

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions