Skip to content

Commit cec4d20

Browse files
Fix step verification bug: use stepName instead of name
- Fixed verification logic in verify.ts to check event.stepName instead of event.name - This resolves the 'Cannot send STEP_FINISHED for step "undefined"' error - Updated test expectations to match the corrected behavior - Bug was causing second requests to LangGraph agents to fail - All integrations correctly use stepName property per official schemas
1 parent 38a2c25 commit cec4d20

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

typescript-sdk/packages/client/src/verify/__tests__/verify.steps.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("verifyEvents steps", () => {
5353
await new Promise((resolve) => setTimeout(resolve, 100));
5454

5555
// Verify only events before the error were processed
56-
expect(events.length).toBe(3);
56+
expect(events.length).toBe(2);
5757
expect(events[1].type).toBe(EventType.STEP_STARTED);
5858
});
5959

@@ -68,7 +68,7 @@ describe("verifyEvents steps", () => {
6868
error: (err) => {
6969
expect(err).toBeInstanceOf(AGUIError);
7070
expect(err.message).toContain(
71-
`Cannot send 'STEP_FINISHED' for step "undefined" that was not started`,
71+
`Cannot send 'STEP_FINISHED' for step "test-step" that was not started`,
7272
);
7373
subscription.unsubscribe();
7474
},
@@ -106,7 +106,7 @@ describe("verifyEvents steps", () => {
106106
next: (event) => events.push(event),
107107
error: (err) => {
108108
expect(err).toBeInstanceOf(AGUIError);
109-
expect(err.message).toContain(`Step "undefined" is already active for 'STEP_STARTED'`);
109+
expect(err.message).toContain(`Step "test-step" is already active for 'STEP_STARTED'`);
110110
subscription.unsubscribe();
111111
},
112112
});

typescript-sdk/packages/client/src/verify/verify.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export const verifyEvents =
1414
let firstEventReceived = false;
1515
// Track active steps
1616
let activeSteps = new Map<string, boolean>(); // Map of step name -> active status
17-
let activeThinkingStep = false
18-
let activeThinkingStepMessage = false
17+
let activeThinkingStep = false;
18+
let activeThinkingStepMessage = false;
1919

2020
return source$.pipe(
2121
// Process each event through our state machine
@@ -244,7 +244,7 @@ export const verifyEvents =
244244

245245
// Step flow
246246
case EventType.STEP_STARTED: {
247-
const stepName = (event as any).name;
247+
const stepName = (event as any).stepName;
248248
if (activeSteps.has(stepName)) {
249249
return throwError(
250250
() => new AGUIError(`Step "${stepName}" is already active for 'STEP_STARTED'`),
@@ -255,7 +255,7 @@ export const verifyEvents =
255255
}
256256

257257
case EventType.STEP_FINISHED: {
258-
const stepName = (event as any).name;
258+
const stepName = (event as any).stepName;
259259
if (!activeSteps.has(stepName)) {
260260
return throwError(
261261
() =>

0 commit comments

Comments
 (0)