[PR #261] [MERGED] Add idle workflow tracking via internal event #269

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

📋 Pull Request Information

Original PR: https://github.com/run-llama/workflows-py/pull/261
Author: @adrianlyjak
Created: 1/6/2026
Status: Merged
Merged: 1/9/2026
Merged by: @adrianlyjak

Base: mainHead: claude/idle-workflow-tracking-AHJQO


📝 Commits (6)

  • 7e11a98 docs: add research for idle workflow tracking
  • e85f04f docs: revise idle tracking to use internal events
  • b1b9bbf docs: simplify idle tracking - single event, computed state
  • 6124fe3 implement tracking
  • 3fd5bae scrap design doc
  • ec6eb10 Update open-boats-kick.md

📊 Changes

7 files changed (+377 additions, -0 deletions)

View changed files

.changeset/open-boats-kick.md (+5 -0)
📝 packages/llama-index-workflows/src/workflows/events.py (+16 -0)
📝 packages/llama-index-workflows/src/workflows/runtime/control_loop.py (+28 -0)
📝 packages/llama-index-workflows/src/workflows/server/abstract_workflow_store.py (+1 -0)
📝 packages/llama-index-workflows/src/workflows/server/server.py (+12 -0)
📝 packages/llama-index-workflows/tests/runtime/test_control_loop.py (+96 -0)
📝 packages/llama-index-workflows/tests/runtime/test_control_loop_transformations.py (+219 -0)

📄 Description

Add idle workflow tracking

Implements tracking for when workflows become idle (waiting on external input via ctx.wait_for_event()).

Changes

  • New WorkflowIdleEvent: Emitted when a workflow transitions to idle state
  • Idle detection: Added _check_idle_state() helper to determine if all steps have no pending work but have active waiters
  • Server tracking: _WorkflowHandler and PersistentHandler now track idle_since timestamp
  • Resumption detection: idle_since is cleared when workflow resumes (receives StepStateChanged(RUNNING))

Definition of "Idle"

A workflow is idle when:

  1. The workflow is running (not completed/failed/cancelled)
  2. All steps have empty queues
  3. All steps have no in-progress workers
  4. At least one step has an active waiter

Future Work

This enables future implementation of:

  • Idle timeout configuration
  • Releasing idle workflows from memory while preserving state
  • Resume-on-event for released workflows

🔄 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/261 **Author:** [@adrianlyjak](https://github.com/adrianlyjak) **Created:** 1/6/2026 **Status:** ✅ Merged **Merged:** 1/9/2026 **Merged by:** [@adrianlyjak](https://github.com/adrianlyjak) **Base:** `main` ← **Head:** `claude/idle-workflow-tracking-AHJQO` --- ### 📝 Commits (6) - [`7e11a98`](https://github.com/run-llama/workflows-py/commit/7e11a983c809d328881c375c715d8abb6d307678) docs: add research for idle workflow tracking - [`e85f04f`](https://github.com/run-llama/workflows-py/commit/e85f04f91110d75e7c28411df0780c8bbf7b2c07) docs: revise idle tracking to use internal events - [`b1b9bbf`](https://github.com/run-llama/workflows-py/commit/b1b9bbf87edc3b857d721f66a7ab8a8df95111b0) docs: simplify idle tracking - single event, computed state - [`6124fe3`](https://github.com/run-llama/workflows-py/commit/6124fe372c5b7641f0e9617e327b11e04a098d1b) implement tracking - [`3fd5bae`](https://github.com/run-llama/workflows-py/commit/3fd5bae8505a7fcca270da31e170b8fa2d3ea10d) scrap design doc - [`ec6eb10`](https://github.com/run-llama/workflows-py/commit/ec6eb109e6a6e0dd8e4ad142fb4723a4f08e25a7) Update open-boats-kick.md ### 📊 Changes **7 files changed** (+377 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/open-boats-kick.md` (+5 -0) 📝 `packages/llama-index-workflows/src/workflows/events.py` (+16 -0) 📝 `packages/llama-index-workflows/src/workflows/runtime/control_loop.py` (+28 -0) 📝 `packages/llama-index-workflows/src/workflows/server/abstract_workflow_store.py` (+1 -0) 📝 `packages/llama-index-workflows/src/workflows/server/server.py` (+12 -0) 📝 `packages/llama-index-workflows/tests/runtime/test_control_loop.py` (+96 -0) 📝 `packages/llama-index-workflows/tests/runtime/test_control_loop_transformations.py` (+219 -0) </details> ### 📄 Description ## Add idle workflow tracking Implements tracking for when workflows become idle (waiting on external input via `ctx.wait_for_event()`). ### Changes - **New `WorkflowIdleEvent`**: Emitted when a workflow transitions to idle state - **Idle detection**: Added `_check_idle_state()` helper to determine if all steps have no pending work but have active waiters - **Server tracking**: `_WorkflowHandler` and `PersistentHandler` now track `idle_since` timestamp - **Resumption detection**: `idle_since` is cleared when workflow resumes (receives `StepStateChanged(RUNNING)`) ### Definition of "Idle" A workflow is idle when: 1. The workflow is running (not completed/failed/cancelled) 2. All steps have empty queues 3. All steps have no in-progress workers 4. At least one step has an active waiter ### Future Work This enables future implementation of: - Idle timeout configuration - Releasing idle workflows from memory while preserving state - Resume-on-event for released workflows --- <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:06 -05:00
yindo closed this issue 2026-02-16 02:17:06 -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#269