Run OpenCode stages on a Pipelines-owned stage service with their own limits

Stages now run on a detached Pipelines-owned opencode serve started with
OPENCODE_CONFIG_CONTENT carrying stage tool_output (16384 bytes / 400 lines)
and compaction.auto defaults, configurable through PIPELINES_OPENCODE_STAGE_*.
Chats keep their existing service and configuration; a server-spawned chat
serve can take PIPELINES_OPENCODE_CHAT_CONFIG. The service shares the user's
OpenCode config, credentials and session database, keeps a stable private
registration so retained references (recovery, interrupt, export) stay valid,
revives on the same port after a crash, replaces itself when idle after a
settings change, and is stopped on shutdown only when idle.
PIPELINES_OPENCODE_STAGE_SERVICE=shared restores the previous behaviour.
This commit is contained in:
2026-11-04 14:04:35 +00:00
parent fa6c0864db
commit b655278674
12 changed files with 977 additions and 15 deletions
+3
View File
@@ -137,6 +137,9 @@ func main() {
defer chats.Close()
}
srv := &http.Server{Addr: *addr, Handler: server.HandlerWithOptions(ctx, options, store), ReadHeaderTimeout: 5 * time.Second}
// Deferred before WaitRuns so it runs after the runs settle: the owned stage
// service is stopped only when no stage session is still active on it.
defer opencode.StopIdleStageService()
defer server.WaitRuns(srv.Handler)
go func() {
<-ctx.Done()