Skip to content

The agent that grows with you

refactor(agent/E_session): AST-identical hugging pass 2

Teknium3780201f3ef9
diff --git a/agent/replay_cleanup.py b/agent/replay_cleanup.py
index 3c7c408499b..b4f17f1a140 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 414df6eaab7..a7252ce5b1a 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 f84ff339a1f..350a092cb9f 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 / "