MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _reset_hook_session

Function _reset_hook_session

graphify/cli.py:1303–1327  ·  view source on GitHub ↗

Give a compacted Claude Code session its hook budget back. After compaction the session id stays the same, but the model no longer sees the nudges it was given, and _nudge_allowed has already spent the cap. Deletes the session's nudge counter, the counter of every subagent of it (``

(session_id: str)

Source from the content-addressed store, hash-verified

1301
1302
1303def _reset_hook_session(session_id: str) -> None:
1304 """Give a compacted Claude Code session its hook budget back.
1305
1306 After compaction the session id stays the same, but the model no longer
1307 sees the nudges it was given, and _nudge_allowed has already spent the cap.
1308 Deletes the session's nudge counter, the counter of every subagent of it
1309 (``<key>-<16 hex>``, the per-agent key _nudge_allowed builds) and the
1310 strict-mode deny marker, so the next qualifying call nudges again and strict
1311 mode can redirect once more. Other sessions&#x27; markers are untouched. Errors
1312 propagate: the caller fails open.
1313 """
1314 from graphify.paths import out_path
1315 key = re.sub(r"[^A-Za-z0-9_-]", "_", str(session_id or ""))[:64]
1316 if not key:
1317 return
1318 d = out_path("cache", "hook_sessions")
1319 if not d.is_dir():
1320 return
1321 own = re.compile(re.escape(key) + r"(?:-[0-9a-f]{16})?\.nudges|" + re.escape(key) + r"\.denied")
1322 for entry in os.scandir(d):
1323 if own.fullmatch(entry.name):
1324 try:
1325 os.unlink(entry.path)
1326 except FileNotFoundError:
1327 pass
1328
1329
1330def _mark_session_denied(session_id: str) -> bool:

Callers 1

_run_hook_guardFunction · 0.85

Calls 1

out_pathFunction · 0.90

Tested by

no test coverage detected