fix(compression): debug-log checkpoint capability probe failures
Keep init fail-open on a broken probe, but emit DEBUG so flaky probes are diagnosable. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1292,6 +1292,8 @@ def _warn_checkpoint_required_without_capable_provider(agent: Any) -> None:
|
||||
|
||||
Capability-probe exceptions are suppressed so a broken provider cannot crash
|
||||
agent construction — same fail-open style as the micro-compact warning.
|
||||
Probe failures log at DEBUG so a flaky probe can be diagnosed without
|
||||
refusing init or emitting the incapable-provider WARNING.
|
||||
"""
|
||||
if getattr(agent, "compression_checkpoint_required", False) is not True:
|
||||
return
|
||||
@@ -1302,7 +1304,12 @@ def _warn_checkpoint_required_without_capable_provider(agent: Any) -> None:
|
||||
try:
|
||||
if bool(supports_checkpoint(PRE_COMPRESS_CHECKPOINT_API_VERSION)):
|
||||
return
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
logger.debug(
|
||||
"checkpoint-required capability probe failed; init continues: %s",
|
||||
exc,
|
||||
exc_info=True,
|
||||
)
|
||||
return
|
||||
logger.warning(
|
||||
"compression.checkpoint_required is enabled but the active memory "
|
||||
|
||||
@@ -696,7 +696,15 @@ def test_startup_probe_exception_fails_open_without_crash_or_warning(caplog):
|
||||
_memory_manager=_ExplodingManager(),
|
||||
)
|
||||
|
||||
with caplog.at_level(logging.WARNING, logger="agent.conversation_compression"):
|
||||
with caplog.at_level(logging.DEBUG, logger="agent.conversation_compression"):
|
||||
_warn_checkpoint_required_without_capable_provider(agent)
|
||||
|
||||
assert "compression.checkpoint_required" not in _warn_text(caplog)
|
||||
warnings = "\n".join(
|
||||
r.getMessage() for r in caplog.records if r.levelno >= logging.WARNING
|
||||
)
|
||||
debugs = "\n".join(
|
||||
r.getMessage() for r in caplog.records if r.levelno == logging.DEBUG
|
||||
)
|
||||
assert "compression.checkpoint_required" not in warnings
|
||||
assert "probe exploded" in debugs
|
||||
assert "capability probe failed" in debugs
|
||||
|
||||
Reference in New Issue
Block a user