Skip to content
Merged
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
4 changes: 1 addition & 3 deletions langgraph/src/channels/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export async function createCheckpoint<Value>(
channelVersions: { ...checkpoint.channelVersions },
versionsSeen: { ...checkpoint.versionsSeen },
};
for (const k in channels) {
if (newCheckpoint.channelValues[k] === undefined) {
for (const k of Object.keys(channels)) {
try {
newCheckpoint.channelValues[k] = await channels[k].checkpoint();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -100,7 +99,6 @@ export async function createCheckpoint<Value>(
throw error; // Rethrow unexpected errors
}
}
}
}
return newCheckpoint;
}
7 changes: 5 additions & 2 deletions langgraph/src/channels/binop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ export class BinaryOperatorAggregate<Value> extends BaseChannel<
this.value = initialValueFactory?.();
}

public empty(_?: Value): BinaryOperatorAggregate<Value> {
public empty(checkpoint?: Value): BinaryOperatorAggregate<Value> {
const empty = new BinaryOperatorAggregate(
this.operator,
this.initialValueFactory
);
if (checkpoint) {
empty.value = checkpoint;
}
return empty;
}

Expand Down Expand Up @@ -61,7 +64,7 @@ export class BinaryOperatorAggregate<Value> extends BaseChannel<
}

public checkpoint(): Value {
if (!this.value) {
if (this.value === undefined) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit for consistency with the rest of the file

throw new EmptyChannelError();
}
return this.value;
Expand Down
2 changes: 1 addition & 1 deletion langgraph/src/tests/pregel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ it("should process two inputs to two outputs validly", async () => {
expect(await app.invoke(2)).toEqual([3, 3]);
});

it.skip("should handle checkpoints correctly", async () => {
it("should handle checkpoints correctly", async () => {
const addOne = jest.fn(
(x: { total: number; input: number }): number => x.total + x.input
);
Expand Down