# NousResearch/hermes-agent · Async timeout/event-loop errors in Weixin, Matrix, Mattermost sends

## Open now

- 4 issues, 0 PRs open on GitHub.
- #12154: \[WeChat\] asyncio.timeout bug and session expiration not handled gracefully
- #13365: Weixin: Voice send fails - asyncio Task attached to different loop
- #37005: Mattermost plugin: send_message fails with 'Timeout context manager should be used inside a task' (v0.15.x)
- #39836: \[Bug\] Mattermost cron job delivery fails with "Timeout context manager should be used inside a task"

Most members report or address the error "Timeout context manager should be used inside a task" (and related cross-event-loop errors) when sending messages or running cron deliveries through Weixin, Matrix, and Mattermost. Proposed changes touch aiohttp timeout handling, event-loop routing for manual cron runs, and session handling, plus a few loosely related Weixin items.

## TL;DR

- 35 member(s): 4 open issue(s), 14 closed issue(s), 0 open PR(s), 3 merged PR(s), 14 PR(s) closed without merging.
- A fix was merged to main in PR #80838. Verify it addresses your case.
- **Recommended:** read PR #80838 (and any competing PRs below) before filing. Confirm the merged change covers your symptom.

## Maintainer resolution verdict

- Internal-tracker verdict over this cluster's issue members: `partially_resolved` · deciding PR(s): `pr-80838`. This is distinct from the fix status above. Weigh it yourself.

## How this cluster was grouped

- Link evidence (`STRUCTURAL_PARTIAL`): some members are connected by structural evidence (shared changed files, or a closing/superseded reference); the rest are joined by an automated relevance judgement over their text.
- Members outside that structural core may belong to a different underlying problem.
- Pairwise link density `0.06`: the share of member pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. `1.00` means every pair is linked.

## Open related issues

- #12154: \[WeChat\] asyncio.timeout bug and session expiration not handled gracefully
- #13365: Weixin: Voice send fails - asyncio Task attached to different loop
- #37005: Mattermost plugin: send_message fails with 'Timeout context manager should be used inside a task' (v0.15.x)
- #39836: \[Bug\] Mattermost cron job delivery fails with "Timeout context manager should be used inside a task"

## Closed / duplicate issues

- #13099: \[Bug\]: WeChat send_message causes "Timeout context manager should be used inside a task" error
- #13281: \[Bug\] send_message tool fails with Weixin: Timeout context manager should be used inside a task
- #16293: \[Bug\]: Weixin message error
- #17347: \[Bug\] Weixin send_message fails with "Timeout context manager should be used inside a task"
- #17595: \[Weixin\] File/image sending fails with asyncio timeout error
- #18014: Bug: Cron job delivery to WeChat fails with "Timeout context manager should be used inside a task"
- #18437: \[Bug\] Weixin send_message fails with event-loop errors in non-gateway sessions (v0.11.0)
- #18791: \[Bug\] Weixin send_message fails with 'Timeout context manager should be used inside a task'
- #18836: \[Bug\] Weixin Gateway: Timeout context manager should be used inside a task
- #20229: WeChat adapter: "Timeout context manager should be used inside a task" error when cron job delivers to WeChat
- #23371: send_message weixin: asyncio 'Future attached to a different loop' bug
- #24142: \[Bug\]: Weixin send_message fails: 'Timeout context manager should be used inside a task'
- #29037: fix(weixin): replace aiohttp ClientTimeout with asyncio.wait_for()
- #61495: \[Bug\]: Matrix manual cron delivery fails with "Timeout context manager should be used inside a task"

## Prior & competing PRs

- **#21196: fix(weixin): replace aiohttp ClientTimeout with asyncio.wait_for (salvage #19050)**. merged to main · fix tier `suggested`
  - maintainer direction: category `merged`
  - _suggested-tier fix detail withheld; re-request with `?tier=all` to include it._
- **#80807: fix: dispatch cronjob(action='run') to the background like delegate_task**. merged to main · fix tier `verified`
  - maintainer direction: category `merged`
  - files: `cron/scheduler.py`, `tests/tools/test_cronjob_run_background.py`, `tools/cronjob_tools.py`
