Skip to content

Commit 96f8b09

Browse files
committed
fix: detect Run instances in Instance reviver instead of fake Run serde key
The Run class goes through the standard Instance serialization pipeline (WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE), not a dedicated 'Run' key. Move the RunRef detection into serializedInstanceToRef() which checks if the className is 'Run' and the data contains a runId string, then returns a RunRef instead of a generic ClassInstanceRef.
1 parent 81958fd commit 96f8b09

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

packages/core/src/serialization-format.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,23 @@ export const extractClassName = (classId: string): string => {
373373
return parts[parts.length - 1] || classId;
374374
};
375375

376-
/** Convert a serialized class instance to a ClassInstanceRef for display */
376+
/** Convert a serialized class instance to a ClassInstanceRef for display.
377+
* Run instances are special-cased to a RunRef for clickable rendering. */
377378
export const serializedInstanceToRef = (value: {
378379
classId: string;
379380
data: unknown;
380-
}): ClassInstanceRef => {
381-
return new ClassInstanceRef(
382-
extractClassName(value.classId),
383-
value.classId,
384-
value.data
385-
);
381+
}): ClassInstanceRef | RunRef => {
382+
const className = extractClassName(value.classId);
383+
if (
384+
className === 'Run' &&
385+
value.data !== null &&
386+
typeof value.data === 'object' &&
387+
'runId' in value.data &&
388+
typeof (value.data as { runId: unknown }).runId === 'string'
389+
) {
390+
return serializedRunToRunRef(value.data as { runId: string });
391+
}
392+
return new ClassInstanceRef(className, value.classId, value.data);
386393
};
387394

388395
/** Convert a serialized class reference to a display string */
@@ -398,7 +405,6 @@ export const observabilityRevivers: Revivers = {
398405
ReadableStream: streamToStreamRef,
399406
WritableStream: streamToStreamRef,
400407
TransformStream: streamToStreamRef,
401-
Run: serializedRunToRunRef,
402408
StepFunction: serializedStepFunctionToString,
403409
WorkflowFunction: (value: { workflowId: string }) =>
404410
`<workflow:${value.workflowId}>`,

0 commit comments

Comments
 (0)