Skip to content

Your lightweight open-source personal agent.

docs: add note about ephemeral guard and per-call hooks contextvar

michaelxera19725bc57f0
diff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.py
index 1f7906c1d..43662489a 100644
--- a/nanobot/agent/loop.py
+++ b/nanobot/agent/loop.py
@@ -729,6 +729,10 @@ class AgentLoop:
hook: AgentHook = loop_hook
per_call = _per_call_hooks.get()
extra_hooks = None
+ # NOTE: SDK callers always go through run() → process_direct(ephemeral=False),
+ # so per_call hooks are intentionally excluded from ephemeral turns. If a future
+ # caller sets the contextvar and then calls process_direct(ephemeral=True), the
+ # hooks will correctly NOT fire (ephemeral guard takes precedence).
if not ephemeral:
extra_hooks = per_call if per_call is not None else self._extra_hooks
if extra_hooks: