mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
Closes the adapter-side half of the split-brain described in issue #11016 where _active_sessions stays live but nothing is processing, trapping the chat in repeated 'Interrupting current task...' while /stop reports no active task. Changes on BasePlatformAdapter: - Add _session_tasks: Dict[str, asyncio.Task] mapping session -> owner task so session-terminating commands can cancel the right task and old task finally blocks can't clobber a newer task's guard. - Add _release_session_guard(guard=...) that only releases if the guard Event still matches, preventing races where /stop or /new swaps in a temporary guard while the old task unwinds. - Add _session_task_is_stale() and _heal_stale_session_lock() for on-entry self-heal: when handle_message() sees an _active_sessions entry whose RECORDED owner task is done/cancelled, clear it and fall through to normal dispatch. No owner task recorded = not stale (some tests install guards directly and shouldn't be auto-healed). - Add cancel_session_processing() as the explicit adapter-side cancel API so /stop/ /new/ /reset can cleanly tear down in-flight work. - Route /stop, /new, /reset through _dispatch_active_session_command(): 1. install a temporary command guard so follow-ups stay queued 2. let the runner process the command 3. cancel the old adapter task AFTER the runner response is ready 4. release the command guard and drain the latest pending follow-up - _start_session_processing() replaces the inline create_task + guard setup in handle_message() so guard + owner-task entry land atomically. - cancel_background_tasks() also clears _session_tasks. Combined, this means: - /stop / /new / /reset actually cancel stuck work instead of leaving adapter state desynced from runner state. - A dead session lock self-heals on the next inbound message rather than persisting until gateway restart. - Follow-up messages after /new are processed in order, after the reset command's runner response lands. Refs #11016 |
||
|---|---|---|
| .. | ||
| qqbot | ||
| __init__.py | ||
| ADDING_A_PLATFORM.md | ||
| api_server.py | ||
| base.py | ||
| bluebubbles.py | ||
| dingtalk.py | ||
| discord.py | ||
| email.py | ||
| feishu.py | ||
| feishu_comment.py | ||
| feishu_comment_rules.py | ||
| helpers.py | ||
| homeassistant.py | ||
| matrix.py | ||
| mattermost.py | ||
| signal.py | ||
| slack.py | ||
| sms.py | ||
| telegram.py | ||
| telegram_network.py | ||
| webhook.py | ||
| wecom.py | ||
| wecom_callback.py | ||
| wecom_crypto.py | ||
| weixin.py | ||
| whatsapp.py | ||