feat(opencode): single-process shared opencode serve for all conversations (opt-in) - #984
Open
leehom0123 wants to merge 1 commit into
Open
feat(opencode): single-process shared opencode serve for all conversations (opt-in)#984leehom0123 wants to merge 1 commit into
leehom0123 wants to merge 1 commit into
Conversation
…ode serve process (opt-in) Every opencode conversation spawns its own \opencode acp\ child today; a few conversations mean several full bun runtimes. With AIONUI_OPENCODE_SHARED_SERVER=on, all opencode conversations instead attach to ONE pooled \opencode serve\ over its HTTP/SSE v2 API (durable per-session events, poll-discovered permission/question pendings, active-map turn closure), as a Session(Arc<dyn SessionBackend>) like codex/claude. - new module aionui-ai-agent/src/opencode_shared (pool/client/backend/translate) - toggle-gated factory branch: default OFF keeps the ACP path byte-identical - build_opencode_instance mirrors the antigravity third-backend template - lease-based server lifecycle: last lease down => server down (own pid only) - 16 unit tests + live E2E (single server hosts >=2 conversations, permission approval round-trip, crash => Detached => respawn) gated behind AIONUI_OPENCODE_E2E
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every opencode conversation spawns a dedicated
opencode acpchild — N conversations means N full bun runtimes (memory, startup, port pressure; the backdrop of the USER_AGENT_STARTUP_FAILED reports).Change
Opt-in (
AIONUI_OPENCODE_SHARED_SERVER=on; default OFF leaves the ACP path byte-identical) single-process mode: all opencode conversations attach via the existingAgentInstance::Session(Arc<dyn SessionBackend>)seam to ONE pooledopencode serveover its HTTP/SSE v2 API.opencode_sharedmodule: process pool (registry-backed adopt-or-spawn, watchdog, lease-counted teardown that only ever kills its own pid), v2 client, durable per-session SSE with cursor reconnect, event translator, permission/question poll-discovery, active-map turn closure.build_opencode_instancefollows the antigravity third-backend template.AIONUI_CONVERSATION_IDstripped).Testing
cargo test -p aionui-ai-agent: 984 pass (incl. 16 new unit tests for the translator/client/SSE parser; the 5terminal::testsfailures are pre-existing Windows env issues unrelated to this change).cargo check+clippy --all-targets+fmt --checkclean.tests/opencode_shared_e2e.rs, gated behindAIONUI_OPENCODE_E2E=1): one server process hosts >=2 conversations (single registry record, independent streams, full turn translation), resume across backend instances from theses_anchor, bash-permission approval round-trip via poll-discoveredPermissionevents, and server kill ->Detached-> automatic respawn. All green on Windows against opencode 1.18.30.