From 3780201f3ef94d41ff6d82dafbe3b0fdc411d31c Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 18:48:22 -0700 Subject: [PATCH] refactor(agent/E_session): AST-identical hugging pass 2 --- agent/replay_cleanup.py | 9 ++------- agent/session_persistence.py | 10 ++-------- agent/shell_hooks.py | 4 +--- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/agent/replay_cleanup.py b/agent/replay_cleanup.py index 3c7c408499..b4f17f1a14 100644 --- a/agent/replay_cleanup.py +++ b/agent/replay_cleanup.py @@ -136,16 +136,11 @@ def strip_dangling_tool_call_tail(agent_history: List[Dict[str, Any]]) -> List[D "its effect is UNKNOWN. Inspect current state before retrying.]", "[Orphan recovery: this read-only tool did not complete and had no effect.]", ) - recovered.append(make_tool_result_message( - name, content, _call_id(call), effect_disposition=disposition, - )) + recovered.append(make_tool_result_message(name, content, _call_id(call), effect_disposition=disposition)) logger.warning("Recovered dangling side-effecting tool call(s) as UNKNOWN instead of erasing them") return recovered - logger.debug( - "Stripping dangling unanswered read-only assistant(tool_calls) tail (%d call(s))", - len(tool_calls), - ) + logger.debug("Stripping dangling unanswered read-only assistant(tool_calls) tail (%d call(s))", len(tool_calls)) return agent_history[:-1] diff --git a/agent/session_persistence.py b/agent/session_persistence.py index 414df6eaab..a7252ce5b1 100644 --- a/agent/session_persistence.py +++ b/agent/session_persistence.py @@ -204,11 +204,7 @@ class SessionPersistenceMixin: _repair_message_sequence = _forward("agent.agent_runtime_helpers", "repair_message_sequence") - def _flush_messages_to_session_db( - self, - messages: List[Dict], - conversation_history: Optional[List[Dict]] = None, - ): + def _flush_messages_to_session_db(self, messages: List[Dict], conversation_history: Optional[List[Dict]] = None): """Serialize direct and turn-boundary session flushes per agent.""" with getattr(self, "_session_persist_lock", None) or nullcontext(): return self._flush_messages_to_session_db_unlocked(messages, conversation_history) @@ -437,9 +433,7 @@ class SessionPersistenceMixin: return True except Exception as e: if self._db_flush_failed(e, batch_rows, _adoption_budget): - return self._flush_messages_to_session_db_unlocked( - messages, conversation_history, _adoption_budget=0, - ) + return self._flush_messages_to_session_db_unlocked(messages, conversation_history, _adoption_budget=0) return False def _get_messages_up_to_last_assistant(self, messages: List[Dict]) -> List[Dict]: diff --git a/agent/shell_hooks.py b/agent/shell_hooks.py index f84ff339a1..350a092cb9 100644 --- a/agent/shell_hooks.py +++ b/agent/shell_hooks.py @@ -188,9 +188,7 @@ def register_from_config(cfg: Optional[Dict[str, Any]], *, accept_hooks: bool = continue already_allowlisted = _is_allowlisted(spec.event, spec.command) - if not already_allowlisted and not _prompt_and_record( - spec.event, spec.command, accept_hooks=effective_accept, - ): + if not already_allowlisted and not _prompt_and_record(spec.event, spec.command, accept_hooks=effective_accept): logger.warning( "shell hook for %s (%s) not allowlisted — skipped. " "Use --accept-hooks / HERMES_ACCEPT_HOOKS=1 / "