Skip to content

Your lightweight open-source personal agent.

perf(tokens): document tool schema cache assumption

Xubin Ren98916a31e390
diff --git a/nanobot/utils/helpers.py b/nanobot/utils/helpers.py
index 7a5d808c3..4243671b9 100644
--- a/nanobot/utils/helpers.py
+++ b/nanobot/utils/helpers.py
@@ -44,6 +44,7 @@ def _estimate_tools_tokens(
leading_separator: bool,
) -> int:
"""Estimate stable tool definition tokens without re-encoding every loop."""
+ # ToolRegistry keeps the returned definitions list alive until the registry changes.
tools_id = id(tools)
fingerprint = tuple(id(tool) for tool in tools)
cached = _TOOLS_TOKEN_CACHE.get(tools_id)