deerflow2/backend/packages/harness/deerflow/tools
InitBoy e19bec1422
fix(task-tool): cancel and schedule deferred cleanup on polling safety timeout (#3097)
When the poll loop's safety-net timeout fires (poll_count > max_poll_count),
the background subagent task was abandoned without cancellation or cleanup,
leaving a stale entry in _background_tasks indefinitely.

The original code had a comment promising "the cleanup will happen when the
executor completes", but run_task() in executor.py never calls
cleanup_background_task after reaching a terminal state -- the promise was
never implemented.

This change mirrors the asyncio.CancelledError path: signal cooperative
cancellation via request_cancel_background_task and schedule
_deferred_cleanup_subagent_task to remove the entry once the background
thread reaches a terminal state.

Direct cleanup at poll-timeout time would introduce a race: run_task() could
remove the entry while the poll loop is still mid-iteration, causing a
spurious "Task disappeared" error. The deferred approach avoids this by
waiting for terminal state before removal.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 07:47:19 +08:00
..
builtins fix(task-tool): cancel and schedule deferred cleanup on polling safety timeout (#3097) 2026-05-21 07:47:19 +08:00
__init__.py Implement skill self-evolution and skill_manage flow (#1874) 2026-04-06 22:07:11 +08:00
skill_manage_tool.py fix(harness): wrap async-only config tools for sync client execution (#2878) 2026-05-11 22:14:13 +08:00
sync.py fix(harness): wrap all async-only tools for sync clients (#2935) 2026-05-19 22:11:46 +08:00
tools.py fix(harness): wrap all async-only tools for sync clients (#2935) 2026-05-19 22:11:46 +08:00
types.py fix(tools): introduce Runtime type alias to eliminate Pydantic serialization warning (#2774) 2026-05-08 14:50:33 +08:00