Skip to content

fix(flows/actions): set _ongoing_actions_finished_event at ActionManager init - #4959

Open
Maurotb wants to merge 1 commit into
pipecat-ai:mainfrom
Maurotb:fix/flows-action-manager-finished-event-init
Open

fix(flows/actions): set _ongoing_actions_finished_event at ActionManager init#4959
Maurotb wants to merge 1 commit into
pipecat-ai:mainfrom
Maurotb:fix/flows-action-manager-finished-event-init

Conversation

@Maurotb

@Maurotb Maurotb commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Problem

ActionManager._ongoing_actions_finished_event is created as an asyncio.Event() at __init__ and left unset, but the accompanying _ongoing_actions_count starts at 0. The event is guarded by the invariant "no ongoing actions are still running", i.e. count == 0 ↔ event set. At construction the count-side of the invariant is already satisfied, so the event should be set too.

Without the initial .set(), an await self._ongoing_actions_finished_event.wait() invoked BEFORE the first _enqueue_action call blocks indefinitely, breaking the invariant and any caller (e.g. teardown, or a FlowManager that awaits the event during _set_node) that relies on it at startup.

Fix

Call .set() immediately after creating the event in ActionManager.__init__.

Test

Adds test_ongoing_actions_finished_event_set_at_init in tests/test_flows_actions.py that asserts both _ongoing_actions_count == 0 and _ongoing_actions_finished_event.is_set() right after construction.

Compatibility

Purely additive — one method call in __init__, no public API change, no behavior change for callers that already interact with the event AFTER at least one action has been enqueued (which is the common path).

History

Re-files pipecat-ai/pipecat-flows#287 against the new pipecat.flows submodule location. The standalone pipecat-ai-flows package was deprecated / frozen in 1.4.0 in favor of the first-party pipecat.flows module inside pipecat-ai, so the original PR no longer targets a live branch.

…ger init

The event indicates "no ongoing actions still running" and is guarded
by the invariant `_ongoing_actions_count == 0 ↔ event set`. At
construction `_ongoing_actions_count = 0` — so the event should
already be set. Without an explicit `.set()` in `__init__`, an
`await event.wait()` invoked before the first `_enqueue_action`
call blocks indefinitely.

Re-files pipecat-ai/pipecat-flows#287 against
the new `pipecat.flows` submodule location (the standalone
`pipecat-ai-flows` package was frozen in 1.4.0).
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/pipecat/flows/actions.py 87.59% <100.00%> (+0.09%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant