mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-21 10:16:03 +00:00
feat(core): interrupt v2 session execution (#30850)
This commit is contained in:
+8
-1
@@ -18,6 +18,13 @@ sessions.prompt({ id?, sessionID, prompt, delivery?, resume? })
|
||||
-> exact retry schedules another wake unless resume is false
|
||||
-> resume omitted or true schedules execution after admission
|
||||
-> resume false admits only
|
||||
|
||||
sessions.interrupt(sessionID)
|
||||
-> interrupts the active ownership chain on this process
|
||||
-> waits for active drain cleanup and settlement
|
||||
-> suppresses reruns already queued before interruption
|
||||
-> preserves durable inbox rows for a later fresh wake or resume
|
||||
-> idle or missing Session is a no-op
|
||||
```
|
||||
|
||||
`session_input` is the durable admission inbox. Admitted inputs remain outside model-visible Session history until the serialized runner publishes `PromptLifecycle.Promoted`. The projector atomically writes the visible user message and marks its inbox row promoted in the same event transaction. The legacy V1-to-V2 shadow bridge continues publishing ordinary `Prompted` events for already-visible V1 prompts.
|
||||
@@ -141,7 +148,7 @@ Execution has two entry points:
|
||||
|
||||
Post-crash activity recovery is intentionally deferred. A wake does not infer that ambiguous provider work is safe to retry after an input has already been promoted. Explicit `run` may deliberately continue from durable projected history. A future recovery slice should model durable activity identity, provider-dispatch ambiguity, required continuation, queue-opener reservation, retry policy, and visible recovery status together.
|
||||
|
||||
A location-scoped `SessionRunCoordinator` serializes each Session drain chain while allowing different Sessions to drain concurrently. Automatic startup discovery, durable multi-node ownership, stale-owner fencing, interruption controls, and retry policy remain future work.
|
||||
A process-global `SessionRunCoordinator` serializes each local Session drain chain while allowing different Sessions to drain concurrently. It enters the Session's current Location only when a drain starts, so interruption targets process execution ownership rather than Location cache identity. Interruption establishes a local ownership-chain boundary by stopping the current chain while preserving pending/unpromoted durable inbox rows for a later fresh wake and projected history for explicit resume. A Location runner also fences every new provider turn against its captured Location so a moved Session cannot begin another turn through source-Location tools or context. An already-dispatched provider turn may still settle source-Location calls until a future move-control slice interrupts active ownership. Automatic startup discovery, durable multi-node ownership, stale-owner fencing, and retry policy remain future work.
|
||||
|
||||
Inbox promotion coalesces pending steers in durable admission order and opens one queued activity at a time in FIFO order. Add explicit inbox backlog and steering-batch limits before exposing broad multi-caller admission or untrusted queue growth.
|
||||
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ through legacy `SessionPrompt.loop(...)`:
|
||||
Prompt admission now uses a durable `session_input` inbox rather than immediate
|
||||
transcript projection. `steer` inputs coalesce into the active activity at the
|
||||
next safe provider-turn boundary. `queue` inputs form a FIFO of future activities
|
||||
that open one at a time. A location-scoped `SessionRunCoordinator` coalesces process-local wakeups
|
||||
that open one at a time. A process-global `SessionRunCoordinator` coalesces process-local wakeups
|
||||
around settlement races. Explicit `run` resumes perform at least one provider
|
||||
attempt; advisory `wake` notifications call the provider only for eligible inbox
|
||||
work. Steers coalesce into the active activity at
|
||||
@@ -55,7 +55,7 @@ Next reviewed slices:
|
||||
- integrate the new BackgroundJob service with V2 tool execution: support background
|
||||
bash jobs and background agent dispatch with durable status observation,
|
||||
completion delivery, and explicit cancellation / continuation semantics
|
||||
- add compaction, interruption, retries, and stale-owner fencing
|
||||
- add compaction, durable/clustered interruption, retries, and stale-owner fencing
|
||||
only as their slices become concrete
|
||||
|
||||
### Deferred durable activity recovery
|
||||
|
||||
Reference in New Issue
Block a user