fix(delegation): harden durable completion delivery

This commit is contained in:
teknium1 2026-07-12 17:53:10 -07:00 committed by Teknium
parent 67f4e1b4a9
commit d0e9a42cec
9 changed files with 696 additions and 153 deletions

20
cli.py
View file

@ -15189,10 +15189,14 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin):
from tools.approval import get_current_session_key
_drain_sk = get_current_session_key(default="")
for _evt, _synth in process_registry.drain_notifications(session_key=_drain_sk):
from tools.async_delegation import (
claim_event_delivery, complete_event_delivery,
)
_claim = claim_event_delivery(_evt, "cli-idle")
if _claim is None:
continue
self._pending_input.put(_synth)
if _evt.get("type") == "async_delegation":
from tools.async_delegation import mark_completion_delivered
mark_completion_delivered(str(_evt.get("delegation_id") or ""))
complete_event_delivery(_evt, _claim)
except Exception:
pass
continue
@ -15354,10 +15358,14 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin):
try:
from tools.process_registry import process_registry
for _evt, _synth in process_registry.drain_notifications():
from tools.async_delegation import (
claim_event_delivery, complete_event_delivery,
)
_claim = claim_event_delivery(_evt, "cli-post-turn")
if _claim is None:
continue
self._pending_input.put(_synth)
if _evt.get("type") == "async_delegation":
from tools.async_delegation import mark_completion_delivered
mark_completion_delivered(str(_evt.get("delegation_id") or ""))
complete_event_delivery(_evt, _claim)
except Exception:
pass # Non-fatal — don't break the main loop