Skip to content

Dashboard: session-stream span 404s when the session key contains ':' #5160

Backlog

Description

@Abhijeet-980

Summary

When a chat session's key contains : characters, opening its sessions.pipe() span in the run inspector shows "Error: 404 Could not subscribe to stream", and the panel header shows only the last segment of the key (e.g. Session: v2.out). The stream itself is fine: the SDK reads and writes it, and read_session_channel (MCP) returns its records.

Reproduction

  1. Define a chat.agent with a custom channel whose key contains colons, e.g. key: "clerk:{event.userId}:v2".
  2. Send a message so a turn runs.
  3. Open the run in the dashboard and click the sessions.pipe() span.

Expected: the session's .out stream renders.
Actual: the panel shows Session: v2.out and "404 Could not subscribe to stream". The webapp logs show the request for the truncated id:

GET /resources/orgs/<org>/projects/<project>/env/prod/sessions/v2/realtime/v1/out 404

while the SDK's own requests for the same session succeed:

PUT /realtime/v1/sessions/clerk%3Auser_XXXX%3Av2/out 202
GET /realtime/v1/sessions/clerk%3Auser_XXXX%3Av2/out/records 200

Cause

SpanPresenter.server.ts (case "session-stream") splits the span entity id on : and indexes from the end:

const parts = span.entity.id.split(":");
const io = parts.at(-1);
const channel = parts.at(-2) ?? "";
const sessionId = parts.at(-3);

Because the session id (an external id / channel key) can itself contain :, a key like clerk:user_XXXX:v2 is reduced to sessionId = "v2", and the route then requests /sessions/v2/realtime/v1/out, which 404s. This is present in v4.8.4 and on main.

Suggested fix

Parse io and channel from the end and join the remainder as the session id (parts.slice(0, -2).join(":")), or encode the session id when building the entity id.

Environment

  • Self-hosted webapp ghcr.io/triggerdotdev/trigger.dev:v4.8.4 (Docker / Coolify)
  • @trigger.dev/sdk 4.8.4
  • Session created via chat.channels.custom({ key: "clerk:{event.clerkUserId}:v2", ... })

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