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
@@ -18,6 +18,7 @@ func fakeExecutionService(t *testing.T) {
t.Setenv("HOME", t.TempDir()) // os.UserCacheDir uses HOME on macOS, not XDG_CACHE_HOME.
state := t.TempDir()
t.Setenv(opencode.OpenCodeServiceStateEnvKey, state)
t.Setenv(opencode.StageServiceEnvKey, "shared") // fixture models the shared CLI-managed service
t.Setenv("XDG_CACHE_HOME", t.TempDir())
if err := os.Mkdir(filepath.Join(state, "opencode"), 0700); err != nil {
t.Fatal(err)
@@ -33,6 +34,7 @@ func TestV2StagePersistsExecutionReferenceBeforePrompt(t *testing.T) {
t.Setenv("HOME", t.TempDir())
state := t.TempDir()
t.Setenv(opencode.OpenCodeServiceStateEnvKey, state)
t.Setenv(opencode.StageServiceEnvKey, "shared")
t.Setenv("XDG_CACHE_HOME", t.TempDir())
t.Setenv(opencode.EndpointEnvKey, "http://127.0.0.1:2")
t.Setenv("OPENCODE_PASSWORD", "foreign")
@@ -98,6 +100,7 @@ func TestV2ColdDiscoveryWithoutRegistrationNeverCreatesSession(t *testing.T) {
t.Setenv("HOME", t.TempDir())
root := t.TempDir()
t.Setenv(opencode.OpenCodeServiceStateEnvKey, root)
t.Setenv(opencode.StageServiceEnvKey, "shared")
t.Setenv("XDG_CACHE_HOME", t.TempDir())
t.Setenv(opencode.EndpointEnvKey, "http://127.0.0.1:1")
marker := filepath.Join(root, "cli-calls")