The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent/E_session): AST-identical line hugging of wrapped signatures/conditions
Teknium55864960bd6e
diff --git a/agent/replay_cleanup.py b/agent/replay_cleanup.pyindex 5423472eac2..f1a18a19c99 100644--- a/agent/replay_cleanup.py+++ b/agent/replay_cleanup.py@@ -51,9 +51,7 @@ def _orphan_recovery(name: str, unknown_text: str, none_text: str) -> tuple:return "none", none_text-def strip_interrupted_tool_tails(- agent_history: List[Dict[str, Any]],-) -> List[Dict[str, Any]]:+def strip_interrupted_tool_tails(agent_history: List[Dict[str, Any]]) -> List[Dict[str, Any]]:"""Strip interrupted assistant→tool sequences from replay history.The interrupted block is not necessarily the final tail (a queued real user@@ -77,10 +75,7 @@ def strip_interrupted_tool_tails(while j < n and agent_history[j].get("role") == "tool":tool_results.append(agent_history[j])j += 1- if tool_results and any(- is_interrupted_tool_result(m.get("content", ""))- for m in tool_results- ):+ if tool_results and any(is_interrupted_tool_result(m.get("content", "")) for m in tool_results):calls = msg.get("tool_calls") or []if _any_side_effecting(calls):call_names = {_call_id(call): _call_name(call) for call in calls}@@ -117,9 +112,7 @@ def strip_interrupted_tool_tails(return cleaned-def strip_dangling_tool_call_tail(- agent_history: List[Dict[str, Any]],-) -> List[Dict[str, Any]]:+def strip_dangling_tool_call_tail(agent_history: List[Dict[str, Any]]) -> List[Dict[str, Any]]:"""Strip a trailing ``assistant(tool_calls)`` block left with NO answers.A tool call that kills the gateway process itself (``docker restart``,@@ -134,11 +127,7 @@ def strip_dangling_tool_call_tail(return agent_historylast = agent_history[-1]- if not (- isinstance(last, dict)- and last.get("role") == "assistant"- and last.get("tool_calls")- ):+ if not (isinstance(last, dict) and last.get("role") == "assistant" and last.get("tool_calls")):return agent_historytool_calls = last.get("tool_calls") or []@@ -155,9 +144,7 @@ def strip_dangling_tool_call_tail(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"- )+ logger.warning("Recovered dangling side-effecting tool call(s) as UNKNOWN instead of erasing them")return recoveredlogger.debug(@@ -167,9 +154,7 @@ def strip_dangling_tool_call_tail(return agent_history[:-1]-def sanitize_replay_history(- agent_history: List[Dict[str, Any]],-) -> List[Dict[str, Any]]:+def sanitize_replay_history(agent_history: List[Dict[str, Any]]) -> List[Dict[str, Any]]:"""Both replay-tail strippers in canonical order (interrupted blocks, thendangling tail). Returns the same list object when nothing is stripped."""if not agent_history:diff --git a/agent/session_activity.py b/agent/session_activity.pyindex ccf9c8b69a2..2a644dd1d53 100644--- a/agent/session_activity.py+++ b/agent/session_activity.py@@ -41,9 +41,7 @@ def bound_activity_description(description: Optional[str]) -> str:return text[: ACTIVITY_DESCRIPTION_MAX - 1] + "…"-def normalize_activity_provenance(- provenance: Optional[ActivityProvenance | str],-) -> ActivityProvenance:+def normalize_activity_provenance(provenance: Optional[ActivityProvenance | str]) -> ActivityProvenance:"""Return a known provenance, or ``UNKNOWN`` when unset/unrecognized."""if isinstance(provenance, ActivityProvenance):return provenancediff --git a/agent/shell_hooks.py b/agent/shell_hooks.pyindex 7d43fa9de9c..ec9c6d935c8 100644--- a/agent/shell_hooks.py+++ b/agent/shell_hooks.py@@ -155,11 +155,7 @@ class ShellHookSpec(_ToolMatcherMixin):# --- Public API ----def register_from_config(- cfg: Optional[Dict[str, Any]],- *,- accept_hooks: bool = False,-) -> List[ShellHookSpec]:+def register_from_config(cfg: Optional[Dict[str, Any]], *, accept_hooks: bool = False) -> List[ShellHookSpec]:"""Register every configured shell hook on the plugin manager; idempotent.Returns the specs that were newly wired up. Skipped entries (unknown events, malformed, not@@ -636,10 +632,7 @@ def _prompt_and_record(event: str, command: str, *, accept_hooks: bool) -> bool:"""Approve an unseen ``(event, command)`` pair; True iff granted and recorded."""if accept_hooks:_record_approval(event, command)- logger.info(- "shell hook auto-approved via --accept-hooks / env / config: "- "%s -> %s", event, command,- )+ logger.info("shell hook auto-approved via --accept-hooks / env / config: " "%s -> %s", event, command)return Trueif not sys.stdin.isatty():diff --git a/agent/trace_upload.py b/agent/trace_upload.pyindex e8ff3aceea0..276e8f6341d 100644--- a/agent/trace_upload.py+++ b/agent/trace_upload.py@@ -250,8 +250,7 @@ def _do_upload(try:from huggingface_hub import HfApiexcept ImportError:- return ("Hugging Face upload needs the `huggingface_hub` package "- "(`pip install huggingface_hub`).")+ return ("Hugging Face upload needs the `huggingface_hub` package " "(`pip install huggingface_hub`).")api = HfApi(token=token)try:diff --git a/agent/transcript_repair.py b/agent/transcript_repair.pyindex 0b790a13764..7da566ead9f 100644--- a/agent/transcript_repair.py+++ b/agent/transcript_repair.py@@ -92,10 +92,7 @@ def resolve_and_repair_transcript_batch(return inserted_rows-def sync_flushed_message_markers(- batch_msgs: List[Dict[str, Any]],- batch_rows: List[Dict[str, Any]],-) -> None:+def sync_flushed_message_markers(batch_msgs: List[Dict[str, Any]], batch_rows: List[Dict[str, Any]]) -> None:"""Stamp _DB_PERSISTED_MARKER and sync canonical row ID / content onto live dicts after commit."""for written, row in zip(batch_msgs, batch_rows):written[_DB_PERSISTED_MARKER] = True