- **#80838: fix(cron): gateway-loop delivery, per-run prompt context, Matrix standalone send — run-action sweep salvage**. merged to main · fix tier `verified`
  - maintainer direction: category `merged`
  - files: `cron/scheduler.py`, `plugins/platforms/matrix/adapter.py`, `tests/cron/test_cron_kanban_env_isolation.py`, `tests/cron/test_cron_workdir.py`, `tests/cron/test_execution_ledger.py`, `tests/cron/test_parallel_pool.py`, `tests/cron/test_run_one_job.py`, `tests/cron/test_scheduler.py`, `tests/tools/test_cronjob_run_background.py`, `tests/tools/test_cronjob_run_immediate.py`, `tools/cronjob_tools.py`
- **#12223: fix: report expired Weixin sessions**. closed without merge
  - maintainer direction: category `uncategorized`; implication `needs_llm`
- **#13520: fix(weixin): avoid cross-loop live session reuse**. closed without merge
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`; refs `a22465e07ab4b71019f711e7a6463f6590c50742`, `#13350`, `#12810`
- **#15911: fix(weixin): avoid cross-event-loop ClientSession reuse in send_weixin_direct**. closed without merge
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`; refs `a22465e07ab4b71019f711e7a6463f6590c50742`, `#13520`, `#14481`, `#14873`
- **#17545: fix(weixin): route send_message media uploads through a fresh aiohttp session**. closed without merge
  - maintainer direction: category `superseded_by_pr`; implication `superseded`; refs `a22465e07ab4b71019f711e7a6463f6590c50742`
- **#18040: fix(weixin): guard against event-loop mismatch in send_weixin_direct**. closed without merge
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#12810`
- **#18714: fix: cross-channel send_message failures (WeChat event loop + Telegram proxy)**. closed without merge
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`; refs `#12370`
- **#37599: fix(mattermost): use asyncio.wait_for instead of aiohttp ClientTimeout (#37005)**. closed without merge
  - maintainer direction: category `merged_via`; implication `superseded`
- **#38525: fix(tools): wrap coroutines in create_task() in _run_async() to fix aiohttp timeout error**. closed without merge
  - maintainer direction: category `silent_close`; implication `active`
- **#39877: fix(mattermost): avoid aiohttp timeout context in sends**. closed without merge
  - maintainer direction: category `uncategorized`; implication `needs_llm`
- **#61502: fix(plugins): use asyncio.wait_for instead of ClientTimeout in Matrix standalone send**. closed without merge
  - maintainer direction: category `merged_via`; implication `superseded`; refs `#80838`, `#63586`, `#61495`
- **#61503: fix(cron,desktop): pass gateway loop to run_one_job for Matrix cron delivery; discover UGit git binary (#61495, #61494)**. closed without merge
  - maintainer direction: category `stale_abandoned`; implication `active`
- **#63586: fix(cron): deliver manual runs on gateway loop**. closed without merge
  - maintainer direction: category `merged_via`; implication `superseded`; refs `#80838`, `#80807`, `#61495`
- **#71132: fix(cron): deliver manual runs on profile-owned gateway loop**. closed without merge
  - maintainer direction: category `partial_fix`; implication `needs_llm`; refs `51013268cf9b0ccc1078c8534cafef48eab145e7`, `6777a6bd67ccabd92455845736b17150a96c6a14`, `da8c209e80fa`, `#71132`, `#61503`, `#7696`, `#7958`, `#17516`, `#16612`, `#50025`, `#32448`, `#32804`, `#32427`, `#33980`, `#34173`, `#34255`, `#34483`, `#37431`, `#37859`, `#41130`, `#41037`, `#41167`, `#41363`, `#41269`, `#41307`, `#50062`, `#43864`, `#49792`, `#49695`, `#52720`, `#52705`, `#53246`, `#34120`, `#53395`, `#57342`, `#57331`, `#57360`, `#57689`, `#61502`, `#61495`, `#61494`, `#63586`, `#63774`, `#374151`
- **#77378: fix(gateway): skip cross-loop live adapter in _send_via_adapter**. closed without merge
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`; refs `#62956`

## Fix status

- Merged to main in PR #80838 (cited above). No release data is tracked. Verify downstream.
- Fix last verified (merged) `2026-08-07`.
- Subsystem: `cron`
- Kind: `bug` (from the open issues' GitHub type labels).
