Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .server-changes/session-run-streams-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
area: webapp
type: fix
---

Run-scoped realtime streams written inside a chat session run now use the same streams backend as the session itself, instead of falling back to the older one.
8 changes: 8 additions & 0 deletions apps/webapp/app/services/realtime/sessionRunManager.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { logger } from "~/services/logger.server";
import { CancelTaskRunService } from "~/v3/services/cancelTaskRun.server";
import { TriggerTaskService } from "~/v3/services/triggerTask.server";
import { isFinalRunStatus } from "~/v3/taskStatus";
import { determineRealtimeStreamsVersion } from "./v1StreamsGlobal.server";

/**
* Schema for `Session.triggerConfig` (stored as JSONB). The wire-format
Expand Down Expand Up @@ -275,6 +276,12 @@ export async function ensureRunForSession(
* Trigger a single run for a session. Builds `TriggerTaskRequestBody`
* by shallow-merging `payloadOverrides` over `config.basePayload` and
* threading `config`'s machine/queue/tags through the trigger options.
*
* A session's own channels are always v2, so the run is stamped to match
* rather than inheriting the `realtimeStreamsVersion` column default. Without
* this, run-scoped `streams.*` calls inside a session run resolve to v1 while
* the session it belongs to is on v2. `determineRealtimeStreamsVersion`
* degrades to v1 where v2 streams are not configured.
*/
async function triggerSessionRun(params: {
session: Pick<Session, "id" | "taskIdentifier">;
Expand Down Expand Up @@ -310,6 +317,7 @@ async function triggerSessionRun(params: {
const result = await service.call(session.taskIdentifier, environment, body, {
triggerSource: "session",
triggerAction: "trigger",
realtimeStreamsVersion: determineRealtimeStreamsVersion("v2"),
Comment thread
matt-aitken marked this conversation as resolved.
Comment thread
matt-aitken marked this conversation as resolved.
Comment thread
matt-aitken marked this conversation as resolved.
});

if (!result) {
Expand Down
1 change: 1 addition & 0 deletions apps/webapp/test/realtimeServices.replicaLag.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ describe("realtime-svc — replica-lag guards", () => {
// previousRunId forwarded to the triggered run is the calling run's cuid (documented fallback).
expect(triggerState.calls).toHaveLength(1);
expect(triggerState.calls[0]!.body.payload.previousRunId).toBe(callingRunId);
expect(triggerState.calls[0]!.options.realtimeStreamsVersion).toBeDefined();
expect(replica.wasHit("taskRun")).toBe(true);

// Proof the null was lag-induced: the primary holds the resolvable friendlyId (≠ the cuid).
Expand Down
Loading