Commits
Click on a commit to change the comparison rangefix: allow pause_flow_run() to pause parent flow when called from task
closes #19435
this pr changes pause_flow_run() to pause the parent flow when called
from within a task, instead of raising "cannot pause task runs" error.
<details>
<summary>context</summary>
previously, calling pause_flow_run() from within a task would raise:
```
RuntimeError: Cannot pause task runs.
```
this was overly restrictive since:
1. the function is named pause_flow_run(), not pause_task_run()
2. both FlowRunContext and TaskRunContext are independently active when
a task runs inside a flow
3. users reasonably expect to encapsulate approval/pause logic in
reusable tasks
</details>
<details>
<summary>changes</summary>
**src/prefect/flow_runs.py**
- removed the guard that raised RuntimeError when TaskRunContext.get()
was truthy
- now directly accesses FlowRunContext.get() (which works even inside
tasks) to pause the parent flow
**tests/test_flow_engine.py**
- renamed test_tasks_cannot_be_paused to
test_pause_flow_run_from_task_pauses_parent_flow
- updated to verify pause works correctly instead of expecting error
- added test_pause_flow_run_from_task_with_input to verify pause with
wait_for_input works from tasks
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>