The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent/turn_usage,turn_explainers): suppress() for best-effort blocks
Tekniumf41dd887b087
diff --git a/agent/turn_explainers.py b/agent/turn_explainers.pyindex 9551792ead3..dae098d0d97 100644--- a/agent/turn_explainers.py+++ b/agent/turn_explainers.py@@ -5,6 +5,7 @@ summarises why a turn ended without a final answer. Every method resolves throug"""import osimport re+from contextlib import suppressfrom typing import Any, Dict, Optionalfrom agent.tool_dispatch_helpers import (@@ -189,19 +190,17 @@ class TurnExplainersMixin:changed = getattr(self, "_turn_file_mutation_paths", None)if changed is not None:changed.update(landed_paths)- # Feed the checkpoint agent-write ledger so /rollback's safe mode- # can tell Hermes-authored content from later user hand-edits.+ # Feed the checkpoint agent-write ledger so /rollback's safe mode can tell+ # Hermes-authored content from later user hand-edits.mgr = getattr(self, "_checkpoint_mgr", None)if mgr is not None and getattr(mgr, "enabled", False):for _p in landed_paths:- try:+ with suppress(Exception):mgr.record_agent_write(_p)- except Exception:- passif is_error and not landed:+ # Keep the FIRST error per path unless a later success replaces it.preview = _extract_error_preview(result)for path in targets:- # Keep the FIRST error per path unless a later success replaces it.state.setdefault(path, {"tool": tool_name, "error_preview": preview})else:for path in targets:diff --git a/agent/turn_usage.py b/agent/turn_usage.pyindex 425c9e10767..87343441d1b 100644--- a/agent/turn_usage.py+++ b/agent/turn_usage.py@@ -11,6 +11,7 @@ model/provider. Logger name stays ``agent.conversation_loop`` for caplog parity.from __future__ import annotationsimport logging+from contextlib import suppressfrom dataclasses import dataclassfrom typing import Any, Dict, List@@ -155,15 +156,13 @@ def record_response_usage(agent.session_cache_write_tokens += canonical_usage.cache_write_tokensagent.session_reasoning_tokens += canonical_usage.reasoning_tokens# Rolling history for status-bar averages (last 10).- try:+ with suppress(Exception):hist = getattr(agent, "_api_latency_history", None)if hist is not None:hist.append(float(api_duration))ohist = getattr(agent, "_api_output_history", None)if ohist is not None:ohist.append(int(canonical_usage.output_tokens or 0))- except Exception:- pass_cache_pct = ""if canonical_usage.cache_read_tokens and prompt_tokens: