Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe("AbstractAgent.legacy_to_be_removed_runAgentBridged", () => {
const legacyEvents = await lastValueFrom(legacy$.pipe(toArray()));

// Verify events are in correct legacy format
expect(legacyEvents).toHaveLength(4); // Start, Content, End, AgentStateMessage
expect(legacyEvents).toHaveLength(3); // Start, Content, End

// TextMessageStart
expect(legacyEvents[0]).toMatchObject({
Expand All @@ -182,12 +182,12 @@ describe("AbstractAgent.legacy_to_be_removed_runAgentBridged", () => {
});

// Final AgentStateMessage
expect(legacyEvents[3]).toMatchObject({
type: "AgentStateMessage",
threadId: "test-thread-id",
agentName: "test-agent-id",
active: false,
});
// expect(legacyEvents[3]).toMatchObject({
// type: "AgentStateMessage",
// threadId: "test-thread-id",
// agentName: "test-agent-id",
// active: false,
// });
});

it("should pass configuration to the underlying run method", async () => {
Expand Down Expand Up @@ -304,7 +304,7 @@ describe("AbstractAgent.legacy_to_be_removed_runAgentBridged", () => {
const legacyEvents = await lastValueFrom(legacy$.pipe(toArray()));

// Verify events are in correct legacy format
expect(legacyEvents).toHaveLength(4); // Start, Content, End, AgentStateMessage
expect(legacyEvents).toHaveLength(3); // Start, Content, End

// TextMessageStart
expect(legacyEvents[0]).toMatchObject({
Expand All @@ -326,12 +326,12 @@ describe("AbstractAgent.legacy_to_be_removed_runAgentBridged", () => {
});

// Final AgentStateMessage
expect(legacyEvents[3]).toMatchObject({
type: "AgentStateMessage",
threadId: "test-thread-id",
agentName: "test-agent-id",
active: false,
});
// expect(legacyEvents[3]).toMatchObject({
// type: "AgentStateMessage",
// threadId: "test-thread-id",
// agentName: "test-agent-id",
// active: false,
// });
});

it("should transform tool call events with results into legacy events with correct tool name", async () => {
Expand All @@ -348,7 +348,7 @@ describe("AbstractAgent.legacy_to_be_removed_runAgentBridged", () => {
const legacyEvents = await lastValueFrom(legacy$.pipe(toArray()));

// Verify events are in correct legacy format
expect(legacyEvents).toHaveLength(5); // ActionExecutionStart, ActionExecutionArgs, ActionExecutionEnd, ActionExecutionResult, AgentStateMessage
expect(legacyEvents).toHaveLength(4); // ActionExecutionStart, ActionExecutionArgs, ActionExecutionEnd, ActionExecutionResult

// ActionExecutionStart
expect(legacyEvents[0]).toMatchObject({
Expand Down Expand Up @@ -379,11 +379,11 @@ describe("AbstractAgent.legacy_to_be_removed_runAgentBridged", () => {
});

// Final AgentStateMessage
expect(legacyEvents[4]).toMatchObject({
type: "AgentStateMessage",
threadId: "test-thread-id",
agentName: "test-agent-id",
active: false,
});
// expect(legacyEvents[4]).toMatchObject({
// type: "AgentStateMessage",
// threadId: "test-thread-id",
// agentName: "test-agent-id",
// active: false,
// });
});
});
5 changes: 5 additions & 0 deletions typescript-sdk/packages/client/src/legacy/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ export const convertToLegacyEvents =
currentState.messages = syncedMessages;
}

// Only do an update if state is not empty
if (Object.keys(currentState).length === 0) {
return [];
}

return [
{
type: LegacyRuntimeEventTypes.enum.AgentStateMessage,
Expand Down
Loading