Keep OpenCode/Codex chat and stage sessions running across server restarts

A stopping server no longer interrupts harness sessions. Runs are canceled
with a shutdown cause, so stage clients leave admitted sessions running and
owned; start-up recovery re-adopts live OpenCode V2 stage sessions (wait,
read back the result, continue the graph), restarts unadmitted visits,
continues runs between stages, and falls back to interrupted with a reason
when the harness is gone. Chats with live work are recorded on shutdown and
reattached on start; turns that ended during the downtime are folded in
from history. The server-spawned V2 chat serve is now a detached owned
service. PIPELINES_SHUTDOWN_SESSIONS=stop restores the old behaviour.
This commit is contained in:
2026-11-04 16:17:08 +00:00
parent 9351cd7d74
commit aa8eddd686
26 changed files with 2318 additions and 99 deletions
+7
View File
@@ -304,6 +304,13 @@ func (c *Chat) Interrupt(ctx context.Context, id string) error {
return nil
}
// DetachSessions is the server-restart shutdown. Sessions, turns, questions,
// permissions and shells live in the OpenCode service, not in this adapter, so
// there is nothing to stop: the connection's owner decides whether the service
// itself outlives the server (an attached endpoint and the detached owned chat
// service do; a V1 serve child does not).
func (c *Chat) DetachSessions() {}
// Messages reads one session's stored turns. On the owned serve backend it
// reuses Connection.Messages, including its read-only OutputFormat readback
// fallback, instead of duplicating that path. It maps the verified assistant