fix: OpenCode event streaming + bypass permission mode#48
Closed
WellDunDun wants to merge 1 commit intorivet-dev:mainfrom
Closed
fix: OpenCode event streaming + bypass permission mode#48WellDunDun wants to merge 1 commit intorivet-dev:mainfrom
WellDunDun wants to merge 1 commit intorivet-dev:mainfrom
Conversation
Three independent fixes for the OpenCode agent adapter:
1. Wrong API endpoints: /event/subscribe → /event, /session/{id}/prompt → /session/{id}/message
2. Untagged enum mis-dispatch: replace serde_json::from_value with manual type-field dispatch
3. Wire permissionMode "bypass" for OpenCode: allow in normalize_permission_mode() and pass
--dangerously-skip-permissions to CLI (both spawn and spawn_streaming)
Tested with OpenCode 1.1.48 + Kimi K2.5.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c5893f2 to
ecb8fcd
Compare
Member
|
thank you! i'm going to take a pass on our test suite to make sure we're covering this edge case for all agents correctly before merging. |
Contributor
Author
|
@NathanFlurry My absolute pleasure! Hope this helps. |
NathanFlurry
added a commit
that referenced
this pull request
Feb 11, 2026
Member
|
Merged manually after resolving conflicts with main. |
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
The daemon cannot stream events from OpenCode >= 1.1.x, and
permissionMode: "bypass"is rejected for OpenCode despite being documented. Three independent bugs:Wrong API endpoints: Daemon calls
GET /event/subscribeandPOST /session/{id}/prompt, but OpenCode servesGET /eventandPOST /session/{id}/message. Unrecognized routes return the SPA HTML catch-all, silently failing.Untagged enum mis-dispatch: The generated
Eventenum uses#[serde(untagged)].EventServerConnected(variant bug(opencode): server spawns without being prompted #5) has empty properties, matching ANY event JSON beforeEventMessageUpdated(docs: documentation overhaul and universal schema reference #10) is tried. All events deserialize asServerConnected→event_to_universal()returns "unsupported opencode event".Bypass mode not wired for OpenCode:
normalize_permission_mode()only allows"default"for OpenCode, and the spawn blocks don't pass--dangerously-skip-permissions. OpenCode has supported this flag since 1.1.x (see [FEATURE]: Add--dangerously-skip-permissions(aka YOLO mode) anomalyco/opencode#8463).Fix
/event/subscribe→/event,/session/{id}/prompt→/session/{id}/message)serde_json::from_value::<Event>()with manual type-field dispatch that deserializes directly into the correct variant struct"bypass"innormalize_permission_mode()for OpenCode--dangerously-skip-permissionsto OpenCode CLI when bypass mode is set (bothspawnandspawn_streaming)Testing
Tested with OpenCode 1.1.48 + Kimi K2.5:
agent.unparsedsession.started,item.deltastreaming,session.idle)permissionMode: "bypass"now accepted —session.startedmetadata confirms"permissionMode":"bypass"Files Changed
server/packages/sandbox-agent/src/router.rsserver/packages/agent-management/src/agents.rs--dangerously-skip-permissionsto OpenCode CLINotes
Eventenum has a variant with empty/loose properties will have the same problem