Skip to content

provider-tangle: a session-bound environment.stream() refuses OpenCode's live raw frames, whose sessionID is the harness-native session #328

Description

@drewstone

Observation

environment.stream({ prompt, sessionId }) fails on the first OpenCode raw frame of a live run stream with Tangle exact session event identified a different sessionId.

The sidecar writes a live raw frame's data as the harness event itself (agent-dev-container apps/sidecar/src/routes/agents-stream.ts:1103-1113 on 9bb408e9f7).
OpenCode's events carry their own session id at the top level, for example { type: "step_start", timestamp, sessionID: "ses_f67f4b273ffeq38073UGm8RzAK", part }.
sandboxEventIdentity reads data.sessionID as the run-frame session position (packages/agent-provider-tangle/src/tangle-events.ts), and environmentEventFromSandboxEvent exempts that position only for session.updated.
The replay lane is unaffected: it sends the buffered { type: "raw", backend: "opencode", event } envelope, where the native id sits under event.

Reproduction

Frames recorded from production execution s19 of run mech-interp-foundations-astra-b-20260912a (the fixture added in #327), streamed through environment.stream({ prompt, sessionId: <runtime session id> }) on the #327 branch:

frame shape result
replay envelope, as recorded 63 events delivered
live shape (data = the inner OpenCode event plus sandboxId) throws after 8 events, on the first step_start

The live shape is reconstructed from the sidecar and SDK source; no live session-bound OpenCode stream was captured.

Ask

Treat the run-frame session position of a raw frame as backend content, as the adapter already does for session.updated on a stream-bound iterator and for properties.part on unshaped frames.
Keep comparing the envelope positions the sidecar rewrites.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions