From 98916a31e3908c61f7f3422fe89c725c75b3b7d5 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sat, 20 Jun 2026 22:44:45 +0800 Subject: [PATCH] perf(tokens): document tool schema cache assumption --- nanobot/utils/helpers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nanobot/utils/helpers.py b/nanobot/utils/helpers.py index 7a5d808c..4243671b 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)