deerflow2/backend/packages/harness/deerflow
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
..
agents fix(trace):memory 中文 in trace info is unicode escape sequence. (#3104) 2026-05-20 22:34:10 +08:00
community feat(sandbox) Adds download file interface in Sandbox (#3038) 2026-05-20 10:16:31 +08:00
config Fix env resolution in MCP config lists (#2556) 2026-05-21 07:27:00 +08:00
guardrails feat(guardrails): add pre-tool-call authorization middleware with pluggable providers (#1240) 2026-03-23 18:07:33 +08:00
mcp fix(harness): wrap async-only config tools for sync client execution (#2878) 2026-05-11 22:14:13 +08:00
models feat: static system prompt with DynamicContextMiddleware for prefix-cache optimization (#2801) 2026-05-09 09:27:02 +08:00
persistence fix(harness)!: hydrate runs from RunStore and persist interrupted status (#2932) 2026-05-18 22:25:02 +08:00
reflection refactor: split backend into harness (deerflow.*) and app (app.*) (#1131) 2026-03-14 22:55:52 +08:00
runtime fix(runtime): make RunManager.cancel() idempotent for already-interrupted runs (#3055) (#3058) 2026-05-20 16:37:36 +08:00
sandbox feat(sandbox) Adds download file interface in Sandbox (#3038) 2026-05-20 10:16:31 +08:00
skills fix(skills): make security scanner JSON parsing robust for LLM output variations (#2987) 2026-05-17 08:59:42 +08:00
subagents fix(subagents): make subagent timeout terminal state atomic (#2583) 2026-05-18 22:19:32 +08:00
tools fix(task-tool): cancel and schedule deferred cleanup on polling safety timeout (#3097) 2026-05-21 07:47:19 +08:00
tracing feat(tracing): add optional Langfuse support (#1717) 2026-04-02 13:06:10 +08:00
uploads fix(uploads): add Windows support for safe symlink-protected uploads (#2794) 2026-05-09 18:21:54 +08:00
utils fix(gateway): return ISO 8601 timestamps from threads endpoints (#2599) 2026-05-02 15:16:16 +08:00
__init__.py refactor: split backend into harness (deerflow.*) and app (app.*) (#1131) 2026-03-14 22:55:52 +08:00
client.py feat: refine token usage display modes (#2329) 2026-05-04 09:56:16 +08:00