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
5 changes: 5 additions & 0 deletions .changeset/fix-checkpoint-runid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@perstack/runtime": patch
---

Fix: Use setting.runId for continued checkpoints instead of inheriting from previous checkpoint
8 changes: 4 additions & 4 deletions apps/runtime/src/helpers/checkpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ describe("@perstack/runtime: createNextStepCheckpoint", () => {
contextWindowUsage: 0.5,
}

it("increments stepNumber and updates id", () => {
const result = createNextStepCheckpoint("new-checkpoint-id", baseCheckpoint)
it("increments stepNumber and updates id and runId", () => {
const result = createNextStepCheckpoint("new-checkpoint-id", baseCheckpoint, "new-run-id")
expect(result.id).toBe("new-checkpoint-id")
expect(result.runId).toBe("new-run-id")
expect(result.stepNumber).toBe(6)
})

it("preserves other checkpoint properties", () => {
const result = createNextStepCheckpoint("new-checkpoint-id", baseCheckpoint)
expect(result.runId).toBe(baseCheckpoint.runId)
const result = createNextStepCheckpoint("new-checkpoint-id", baseCheckpoint, "new-run-id")
expect(result.expert).toEqual(baseCheckpoint.expert)
expect(result.status).toBe(baseCheckpoint.status)
expect(result.messages).toEqual(baseCheckpoint.messages)
Expand Down
7 changes: 6 additions & 1 deletion apps/runtime/src/helpers/checkpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ export function createInitialCheckpoint(
}
}

export function createNextStepCheckpoint(checkpointId: string, checkpoint: Checkpoint): Checkpoint {
export function createNextStepCheckpoint(
checkpointId: string,
checkpoint: Checkpoint,
runId: string,
): Checkpoint {
return {
...checkpoint,
id: checkpointId,
runId,
stepNumber: checkpoint.stepNumber + 1,
}
}
Expand Down
3 changes: 2 additions & 1 deletion apps/runtime/src/orchestration/single-run-executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ vi.mock("../helpers/index.js", () => ({
},
contextWindow: params.contextWindow,
})),
createNextStepCheckpoint: vi.fn().mockImplementation((id, checkpoint) => ({
createNextStepCheckpoint: vi.fn().mockImplementation((id, checkpoint, runId) => ({
...checkpoint,
id,
runId,
stepNumber: checkpoint.stepNumber + 1,
})),
}))
Expand Down
2 changes: 1 addition & 1 deletion apps/runtime/src/orchestration/single-run-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class SingleRunExecutor {
})

const initialCheckpoint = checkpoint
? createNextStepCheckpoint(createId(), checkpoint)
? createNextStepCheckpoint(createId(), checkpoint, setting.runId)
: createInitialCheckpoint(createId(), {
jobId: setting.jobId,
runId: setting.runId,
Expand Down