P-043 Phase 1: background_term-Hook fix
- on_post_tool_call dekrementiert NICHT mehr background_term (war im selben Turn) - Neuer Hook on_background_process_stop dekrementiert bei echtem Prozess-Ende - background_term bleibt > 0 solange Hintergrundprozess laeuft - Hook-Registrierung in __init__.py: 10 -> 11 Hooks (background_process_stop) - Alten Test auf P-043-Verhalten aktualisiert (test_post_tool_call_terminal_bg_noop) - Neuer Test test_background_process_stop_decrements
This commit is contained in:
+9
-3
@@ -174,7 +174,8 @@ def register(ctx):
|
||||
# on_session_finalize → chat_profile -= 1 (GELB Ende, echtes Session-Ende)
|
||||
# on_session_reset → alle Counter auf 0 (/reset)
|
||||
# pre_tool_call → background_term += 1 (wenn terminal bg=true)
|
||||
# post_tool_call → background_term -= 1 (wenn terminal bg=true)
|
||||
# post_tool_call → NO-OP (P-043: kein Dekrement im selben Turn)
|
||||
# background_process_stop → background_term -= 1 (P-043: echtes Prozess-Ende)
|
||||
#
|
||||
# Die Callbacks nutzen adapter._active_adapter (Modul-Level-Referenz,
|
||||
# gesetzt in connect()) statt privater ctx-Attribute (F1.1 — offizielle API).
|
||||
@@ -260,6 +261,10 @@ def _register_presence_hooks() -> None:
|
||||
def _on_post_tool_call(**kwargs):
|
||||
_get_engine_and_call("on_post_tool_call", **kwargs)
|
||||
|
||||
# ── P-043: background_process_stop Hook ──────────────────────────
|
||||
def _on_background_process_stop(**kwargs):
|
||||
_get_engine_and_call("on_background_process_stop", **kwargs)
|
||||
|
||||
# ── Registrierung via offizielle API ──────────────────────────────
|
||||
ctx.register_hook("pre_gateway_dispatch", _on_pre_gateway_dispatch)
|
||||
ctx.register_hook("post_llm_call", _on_post_llm_call)
|
||||
@@ -271,13 +276,14 @@ def _register_presence_hooks() -> None:
|
||||
ctx.register_hook("on_session_reset", _on_session_reset)
|
||||
ctx.register_hook("pre_tool_call", _on_pre_tool_call)
|
||||
ctx.register_hook("post_tool_call", _on_post_tool_call)
|
||||
ctx.register_hook("background_process_stop", _on_background_process_stop)
|
||||
|
||||
_hooks_registered = True
|
||||
logger.info(
|
||||
"[presence-v10] 10 Hooks registriert: "
|
||||
"[presence-v10] 11 Hooks registriert: "
|
||||
"pre_gateway_dispatch, post_llm_call, subagent_start, subagent_stop, "
|
||||
"on_session_start, on_session_end, on_session_finalize, on_session_reset, "
|
||||
"pre_tool_call, post_tool_call"
|
||||
"pre_tool_call, post_tool_call, background_process_stop"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
|
||||
Reference in New Issue
Block a user