deerflow2/backend/packages/harness/deerflow/tools/builtins
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
..
__init__.py feat(agent): add custom-agent self-updates with user isolation (#2713) 2026-05-05 23:17:42 +08:00
clarification_tool.py refactor: split backend into harness (deerflow.*) and app (app.*) (#1131) 2026-03-14 22:55:52 +08:00
invoke_acp_agent_tool.py feat(persistence): per-user filesystem isolation, run-scoped APIs, and state/history simplification (#2153) 2026-04-26 11:13:01 +08:00
present_file_tool.py fix(tools): introduce Runtime type alias to eliminate Pydantic serialization warning (#2774) 2026-05-08 14:50:33 +08:00
setup_agent_tool.py fix(agents): make update_agent honor runtime.context user_id like setup_agent (#2867) 2026-05-12 23:18:54 +08:00
task_tool.py fix(task-tool): cancel and schedule deferred cleanup on polling safety timeout (#3097) 2026-05-21 07:47:19 +08:00
tool_search.py fix: gate deferred MCP tool execution (#2513) 2026-04-24 22:45:41 +08:00
update_agent_tool.py fix(agents): make update_agent honor runtime.context user_id like setup_agent (#2867) 2026-05-12 23:18:54 +08:00
view_image_tool.py fix(tools): introduce Runtime type alias to eliminate Pydantic serialization warning (#2774) 2026-05-08 14:50:33 +08:00