Skip to content

fix(opencode): stream persistent HTTP sessions#1535

Open
zmlgit wants to merge 6 commits into
chenhg5:mainfrom
zmlgit:codex-opencode-http-sse-background
Open

fix(opencode): stream persistent HTTP sessions#1535
zmlgit wants to merge 6 commits into
chenhg5:mainfrom
zmlgit:codex-opencode-http-sse-background

Conversation

@zmlgit

@zmlgit zmlgit commented Jul 13, 2026

Copy link
Copy Markdown

Summary

  • Add an optional OpenCode connection_url mode that talks to opencode serve over HTTP and keeps /event SSE connected before prompts are sent.
  • Stream assistant text/reasoning/tool/status events from SSE while the synchronous /session/{id}/message request is still running, preserving progress updates and background callbacks.
  • Forward OpenCode permission/question requests back through cc-connect, and ignore user prompt text parts so replies do not echo the user's own message.

Why

opencode run --attach is short-lived in cc-connect. When the client process exits at the end of a turn, OpenCode server-side background callbacks can be lost. The OpenCode CLI already subscribes to /event SSE internally; this patch mirrors that behavior in cc-connect when connection_url is configured.

Related: #1534, especially #1534 (comment)

Test Plan

  • GOCACHE=/tmp/cc-connect-go-cache go test ./agent/opencode -count=1
  • GOPATH=/tmp/cc-connect-go GOMODCACHE=/tmp/cc-connect-go/pkg/mod GOCACHE=/tmp/cc-connect-go-cache go build ./...
  • Live local validation against opencode serve: OPENCODE_LIVE_URL=... OPENCODE_LIVE_USERNAME=... OPENCODE_LIVE_PASSWORD=... OPENCODE_LIVE_SEND=1 go test ./agent/opencode -run TestOpencodeHTTPModeLiveServer -count=1 -v
  • Manual Feishu validation with the rebuilt local service: streaming works, background callbacks survive, and user prompts are no longer echoed in bot replies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant