The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(checkpoints): surface skipped_oversize to users and stop misreporting failed deletes as restored
kshitijk4poord62a05e94c74
diff --git a/gateway/slash_commands.py b/gateway/slash_commands.pyindex fe497b67842..6c326069747 100644--- a/gateway/slash_commands.py+++ b/gateway/slash_commands.py@@ -3479,6 +3479,14 @@ class GatewaySlashCommandsMixin:"gateway.rollback.kept_user_edits",files=shown + more,)+ oversize = result.get("skipped_oversize") or []+ if oversize:+ shown = ", ".join(oversize[:5])+ more = f" (+{len(oversize) - 5})" if len(oversize) > 5 else ""+ msg += "\n" + t(+ "gateway.rollback.kept_oversize",+ files=shown + more,+ )return msgreturn t("gateway.rollback.restore_failed", error=result["error"])diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.pyindex 2bde61a90c3..d399f2fa1ee 100644--- a/hermes_cli/cli_commands_mixin.py+++ b/hermes_cli/cli_commands_mixin.py@@ -165,6 +165,11 @@ class CLICommandsMixin:more = f" (+{len(skipped) - 5} more)" if len(skipped) > 5 else ""print(f" ↷ Kept your hand-edits: {shown}{more}")print(" Use /rollback <N> --all to restore those too.")+ oversize = result.get("skipped_oversize") or []+ if oversize:+ shown = ", ".join(oversize[:5])+ more = f" (+{len(oversize) - 5} more)" if len(oversize) > 5 else ""+ print(f" ↷ Kept (too large for checkpoints, no stored copy to revert to): {shown}{more}")print(" A pre-rollback snapshot was saved automatically.")# Also undo the last conversation turn so the agent's contextdiff --git a/locales/af.yaml b/locales/af.yamlindex 2c578ebc2ac..b1606af7bd4 100644--- a/locales/af.yaml+++ b/locales/af.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Ongeldige kontrolepunt-nommer. Gebruik 1-{max}."restored: "✅ Herstel na kontrolepunt {hash}: {reason}\n'n Voor-terugrol-momentopname is outomaties gestoor."kept_user_edits: "↷ Jou handwysigings is behou: {files}\nGebruik /rollback <N> --all om dié ook te herstel."+ kept_oversize: "↷ Behou (te groot vir kontrolepunte, geen gestoorde kopie om na terug te keer nie): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/ar.yaml b/locales/ar.yamlindex 7512a056221..8230c2c2c94 100644--- a/locales/ar.yaml+++ b/locales/ar.yaml@@ -300,6 +300,7 @@ gateway:invalid_number: "رقم نقطة تحقّق غير صالح. استخدم 1-{max}."restored: "✅ استُعيد إلى نقطة التحقّق {hash}: {reason}\nحُفظت لقطة ما قبل التراجع تلقائيًا."kept_user_edits: "↷ احتُفظ بتعديلاتك اليدوية: {files}\nاستخدم /rollback <N> --all لاستعادتها أيضًا."+ kept_oversize: "↷ احتُفظ به (أكبر من أن يُحفظ في نقاط التفتيش، لا توجد نسخة مخزنة للرجوع إليها): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/de.yaml b/locales/de.yamlindex 24fb2645c60..c7006020f8a 100644--- a/locales/de.yaml+++ b/locales/de.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Ungültige Checkpoint-Nummer. Verwenden Sie 1-{max}."restored: "✅ Auf Checkpoint {hash} wiederhergestellt: {reason}\nEin Pre-Rollback-Snapshot wurde automatisch gespeichert."kept_user_edits: "↷ Deine manuellen Änderungen wurden behalten: {files}\nNutze /rollback <N> --all, um auch diese wiederherzustellen."+ kept_oversize: "↷ Behalten (zu groß für Checkpoints, keine gespeicherte Kopie zum Zurücksetzen): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/en.yaml b/locales/en.yamlindex b395fb99ab0..dbce02e0c48 100644--- a/locales/en.yaml+++ b/locales/en.yaml@@ -292,6 +292,7 @@ gateway:invalid_number: "Invalid checkpoint number. Use 1-{max}."restored: "✅ Restored to checkpoint {hash}: {reason}\nA pre-rollback snapshot was saved automatically."kept_user_edits: "↷ Kept your hand-edits: {files}\nUse /rollback <N> --all to restore those too."+ kept_oversize: "↷ Kept (too large for checkpoints, no stored copy to revert to): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/es.yaml b/locales/es.yamlindex 10449023776..65fa1aab150 100644--- a/locales/es.yaml+++ b/locales/es.yaml@@ -277,6 +277,7 @@ gateway:invalid_number: "Número de checkpoint inválido. Usa 1-{max}."restored: "✅ Restaurado al checkpoint {hash}: {reason}\nSe guardó automáticamente un snapshot previo al rollback."kept_user_edits: "↷ Se conservaron tus ediciones manuales: {files}\nUsa /rollback <N> --all para restaurarlas también."+ kept_oversize: "↷ Conservado (demasiado grande para los checkpoints, no hay copia guardada a la que revertir): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/fr.yaml b/locales/fr.yamlindex 44ad06b4762..481494a8d3b 100644--- a/locales/fr.yaml+++ b/locales/fr.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Numéro de point de contrôle invalide. Utilisez 1-{max}."restored: "✅ Restauré au point de contrôle {hash} : {reason}\nUn instantané pré-rollback a été enregistré automatiquement."kept_user_edits: "↷ Vos modifications manuelles ont été conservées : {files}\nUtilisez /rollback <N> --all pour les restaurer aussi."+ kept_oversize: "↷ Conservé (trop volumineux pour les checkpoints, aucune copie enregistrée vers laquelle revenir) : {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/ga.yaml b/locales/ga.yamlindex 2b6ab3d6616..4658541457e 100644--- a/locales/ga.yaml+++ b/locales/ga.yaml@@ -284,6 +284,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Uimhir seicphointe neamhbhailí. Úsáid 1-{max}."restored: "✅ Aischurtha go seicphointe {hash}: {reason}\nSábháladh roghchóip réamh-rollback go huathoibríoch."kept_user_edits: "↷ Coinníodh do chuid athruithe láimhe: {files}\nÚsáid /rollback <N> --all chun iad sin a aischur freisin."+ kept_oversize: "↷ Coinnithe (ró-mhór do sheicphointí, níl aon chóip stóráilte le filleadh uirthi): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/hu.yaml b/locales/hu.yamlindex 1533722f6a5..334a6f98382 100644--- a/locales/hu.yaml+++ b/locales/hu.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Érvénytelen ellenőrzőpont-szám. Használj 1-{max} közötti értéket."restored: "✅ Visszaállítva a(z) {hash} ellenőrzőpontra: {reason}\nA visszaállítás előtti pillanatkép automatikusan elmentve."kept_user_edits: "↷ A kézi szerkesztéseid megmaradtak: {files}\nHasználd a /rollback <N> --all parancsot, hogy azokat is visszaállítsd."+ kept_oversize: "↷ Megtartva (túl nagy az ellenőrzőpontokhoz, nincs tárolt másolat, amire vissza lehetne állni): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/it.yaml b/locales/it.yamlindex e809e5abaac..4124945df37 100644--- a/locales/it.yaml+++ b/locales/it.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Numero di checkpoint non valido. Usa 1-{max}."restored: "✅ Ripristinato al checkpoint {hash}: {reason}\nUno snapshot pre-rollback è stato salvato automaticamente."kept_user_edits: "↷ Le tue modifiche manuali sono state conservate: {files}\nUsa /rollback <N> --all per ripristinare anche quelle."+ kept_oversize: "↷ Conservato (troppo grande per i checkpoint, nessuna copia salvata a cui tornare): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/ja.yaml b/locales/ja.yamlindex df730df3067..c96bf559a62 100644--- a/locales/ja.yaml+++ b/locales/ja.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "無効なチェックポイント番号です。1-{max} を使用してください。"restored: "✅ チェックポイント {hash} に復元しました: {reason}\nロールバック前のスナップショットが自動的に保存されました。"kept_user_edits: "↷ 手動編集は保持されました: {files}\nそれらも復元するには /rollback <N> --all を使用してください。"+ kept_oversize: "↷ 保持しました(チェックポイントには大きすぎるため、戻せる保存コピーがありません): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/ko.yaml b/locales/ko.yamlindex a3ba80ce3f5..07990df2e4c 100644--- a/locales/ko.yaml+++ b/locales/ko.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "잘못된 체크포인트 번호입니다. 1-{max}을 사용하세요."restored: "✅ 체크포인트 {hash}(으)로 복원됨: {reason}\n롤백 전 스냅샷이 자동으로 저장되었습니다."kept_user_edits: "↷ 직접 수정한 내용은 유지되었습니다: {files}\n해당 파일도 복원하려면 /rollback <N> --all 을 사용하세요."+ kept_oversize: "↷ 유지됨 (체크포인트에 저장하기엔 너무 커서 되돌릴 저장본이 없습니다): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/pt.yaml b/locales/pt.yamlindex fc615a7eb40..c40b0c0389c 100644--- a/locales/pt.yaml+++ b/locales/pt.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Número de checkpoint inválido. Usa 1-{max}."restored: "✅ Restaurado para o checkpoint {hash}: {reason}\nFoi guardado automaticamente um snapshot anterior ao rollback."kept_user_edits: "↷ As suas edições manuais foram mantidas: {files}\nUse /rollback <N> --all para restaurar essas também."+ kept_oversize: "↷ Mantido (grande demais para os checkpoints, sem cópia guardada para reverter): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/ru.yaml b/locales/ru.yamlindex 3ec27bee9c9..be08f044357 100644--- a/locales/ru.yaml+++ b/locales/ru.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Недействительный номер контрольной точки. Используйте 1-{max}."restored: "✅ Восстановлено до контрольной точки {hash}: {reason}\nСнимок перед откатом сохранён автоматически."kept_user_edits: "↷ Ваши ручные правки сохранены: {files}\nИспользуйте /rollback <N> --all, чтобы восстановить и их."+ kept_oversize: "↷ Сохранено (слишком большой для контрольных точек, нет сохранённой копии для отката): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/tr.yaml b/locales/tr.yamlindex 3c92ec6552d..791c364c16f 100644--- a/locales/tr.yaml+++ b/locales/tr.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Geçersiz kontrol noktası numarası. 1-{max} aralığını kullanın."restored: "✅ {hash} kontrol noktasına geri yüklendi: {reason}\nGeri alma öncesi anlık görüntü otomatik olarak kaydedildi."kept_user_edits: "↷ Elle yaptığınız düzenlemeler korundu: {files}\nOnları da geri yüklemek için /rollback <N> --all kullanın."+ kept_oversize: "↷ Korundu (denetim noktaları için çok büyük, geri dönülecek kayıtlı kopya yok): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/uk.yaml b/locales/uk.yamlindex a4ca0708284..123b70f079f 100644--- a/locales/uk.yaml+++ b/locales/uk.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "Недійсний номер контрольної точки. Використовуйте 1-{max}."restored: "✅ Відновлено до контрольної точки {hash}: {reason}\nЗнімок перед відкатом збережено автоматично."kept_user_edits: "↷ Ваші ручні правки збережено: {files}\nВикористайте /rollback <N> --all, щоб відновити і їх."+ kept_oversize: "↷ Збережено (завеликий для контрольних точок, немає збереженої копії для відкату): {files}"restore_failed: "❌ {error}"diff:diff --git a/locales/zh-hant.yaml b/locales/zh-hant.yamlindex 224c2f21bf8..f61216e45d2 100644--- a/locales/zh-hant.yaml+++ b/locales/zh-hant.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "無效的檢查點編號。請使用 1-{max}。"restored: "✅ 已還原至檢查點 {hash}:{reason}\n已自動儲存回復前的快照。"kept_user_edits: "↷ 已保留您的手動編輯:{files}\n若也要還原這些檔案,請使用 /rollback <N> --all。"+ kept_oversize: "↷ 已保留(檔案過大無法納入檢查點,沒有可還原的儲存副本):{files}"restore_failed: "❌ {error}"diff:diff --git a/locales/zh.yaml b/locales/zh.yamlindex de32de51150..686cb1ea554 100644--- a/locales/zh.yaml+++ b/locales/zh.yaml@@ -280,6 +280,7 @@ Future messages in this room will use that transcript until `/reset` or anotherinvalid_number: "无效的检查点编号。请使用 1-{max}。"restored: "✅ 已恢复到检查点 {hash}:{reason}\n已自动保存回滚前的快照。"kept_user_edits: "↷ 已保留您的手动编辑:{files}\n如需一并恢复这些文件,请使用 /rollback <N> --all。"+ kept_oversize: "↷ 已保留(文件过大无法纳入检查点,没有可恢复的存储副本):{files}"restore_failed: "❌ {error}"diff:diff --git a/tests/tools/test_checkpoint_manager.py b/tests/tools/test_checkpoint_manager.pyindex a42658bf639..b97482cb3ff 100644--- a/tests/tools/test_checkpoint_manager.py+++ b/tests/tools/test_checkpoint_manager.py@@ -528,6 +528,33 @@ class TestSafeRestore:assert "scratch.txt" in result["restored_files"]assert "skipped_oversize" not in result+ def test_safe_restore_does_not_report_a_failed_delete_as_restored(+ self, mgr, work_dir, monkeypatch,+ ):+ """A delete_target whose unlink fails stays on disk — reporting it in+ restored_files is the same silent misreport the oversize fix closed."""+ base = self._checkpoint(mgr, work_dir)++ stubborn = work_dir / "stubborn.txt"+ stubborn.write_text("agent scratch\n")+ mgr.record_agent_write(str(stubborn))++ import pathlib++ real_unlink = pathlib.Path.unlink++ def failing_unlink(self, *args, **kwargs):+ if self.name == "stubborn.txt":+ raise OSError(13, "Permission denied")+ return real_unlink(self, *args, **kwargs)++ monkeypatch.setattr(pathlib.Path, "unlink", failing_unlink)+ result = mgr.restore(str(work_dir), base, safe=True)++ assert result["success"] is True+ assert stubborn.exists()+ assert "stubborn.txt" not in result["restored_files"]+def test_unsafe_restore_overwrites_everything(self, mgr, work_dir):base = self._checkpoint(mgr, work_dir)(work_dir / "main.py").write_text("agent version\n")diff --git a/tools/checkpoint_manager.py b/tools/checkpoint_manager.pyindex 3c0deff6411..966673fef3b 100644--- a/tools/checkpoint_manager.py+++ b/tools/checkpoint_manager.py@@ -1124,6 +1124,8 @@ class CheckpointManager:"debug": err or None}skipped_user_edits: List[str] = []+ kept_oversize: List[str] = []+ failed_deletes: List[str] = []restore_paths: Optional[List[str]] = Noneif safe and not file_path:plan = self.safe_restore_plan(abs_dir, commit_hash)@@ -1157,7 +1159,6 @@ class CheckpointManager:# Hermes-created files absent from it (delete to restore state).checkout_targets: List[str] = []delete_targets: List[str] = []- kept_oversize: List[str] = []for rel in restore_paths:ok_in_commit, _, _ = _run_git(["cat-file", "-e", f"{commit_hash}:{rel}"],@@ -1184,6 +1185,7 @@ class CheckpointManager:target.unlink()except OSError as exc:logger.debug("Safe restore: could not remove %s: %s", rel, exc)+ failed_deletes.append(rel)if not checkout_targets:ok, stdout, err = True, "", ""else:@@ -1218,11 +1220,13 @@ class CheckpointManager:result["file"] = file_pathif restore_paths is not None:# Only what was actually acted on. A kept oversize path was not- # restored, and reporting it as such is how the data loss above- # stayed silent: the user was told "Restored" for a file that had- # just been unlinked.+ # restored (and a failed unlink left the file in place), and+ # reporting either as restored is how the data loss above stayed+ # silent: the user was told "Restored" for a file that had just+ # been unlinked.+ not_restored = set(kept_oversize) | set(failed_deletes)result["restored_files"] = [- rel for rel in restore_paths if rel not in kept_oversize+ rel for rel in restore_paths if rel not in not_restored]result["skipped_user_edits"] = skipped_user_editsif kept_oversize: