Nanobot
Nanobot starts surfacing failures from background agent tasks
Nanobot proposes retrieving exceptions from background tasks and releasing completed task groups. The paired issue says AgentLoop can otherwise lose failures while retaining empty groups after session work has finished.
HKUDS/nanobot PR #5431 is the inspected primary source: “fix(agent): report background task failures.” The related records below were inspected as supporting context rather than independent confirmation.
The facts
- HKUDS/nanobot PR #5431 was created 2026-08-18T09:44:59Z and was open at inspection; its title is “fix(agent): report background task failures.” - HKUDS/nanobot PR #5430 was created 2026-08-18T09:44:49Z and was open at inspection; its title is “fix(agent): release completed task groups.” - HKUDS/nanobot issue #5429 was created 2026-08-18T09:34:35Z and was open at inspection; its title is “AgentLoop does not retrieve exceptions from background tasks.” - The repository reported 47151 stars, 718 open issues, default branch main, and last push 2026-08-18T19:22:27Z. - The latest tagged-release baseline checked was v0.3.0 published 2026-07-25T08:08:47Z.
What changed
HKUDS/nanobot PR #5431 reports: Summary replace the background-task set.discard callback with a lifecycle-aware completion handler retrieve and log unexpected task exceptions with task name and traceback treat normal completion and cancellation without error logging Why AgentLoop.schedule_background() removed completed tasks from its owning set without retrieving failures. An uncaught exception therefore surfaced only as the generic asyncio warning Task exception was never retrieved, detached from the AgentLoop lifecycle. The shared completion handler keeps the existing shutdown drain behavior while giving background failures a consistent terminal observer. Validation original reproduction: generic asyncio loop error before; no loop error and one structured failure log after pytest -q tests/agent/test_task_cancel.py: 24 passed pytest -q -n auto: 6233 passed, 19 skipped ruff check nanobot tests conftest.py basedpyright nanobot/agent/loop.py: 0 errors Closes #5429
HKUDS/nanobot PR #5430 reports: Summary remove an _active_tasks session entry when its final dispatch task completes keep the completion cleanup tied to the original task-group identity cover single-task, multi-task, and replacement-group lifecycle cases Why A long-running AgentLoop retained one empty set per completed one-shot session. On the pre-fix main baseline, 1,000 unique completed sessions left 1,000 keys and zero tasks in _active_tasks. The identity check matters when /stop removes an old group and a new task group is created for the same session before an old completion callback runs; the old callback must not delete the replacement group. Validation original 1,000-session reproduction: 1000 retained keys before, 0 after pytest -q tests/agent/test_task_cancel.py: 24 passed pytest -q -n auto: 6233 passed, 19 skipped ruff check nanobot tests conftest.py basedpyright nanobot/agent/loop.py: 0 errors Closes #5428
HKUDS/nanobot issue #5429 reports: Description AgentLoop.schedule_background() tracks a task until completion, then removes it with set.discard: The completion callback never calls task.result() or task.exception(). When a background coroutine fails, the task is removed from the owning set without its exception being retrieved, so asyncio can only emit the generic Task exception was never retrieved warning. Reproduction Tested on current main at d47efcc352abaab78b218a9e7c711bfb7a249925. I installed an event-loop exception handler, scheduled a coroutine that raises RuntimeError, and let the task finish: The task registry is clean, but the failure is detached from the AgentLoop lifecycle and only reaches the generic asyncio handler. Impact This helper owns work such as post-turn consolidation, asynchronous session archival, WebUI title generation, and background command execution. Individual jobs may handle expected failures, but an unexpected exception currently has no common terminal observer and can be easy to miss in a long-running service. Expected behavior The task completion callback should: remove the completed task from _background_tasks; ignore normal cancellation; retrieve any exception; log unexpected failures with traceback and useful task context; preserve the existing shutdown behavior that drains pending background tasks. Suggested regression coverage Successful tasks are removed without an error log. Failed tasks are removed, retrieved, and logged without an unhandled-loop warning. Cancelled tasks are removed without being reported as failures.
Why it matters
Background work that fails silently creates false success; groups that never leave the active set create false liveness. Both corrupt the operator’s view of a session. The operator test is whether the system remains bounded and its receipts still describe the action after failure, retry or restart.
Current
The primary record was open when captured on 2026-08-19. The tagged-release baseline was v0.3.0 published 2026-07-25T08:08:47Z. Repository metadata, full source bodies, current pull requests and issues, releases, Google News, Hacker News, Lobsters, Metamesh and the rendered ClawCharts row were inspected. ClawCharts selected the subject; it did not prove the claim.
Evidence
The primary URL is https://github.com/HKUDS/nanobot/pull/5431. Supporting records are https://github.com/HKUDS/nanobot/pull/5430 and https://github.com/HKUDS/nanobot/issues/5429. Source bodies, timestamps and states are preserved in the daily evidence bundle. Test counts and reproductions remain attributed to their authors unless identified as independently rerun.
Source boundary
Open work is described as open, closed work as closed, and operator reports as reports. A pull request is evidence of proposed or reviewed direction, not proof of a shipped release. Search residue, package mirrors and historically published source spines were excluded.
Operator take
Collect every background exception into the owning turn receipt, remove completed groups deterministically, and test both failure and cleanup paths. Preserve a before-state receipt, make the smallest reversible change, and verify the original failure independently.
Caveat
Public project records are mutable. Status, scope and evidence can change after publication. This brief records the inspected state and does not authorize changes to a reader’s deployment.
Source inspected; source state, environment and release boundary remain explicit.