Repository navigation
Description
Description
A prompt can remain indefinitely in the durable inbox if the process dies after admitting it but before its execution claim is recorded. Startup recovery scans claimed sessions, so this admitted prompt is not resumed until another action wakes the session. The prompt is durable but effectively stuck. The earlier source-review report #51746 was automatically closed for template compliance and invited a new report; this reproduction exercises the admission and recovery implementation.
Steps to reproduce
On dev commit 82666b6612cdb2ba13a7a26e150b21e897a80373, save this script to /tmp/oc-recovery-gap.ts and run from packages/core:
bun -e "$(cat /tmp/oc-recovery-gap.ts)"import { Effect, Layer } from 'effect'
import { AppNodeBuilder } from '@opencode/core/effect/app-node-builder'
import { LayerNode } from '@opencode/util/effect/layer-node'
import { Database } from '@opencode/core/database/database'
import { Bus } from '@opencode/core/bus'
import { Job } from '@opencode/core/job'
import { Session } from '@opencode/core/session'
import { SessionRestart } from '@opencode/core/session/execution/restart'
import { SessionExecution } from '@opencode/core/session/execution'
import { SessionProjector } from '@opencode/core/session/projector'
import { SessionInbox } from '@opencode/core/session/inbox'
import { SessionMessage } from '@opencode/core/session/message'
import { SessionStore } from '@opencode/core/session/store'
import { SessionTable, SessionInboxTable } from '@opencode/core/session/sql'
import { Project } from '@opencode/core/project'
import { ProjectTable } from '@opencode/core/project/sql'
import { AbsolutePath } from '@opencode/core/schema'
const calls=[]
const layer=AppNodeBuilder.build(LayerNode.group([Database.node,Bus.node,SessionProjector.node,SessionInbox.node,SessionStore.node,Job.node,Session.node]),[Bus.node.replace(Bus.configured({persist:true}))])
await Effect.runPromise(Effect.gen(function*(){
const database=yield* Database.Service;const db=database.db;const store=yield* SessionStore.Service;const bus=yield* Bus.Service;const jobs=yield* Job.Service;const sessions=yield* Session.Service
const id=Session.ID.make('ses_crash_gap');yield* db.insert(ProjectTable).values({id:Project.ID.global,worktree:AbsolutePath.make('/project'),sandboxes:[]}).onConflictDoNothing().run();yield* db.insert(SessionTable).values({id,project_id:Project.ID.global,slug:id,directory:'/project',title:id,version:'test'}).run()
const admission=yield* SessionInbox.Service; yield* admission.admit({id:SessionMessage.ID.create(),sessionID:id,item:{type:'user',payload:{text:'Please fix the bug'},delivery:'steer'}})
const execution=SessionExecution.Service.of({active:Effect.succeed(new Set()),isActive:()=>Effect.succeed(false),resume:(id)=>Effect.sync(()=>calls.push(id)),wake:()=>Effect.void,interrupt:()=>Effect.succeed(false),awaitIdle:()=>Effect.void})
const restart=yield* SessionRestart.Service.pipe(Effect.provide(SessionRestart.layer().pipe(Layer.provide(Layer.succeed(SessionStore.Service,store)),Layer.provide(Layer.succeed(Bus.Service,bus)),Layer.provide(Layer.succeed(Job.Service,jobs)),Layer.provide(Layer.succeed(Session.Service,sessions)),Layer.provide(Layer.succeed(SessionExecution.Service,execution)))))
console.log('before',JSON.stringify({pending:yield* SessionInbox.list(db,id),suspended:yield* store.listSuspended()}))
yield* restart.resumeSuspendedSessions
console.log('after',JSON.stringify({pending:yield* SessionInbox.list(db,id),resumes:calls}))
}).pipe(Effect.provide(layer)))The script uses real SQLite, durable event projection, SessionInbox.admit, SessionStore, and SessionRestart. It creates the database state corresponding to a crash between admission and execution claim, then runs startup recovery. SessionExecution is a recording fixture. It does not kill a real process or exercise Session.prompt end-to-end.
Actual: before recovery the prompt is pending and the suspended-claim list is empty; after recovery the prompt is still pending and no resume was requested. Expected: a prompt admitted with automatic execution intended should be recovered after restart, while preserving the separate resume: false admit-only behavior. Currently that intent is not represented in this simulated inbox row, which is relevant to designing a fix.
OpenCode version
Source dev commit 82666b6612cdb2ba13a7a26e150b21e897a80373; the current upstream restart file differs only in unrelated image notification metadata.
Operating system
macOS (Bun).
Activity
opencodejr commentedon Oct 30, 2026
Thanks for the detailed report and script. I could reproduce this on the latest
dev(95fc3c8).The script below follows yours. It uses the real SQLite, persisted bus, projector,
SessionInbox,SessionStore,JobandSessionservices, admits asteeruser prompt to a session with no execution claim, and then runsSessionRestart.resumeSuspendedSessionswith an execution stub that records resume calls. The prompt is pending before and after recovery,listSuspended()is empty, and no resume is requested.In the code,
Session.promptwrites the prompt to the inbox first and only then callsexecution.wake, while startup recovery only looks at sessions that already have a claim (time_suspended) plus running subagent children. Nothing scans pending inbox items, and the inbox row does not record whether automatic execution was intended. So a crash between those two steps leaves the prompt pending until something else wakes the session.Related issues:
Reproduction script (oc-recovery-gap.ts)
Run it:
bun oc-recovery-gap.ts