Skip to content

The agent that grows with you

fix(skills): guard compact_ledger() against undecodable ledger bytes

kshitijk4poor25f1f6fc4790
diff --git a/tools/skill_ledger.py b/tools/skill_ledger.py
index 44324e1238d..79266351111 100644
--- a/tools/skill_ledger.py
+++ b/tools/skill_ledger.py
@@ -304,10 +304,11 @@ def compact_ledger() -> Tuple[int, int, int]:
path = ledger_path()
try:
raw = path.read_bytes()
- except OSError:
+ text = raw.decode("utf-8")
+ except (OSError, UnicodeError):
return 0, 0, 0
out, kept = [], 0
- for line in raw.decode("utf-8").splitlines():
+ for line in text.splitlines():
if not line.strip():
continue
try: