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

This commit is contained in:
Teknium
2026-09-02 18:48:22 -07:00
parent 1c55eefec1
commit 3780201f3e
3 changed files with 5 additions and 18 deletions
+2 -7
View File
@@ -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]
+2 -8
View File
@@ -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]:
+1 -3
View File
@@ -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 / "