fix(presence): Busy-Done-Debounce verhindert vorzeitiges mark_busy_done (V8.9 P1)
PROBLEM: mark_busy_done im finally-Block von _process_incoming feuert 25ms nach mark_busy_started — der Status geht auf Grün, während der Agent noch 30-90s arbeitet. Ursache: handle_message() dispatched den Agent asynchron und kehrt sofort zurück, aber der finally-Block wartet nicht auf die tatsächliche Agent-Fertigstellung. LÖSUNG: Busy-Done-Debounce: Statt sofort mark_busy_done zu rufen, startet der finally-Block einen 3s-Timer. Jeder send()-Call resettet den Timer. Erst wenn 3s lang keine Nachricht mehr gesendet wurde, ist der Agent wirklich fertig und mark_busy_done wird aufgerufen. ÄNDERUNGEN (adapter.py): - __init__: _agent_dispatched_this_turn, _busy_done_debounce_task, _busy_done_debounce_lock - _process_incoming: Flag-Reset vor mark_busy_started; finally-Block startet _start_busy_done_debounce() statt sofort mark_busy_done - _dispatch_agent + main dispatch path: Flag auf True setzen - send(): _reset_busy_done_debounce() nach erfolgreichem Post - _send_split(): _reset_busy_done_debounce() pro Chunk - disconnect(): _cancel_busy_done_debounce() - Neue Methoden: _start_busy_done_debounce, _busy_done_debounce_timer, _reset_busy_done_debounce, _cancel_busy_done_debounce EDGE CASES: - Kein Agent dispatched (Inline-Command, Onboarding-Guard): mark_busy_done sofort - Agent sendet mehrere Nachrichten: Timer wird jedes Mal reset - Agent sendet Split-Nachrichten: Timer wird pro Chunk reset - disconnect(): Timer wird gecancelled ZUSÄTZLICH (presence_engine.py): pgrep-Block von pid_used/gateway_used/plugin_used entkoppelt — pgrep läuft jetzt immer (bereits deployed von Bernd).
This commit is contained in:
@@ -1542,12 +1542,13 @@ class DetectionTimer:
|
||||
# ── V8.7: pgrep /proc scan — hermes chat --profile Prozesse ──
|
||||
# Ersetzt subagent_status.json als vierte Quelle.
|
||||
# Direkt /proc lesen, kein subprocess.
|
||||
pgrep_count = 0
|
||||
if not pid_used and not gateway_used and not plugin_used:
|
||||
pgrep_count = self._pgrep_hermes_subagents()
|
||||
if pgrep_count > 0:
|
||||
result = True
|
||||
detection_source = "pgrep"
|
||||
# V8.9: pgrep ALWAYS runs — not gated behind pid_sentinel/gateway_state.
|
||||
# PID-Sentinel says "Gateway alive" (always true), pgrep says "Subagent active".
|
||||
# Different semantics — pgrep must run independently.
|
||||
pgrep_count = self._pgrep_hermes_subagents()
|
||||
if pgrep_count > 0:
|
||||
result = True
|
||||
detection_source = "pgrep"
|
||||
|
||||
# ── Log: all signals, result, source ───────────────────────────────
|
||||
plugin_str = str(plugin_bg_tasks) if plugin_bg_tasks >= 0 else "n/a"
|
||||
|
||||
Reference in New Issue
Block a user