opencode/packages/core
Kit Langton 2f0dd2ebc5 fix(core): bound concurrent session resumes after restart
After a server restart every suspended session and recovered subagent resumed at once (concurrency unbounded), so ~40 turns hit their first model request together and froze the host.

Resumes now go through a Semaphore (Options.maxConcurrentResumes, default 3). The permit is taken on the sweep fiber before the attempt is counted, and held until the resumed turn's first step ends or fails (session.step.ended / session.step.failed, subscribed before the turn starts), the turn ends, or 60 seconds pass. It is never released just because the resume fiber was forked.

- Shell notices first, then settled subagent results, then running subagent children through the gate, then suspended sessions most recently updated first (listSuspended now orders by time_updated desc).
- countResume and the 'Continuing after restart' synthetic run inside the slot, so queued sessions are not charged an attempt until they start. Ownership (local job, child/parent existence, active execution, claim) is re-checked at admission.
- Each session leaves the early-notice set as soon as its own resume is accounted for, so a parent that already resumed and went idle is still woken by a child result while older sessions wait in line.
- resumeSuspendedSessions completes once every resume has started rather than right away. Existing tests assert accounting as soon as it returns, and every caller already forks it.

Attempt budget and shell recovery are unchanged.
2026-10-25 05:23:11 -07:00
..
script refactor(ai): make Promise the root entry and move Effect to @opencode/ai/effect (#58847) 2026-10-24 22:18:23 -05:00
src fix(core): bound concurrent session resumes after restart 2026-10-25 05:23:11 -07:00
test fix(core): bound concurrent session resumes after restart 2026-10-25 05:23:11 -07:00
bunfig.toml refactor(core): simplify integration test fixtures (#33292) 2026-06-22 04:15:34 +00:00
drizzle.config.ts refactor(core): move database schema ownership (#29068) 2026-05-30 21:08:38 -04:00
package.json sync release versions for v2.1.4 [skip ci] 2026-10-23 10:15:01 +00:00
README.md refactor(packages): migrate to the opencode npm scope (#47852) 2026-09-07 17:19:33 -04:00
schema.json refactor(core): keep Go allowance out of messages and sessions (#58765) 2026-10-24 13:05:02 -05:00
sst-env.d.ts refactor: rename shared package to core (#24309) 2026-04-25 10:59:17 -04:00
tsconfig.build.json feat(core): configure package publishing 2026-08-12 09:30:34 -04:00
tsconfig.json chore: upgrade typecheck to TypeScript 7.0.2 (#56300) 2026-10-17 13:26:46 -07:00
tsconfig.tests.json chore: upgrade typecheck to TypeScript 7.0.2 (#56300) 2026-10-17 13:26:46 -07:00

@opencode/core

Core runtime services for OpenCode.