fix(logging): replace stdlib-style exc_info kwargs with loguru opt(exception=)
Loguru has no exc_info kwarg: extra kwargs are str.format() arguments, so
logger.error(f"...{e}", exc_info=True) forces .format() on the rendered
message — any error text containing braces (e.g. a JSON error body) raises
KeyError FROM the log call itself, escaping the surrounding except block and
killing the caller (observed: whole agent turns dying in benchmark runs).
The intended traceback was also never logged, since exc_info is not a loguru
feature.
Batch fix of all 143 sites across 11 files:
logger.X(msg, exc_info=True) -> logger.opt(exception=True).X(msg)
(one exc_info=exc site -> opt(exception=exc))
Messages are byte-identical; with the kwarg gone loguru never calls
.format(), so brace-containing f-string messages are inert.
Verified: AST post-conditions per file, py_compile, import smoke of all
modules, behavioral equivalence of the 3 patterns, full unit suite (1549
passed) with a failure set identical to the pristine tree (22 pre-existing,
zero regressions).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Also add pixel-agents to the README acknowledgements.
This commit is contained in:
@@ -429,10 +429,9 @@ class ExternalAgentBroker:
|
||||
role_session_id, adapter.agent_type
|
||||
)
|
||||
except Exception:
|
||||
logger.debug(
|
||||
logger.opt(exception=True).debug(
|
||||
f"PR6 role adapter-state read failed "
|
||||
f"sid={role_session_id} agent={adapter.agent_type}",
|
||||
exc_info=True,
|
||||
)
|
||||
entry = None
|
||||
if isinstance(entry, dict):
|
||||
@@ -452,9 +451,8 @@ class ExternalAgentBroker:
|
||||
opc_session_id=role_session_id,
|
||||
)
|
||||
except Exception:
|
||||
logger.debug(
|
||||
logger.opt(exception=True).debug(
|
||||
f"External resume restore: get_external_session by role failed for {adapter.agent_type}/{role_session_id}",
|
||||
exc_info=True,
|
||||
)
|
||||
prior = None
|
||||
if prior is None:
|
||||
@@ -465,9 +463,8 @@ class ExternalAgentBroker:
|
||||
task_id=task.id,
|
||||
)
|
||||
except Exception:
|
||||
logger.debug(
|
||||
logger.opt(exception=True).debug(
|
||||
f"External resume restore: get_external_session failed for {adapter.agent_type}/{task.id}",
|
||||
exc_info=True,
|
||||
)
|
||||
return
|
||||
if prior is None:
|
||||
@@ -1387,7 +1384,7 @@ class ExternalAgentBroker:
|
||||
)
|
||||
return str(path)
|
||||
except Exception:
|
||||
logger.debug("ExternalAgentBroker: failed to write raw external log", exc_info=True)
|
||||
logger.opt(exception=True).debug("ExternalAgentBroker: failed to write raw external log")
|
||||
return ""
|
||||
|
||||
def _enrich_structured_result_artifacts(
|
||||
@@ -2231,8 +2228,7 @@ class ExternalAgentBroker:
|
||||
token_record,
|
||||
)
|
||||
except Exception:
|
||||
logger.debug(
|
||||
logger.opt(exception=True).debug(
|
||||
f"PR6 role adapter-state write failed "
|
||||
f"sid={role_session_id} agent={adapter.agent_type}",
|
||||
exc_info=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user