[PR #282] [MERGED] fix: rebuild_state_from_ticks clears in_progress before replaying #288

Closed
opened 2026-02-16 02:17:08 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/run-llama/workflows-py/pull/282
Author: @OS-ramamurtisubramanian
Created: 1/15/2026
Status: Merged
Merged: 1/15/2026
Merged by: @adrianlyjak

Base: mainHead: fix/rebuild-state-clears-in-progress


📝 Commits (7)

  • 534d6c8 fix: rebuild_state_from_ticks clears in_progress before replaying
  • bc17299 chore: add changeset for patch release
  • 22ba201 Add failing test and fix formats
  • 78833bf wip
  • 106db84 Update fix-rebuild-state-checkpoint.md
  • 56174d5 workaround tests for py3.9
  • 5bfef95 missed the other | None

📊 Changes

5 files changed (+212 additions, -4 deletions)

View changed files

.changeset/fix-rebuild-state-checkpoint.md (+7 -0)
📝 packages/llama-index-workflows/src/workflows/runtime/control_loop.py (+17 -1)
📝 packages/llama-index-workflows/tests/runtime/test_control_loop_transformations.py (+127 -0)
📝 packages/llama-index-workflows/tests/test_workflow.py (+59 -1)
📝 uv.lock (+2 -2)

📄 Description

Summary

Fixes ctx.to_dict() failing with "Worker X not found in in_progress" when checkpointing resumed workflows.

Problem

When resuming a workflow from checkpoint:

  1. rewind_in_progress() clears in_progress and assigns new worker IDs
  2. New ticks reference these new worker IDs
  3. But rebuild_state_from_ticks() replayed ticks against the original init_state
  4. Worker ID mismatch caused the error

Solution

Modified rebuild_state_from_ticks() to clear in_progress and move events back to the queue before replaying ticks. This mirrors what rewind_in_progress() does at runtime, ensuring the baseline state aligns with what the control loop uses.

Changes

  • control_loop.py: Updated rebuild_state_from_ticks() to clear in_progress before replaying
  • test_control_loop_transformations.py: Added 2 test cases

Test Plan

  • test_rebuild_state_from_ticks_clears_in_progress - verifies the bug fix
  • test_rebuild_state_from_ticks_preserves_queue_order - verifies retry metadata preserved
  • All 39 existing control loop transformation tests pass

Closes #281


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/run-llama/workflows-py/pull/282 **Author:** [@OS-ramamurtisubramanian](https://github.com/OS-ramamurtisubramanian) **Created:** 1/15/2026 **Status:** ✅ Merged **Merged:** 1/15/2026 **Merged by:** [@adrianlyjak](https://github.com/adrianlyjak) **Base:** `main` ← **Head:** `fix/rebuild-state-clears-in-progress` --- ### 📝 Commits (7) - [`534d6c8`](https://github.com/run-llama/workflows-py/commit/534d6c873b1f6c7dac4ec27464d2d39d501be5f3) fix: rebuild_state_from_ticks clears in_progress before replaying - [`bc17299`](https://github.com/run-llama/workflows-py/commit/bc17299517ba24d5b061a9bd0bc1fa4d460931f5) chore: add changeset for patch release - [`22ba201`](https://github.com/run-llama/workflows-py/commit/22ba2017794825384861545ae3427d0ba92639e1) Add failing test and fix formats - [`78833bf`](https://github.com/run-llama/workflows-py/commit/78833bf7205135fb3d9724fb561f423c81f3fc8c) wip - [`106db84`](https://github.com/run-llama/workflows-py/commit/106db84738de6446258309907e85aaed7ae17f97) Update fix-rebuild-state-checkpoint.md - [`56174d5`](https://github.com/run-llama/workflows-py/commit/56174d58a9abf70ce68d417380a79896ca92f1ff) workaround tests for py3.9 - [`5bfef95`](https://github.com/run-llama/workflows-py/commit/5bfef95679dded7f5a27e52861db4fca6e02ae36) missed the other | None ### 📊 Changes **5 files changed** (+212 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/fix-rebuild-state-checkpoint.md` (+7 -0) 📝 `packages/llama-index-workflows/src/workflows/runtime/control_loop.py` (+17 -1) 📝 `packages/llama-index-workflows/tests/runtime/test_control_loop_transformations.py` (+127 -0) 📝 `packages/llama-index-workflows/tests/test_workflow.py` (+59 -1) 📝 `uv.lock` (+2 -2) </details> ### 📄 Description ## Summary Fixes `ctx.to_dict()` failing with "Worker X not found in in_progress" when checkpointing resumed workflows. ## Problem When resuming a workflow from checkpoint: 1. `rewind_in_progress()` clears `in_progress` and assigns **new** worker IDs 2. New ticks reference these new worker IDs 3. But `rebuild_state_from_ticks()` replayed ticks against the **original** `init_state` 4. Worker ID mismatch caused the error ## Solution Modified `rebuild_state_from_ticks()` to clear `in_progress` and move events back to the queue before replaying ticks. This mirrors what `rewind_in_progress()` does at runtime, ensuring the baseline state aligns with what the control loop uses. ## Changes - `control_loop.py`: Updated `rebuild_state_from_ticks()` to clear `in_progress` before replaying - `test_control_loop_transformations.py`: Added 2 test cases ## Test Plan - [x] `test_rebuild_state_from_ticks_clears_in_progress` - verifies the bug fix - [x] `test_rebuild_state_from_ticks_preserves_queue_order` - verifies retry metadata preserved - [x] All 39 existing control loop transformation tests pass Closes #281 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 02:17:08 -05:00
yindo closed this issue 2026-02-16 02:17:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/workflows-py#288