[PR #6729] feat(server): add session parameter to /event endpoint #12065

Open
opened 2026-02-16 18:17:00 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6729

State: open
Merged: No


Summary

  • Add optional session query parameter to the /event SSE endpoint
  • Implement server-side filtering to only send events for the specified session
  • Update OpenAPI spec and regenerate SDK (v2)

Details

The /event endpoint now accepts an optional session query parameter. When provided, only events related to that session are streamed to the client.

Filtering Logic

When session parameter is specified:

Event Type Has sessionID? Behavior
session.*, message.*, etc. matching Pass through
session.*, message.*, etc. non-matching Filtered out
server.connected, server.heartbeat Pass through (connection-level)
ide.*, file.*, lsp.*, mcp.*, etc. Filtered out

This prevents cross-session event leakage. Events without sessionID (except server.*) are filtered out to maintain strict session isolation.

Backward Compatibility

This change is fully backward compatible:

  • Without session parameter: Behavior is unchanged - all events are streamed
  • With session parameter: Only session-specific events + server.* events are streamed

SDK Support

  • @opencode-ai/sdk/v2 - Fully supported
  • ⚠️ @opencode-ai/sdk (v1) - Types not yet updated, will follow up separately

Fixes #6686

AI Assistance Disclosure

I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6729 **State:** open **Merged:** No --- ## Summary - Add optional `session` query parameter to the `/event` SSE endpoint - Implement server-side filtering to only send events for the specified session - Update OpenAPI spec and regenerate SDK (v2) ## Details The `/event` endpoint now accepts an optional `session` query parameter. When provided, only events related to that session are streamed to the client. ### Filtering Logic When `session` parameter is specified: | Event Type | Has sessionID? | Behavior | |------------|----------------|----------| | `session.*`, `message.*`, etc. | ✅ matching | ✅ Pass through | | `session.*`, `message.*`, etc. | ✅ non-matching | ❌ Filtered out | | `server.connected`, `server.heartbeat` | ❌ | ✅ Pass through (connection-level) | | `ide.*`, `file.*`, `lsp.*`, `mcp.*`, etc. | ❌ | ❌ Filtered out | This prevents cross-session event leakage. Events without sessionID (except `server.*`) are filtered out to maintain strict session isolation. ### Backward Compatibility This change is fully backward compatible: - **Without `session` parameter**: Behavior is unchanged - all events are streamed - **With `session` parameter**: Only session-specific events + server.* events are streamed ### SDK Support - ✅ `@opencode-ai/sdk/v2` - Fully supported - ⚠️ `@opencode-ai/sdk` (v1) - Types not yet updated, will follow up separately Fixes #6686 ## AI Assistance Disclosure I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.
yindo added the pull-request label 2026-02-16 18:17:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12065