JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(progressive): 冻结 eager 工具顺序,导航按名称指纹稳定前缀缓存
renquanjia69598956020c
diff --git a/jiuwenswarm/agents/harness/common/rails/progressive_tool_rail.py b/jiuwenswarm/agents/harness/common/rails/progressive_tool_rail.pyindex 0df9e76ae5..ed8314774e 100644--- a/jiuwenswarm/agents/harness/common/rails/progressive_tool_rail.py+++ b/jiuwenswarm/agents/harness/common/rails/progressive_tool_rail.py@@ -144,6 +144,10 @@ class ProgressiveToolRail(DeepAgentRail):self._owned_tool_ids: set[str] = set()self._cached_all_tool_infos: list[Any] = []self._cached_deferred_tool_infos: list[Any] = []+ # Fingerprint of deferred tool *names* last written into TOOL_NAVIGATION.+ # Instance id churn (OfficeClaw request-scoped MCP rebind) must refresh+ # invoke caches but must not rewrite this system prompt section.+ self._navigation_name_fingerprint: frozenset[str] | None = None# Request-scoped OfficeClaw MCP allowlist for this session agent.# Interaction rounds do not inherit the facade ContextVar, so# invoke_tool re-binds from this attribute before tool execution.@@ -152,7 +156,12 @@ class ProgressiveToolRail(DeepAgentRail):self._office_claw_invocation_id: str | None = Nonedef update_disabled_tools(self, disabled_tools: list[str] | None) -> None:- """Replace the local blacklist mirror and drop stale deferred cache."""+ """Replace the local blacklist mirror and drop stale deferred cache.++ Also clears the navigation name fingerprint (via+ ``invalidate_deferred_tool_cache``) so blacklist-driven name changes+ force a TOOL_NAVIGATION rebuild on the next model call.+ """self._disabled_tools = {str(name).strip()for name in (disabled_tools or [])@@ -377,9 +386,16 @@ class ProgressiveToolRail(DeepAgentRail):self._meta_tools = Nonedef invalidate_deferred_tool_cache(self) -> None:- """Clear deferred tool caches (after agent rebind or reload)."""+ """Clear deferred tool caches and nav fingerprint (after agent rebind/reload).++ Fingerprint must drop with the caches: a rebind/reload may install a+ blank ``SystemPromptBuilder`` while this rail instance (and an old+ fingerprint) survive. Leaving the fingerprint set would skip rewriting+ ``TOOL_NAVIGATION`` into the new builder.+ """self._cached_all_tool_infos = []self._cached_deferred_tool_infos = []+ self._navigation_name_fingerprint = Nonedef _resolve_runtime_agent(self,@@ -621,43 +637,95 @@ class ProgressiveToolRail(DeepAgentRail):name = str(getattr(tool, "name", "") or "")if name in self.eager_tools and name not in disabled:filtered_tools.append(tool)- inputs.tools = filtered_tools+ # Canonical eager order — never follow ability_manager / MCP rebind order.+ # Mid-task send_file_to_user <-> tools_search swaps break LLM prefix cache.+ inputs.tools = self._order_tools_by_eager_list(filtered_tools)- removed = sorted(set(- str(getattr(tool, "name", "") or "")- for tool in tools- ) - set(- str(getattr(tool, "name", "") or "")- for tool in filtered_tools- ))+ input_tool_names = set()+ for tool in tools:+ input_tool_names.add(str(getattr(tool, "name", "") or ""))+ eager_tool_names = set()+ for tool in inputs.tools:+ eager_tool_names.add(str(getattr(tool, "name", "") or ""))+ removed = sorted(input_tool_names - eager_tool_names)logger.info("%s filter tools %s -> %s removed=%s disabled=%s",_LOG_PREFIX,original_count,- len(filtered_tools),+ len(inputs.tools),removed,sorted(disabled),)await self._add_navigation_section(ctx)+ def _order_tools_by_eager_list(self, tools: list[Any]) -> list[Any]:+ """Stable-sort filtered tools to match ``self.eager_tools`` order."""+ by_name: dict[str, Any] = {}+ for tool in tools:+ name = str(getattr(tool, "name", "") or "")+ if name and name not in by_name:+ by_name[name] = tool+ return [by_name[name] for name in self.eager_tools if name in by_name]++ @staticmethod+ def _deferred_name_fingerprint(tools: list[Any]) -> frozenset[str]:+ """Return a name-only fingerprint for TOOL_NAVIGATION cache stability.++ Description-only changes intentionally do not rewrite the navigation+ section; ``tools_search`` remains the source of truth for live schemas.+ """+ names = set()+ for tool in tools:+ name = str(getattr(tool, "name", "") or "").strip()+ if name:+ names.add(name)+ return frozenset(names)+# ------------------------------------------------------------------# Navigation prompt# ------------------------------------------------------------------async def _add_navigation_section(self, ctx: AgentCallbackContext) -> None:- """Add tool navigation prompt section."""+ """Add tool navigation prompt section when deferred *names* change.++ OfficeClaw request-scoped MCP rebinds swap tool ids while keeping names.+ Instance caches still refresh via ``_refresh_deferred_tool_cache_if_stale``;+ the system TOOL_NAVIGATION text must stay frozen across id-only churn.++ Fingerprint match alone is not enough to skip: DeepAgent hot-reload can+ rebuild a blank ``SystemPromptBuilder`` while preserving this rail (and+ its fingerprint). Mirror agent-core ContextAssembleRail: only early-return+ when the *current* builder still has the section.+ """if ctx.agent is None:return+ spb = getattr(ctx.agent, "system_prompt_builder", None)+ name_fp = self._deferred_name_fingerprint(self._cached_deferred_tool_infos)+ section_present = bool(+ spb is not None+ and hasattr(spb, "has_section")+ and spb.has_section(SectionName.TOOL_NAVIGATION)+ )+ if (+ self._navigation_name_fingerprint is not None+ and name_fp == self._navigation_name_fingerprint+ and section_present+ ):+ return+navigation_section = await self._build_navigation_section()if navigation_section is None:+ # Empty deferred set: clear fingerprint so a later non-empty set rebuilds.+ if not name_fp:+ self._navigation_name_fingerprint = frozenset()return- spb = getattr(ctx.agent, "system_prompt_builder", None)if spb is not None and hasattr(spb, "add_section"):spb.add_section(navigation_section)+ self._navigation_name_fingerprint = name_fpasync def _build_navigation_section(self) -> PromptSection | None:"""Build navigation prompt section for deferred tools."""diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.pyindex 4051adf2de..8294c757a3 100644--- a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py+++ b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py@@ -1677,30 +1677,97 @@ def _deep_agent_kv_cache_affinity_config(def _build_context_assemble_rail(disabled_tools: list[str] | None = None,+ tool_name_allowlist: list[str] | None = None,) -> ContextAssembleRail | None:"""Build ContextAssembleRail.``disabled_tools`` seeds the tools prompt hide-list. Product adapters ownthe blacklist data flow at construction time (and optional later- ``update_disabled_tools`` calls). Compatible with older openjiuwen / test- fakes whose constructor does not accept ``disabled_tools=``: fall back to- no-arg construction and ``update_disabled_tools`` when available.+ ``update_disabled_tools`` calls).++ ``tool_name_allowlist`` (typically ProgressiveToolRail.eager_tools) keeps the+ system ``# 可用工具`` section aligned with the fixed eager schema so deferred+ / OfficeClaw MCP registrations do not rewrite the prompt prefix mid-task.+ Compatible with older openjiuwen / test fakes whose constructor does not+ accept the newer kwargs.++ Merge order: land agent-core !2840 (``tool_name_allowlist`` + tools-section+ fingerprint ``has_section`` guard) before this change. Without !2840 the+ modern kwargs raise ``TypeError`` and we silently fall back to the legacy+ constructor / optional setter path."""try:+ ctor_path = "modern"+ effective_disabled: list[str] | None = disabled_tools+ effective_allowlist: list[str] | None = tool_name_allowlisttry:- context_assemble_rail = ContextAssembleRail(disabled_tools=disabled_tools)+ context_assemble_rail = ContextAssembleRail(+ disabled_tools=disabled_tools,+ tool_name_allowlist=tool_name_allowlist,+ )except TypeError:- context_assemble_rail = ContextAssembleRail()- update = getattr(context_assemble_rail, "update_disabled_tools", None)- if callable(update) and disabled_tools:- update(disabled_tools)- logger.info("[JiuWenSwarmDeepAdapter] ContextAssembleRail create success")+ # Requested allowlist is not in effect until a setter applies it.+ effective_allowlist = None+ try:+ context_assemble_rail = ContextAssembleRail(disabled_tools=disabled_tools)+ ctor_path = "legacy_disabled_kw"+ except TypeError:+ context_assemble_rail = ContextAssembleRail()+ ctor_path = "legacy_no_args"+ effective_disabled = None+ update = getattr(context_assemble_rail, "update_disabled_tools", None)+ if callable(update) and disabled_tools:+ update(disabled_tools)+ effective_disabled = list(disabled_tools)+ setter = getattr(context_assemble_rail, "set_tool_name_allowlist", None)+ if callable(setter) and tool_name_allowlist is not None:+ setter(tool_name_allowlist)+ effective_allowlist = list(tool_name_allowlist)+ # Prefer instance state when the rail exposes what actually stuck.+ for attr in ("tool_name_allowlist", "_tool_name_allowlist"):+ if hasattr(context_assemble_rail, attr):+ effective_allowlist = getattr(context_assemble_rail, attr)+ break+ for attr in ("disabled_tools", "_disabled_tools"):+ if hasattr(context_assemble_rail, attr):+ value = getattr(context_assemble_rail, attr)+ if isinstance(value, (set, frozenset)):+ effective_disabled = sorted(str(item) for item in value)+ elif value is not None:+ effective_disabled = list(value)+ else:+ effective_disabled = None+ break+ logger.info(+ "[JiuWenSwarmDeepAdapter] ContextAssembleRail create success "+ "(path=%s disabled_tools=%s allowlist=%s)",+ ctor_path,+ list(effective_disabled) if effective_disabled else None,+ list(effective_allowlist) if effective_allowlist else None,+ )except Exception as exc:logger.warning("[JiuWenSwarmDeepAdapter] ContextAssembleRail create failed: %s", exc)context_assemble_rail = Nonereturn context_assemble_rail+def _sync_context_assemble_tool_allowlist(+ assemble: ContextAssembleRail | None,+ progressive: Any | None,+) -> None:+ """Keep ContextAssemble tools-section allowlist aligned with eager schema."""+ if assemble is None:+ return+ setter = getattr(assemble, "set_tool_name_allowlist", None)+ if not callable(setter):+ return+ if progressive is None:+ setter(None)+ return+ eager = getattr(progressive, "eager_tools", None) or []+ setter(list(eager))++def _resolve_session_memory_config(context_engine_cfg: dict[str, Any]) -> dict[str, Any] | None:raw_config = (context_engine_cfg.get("session_memory_config")@@ -9699,8 +9766,16 @@ class JiuWenSwarmDeepAdapter:),invocation_id=active_mcp.invocation_id or None,)+ _sync_context_assemble_tool_allowlist(+ self._context_assemble_rail,+ progressive_tool_rail,+ )elif old_progressive_tool_rail is not None:rails_to_unregister.append(old_progressive_tool_rail)+ _sync_context_assemble_tool_allowlist(+ self._context_assemble_rail,+ None,+ )# 统一工具开关热更新:重建式(与 ProgressiveToolRail 一致)。# 旧 rail uninit 时回滚它注销的工具(重新注册),新 rail init 再按新名单注销。@@ -11305,14 +11380,22 @@ class JiuWenSwarmDeepAdapter:)self._context_assemble_rail = _build_context_assemble_rail(disabled_tools=disabled_list or None,+ tool_name_allowlist=(+ list(self._progressive_tool_rail.eager_tools)+ if self._progressive_tool_rail is not None+ else None+ ),)self._context_assemble_mode = "agent"if self._context_assemble_rail is not None:await self._instance.register_rail(self._context_assemble_rail)logger.info("[JiuWenSwarmDeepAdapter] ContextAssembleRail registered for agent mode "- "(disabled_tools=%s)",+ "(disabled_tools=%s allowlist=%s)",disabled_list,+ list(self._progressive_tool_rail.eager_tools)+ if self._progressive_tool_rail is not None+ else None,)else:logger.warning(diff --git a/tests/unit_tests/agentserver/test_context_assemble_allowlist_compat.py b/tests/unit_tests/agentserver/test_context_assemble_allowlist_compat.pynew file mode 100644index 0000000000..9f79d85d6c--- /dev/null+++ b/tests/unit_tests/agentserver/test_context_assemble_allowlist_compat.py@@ -0,0 +1,143 @@+# Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.++"""Compatibility tests for ContextAssembleRail eager-tool allowlists."""++# pylint: disable=protected-access++import logging+from types import SimpleNamespace++from jiuwenswarm.server.runtime.agent_adapter import interface_deep+++def test_build_context_assemble_rail_uses_modern_signature(monkeypatch):+ class ModernContextAssembleRail:+ def __init__(self, *, disabled_tools=None, tool_name_allowlist=None):+ self.disabled_tools = disabled_tools+ self.tool_name_allowlist = tool_name_allowlist++ monkeypatch.setattr(+ interface_deep,+ "ContextAssembleRail",+ ModernContextAssembleRail,+ )++ rail = interface_deep._build_context_assemble_rail(+ disabled_tools=["memory_search"],+ tool_name_allowlist=["tools_search", "invoke_tool"],+ )++ assert rail.disabled_tools == ["memory_search"]+ assert rail.tool_name_allowlist == ["tools_search", "invoke_tool"]+++def test_build_context_assemble_rail_falls_back_and_calls_setter(monkeypatch):+ class LegacyContextAssembleRail:+ def __init__(self, disabled_tools=None):+ self.disabled_tools = disabled_tools+ self.allowlist_calls = []++ def set_tool_name_allowlist(self, tool_names):+ self.allowlist_calls.append(tool_names)++ monkeypatch.setattr(+ interface_deep,+ "ContextAssembleRail",+ LegacyContextAssembleRail,+ )++ rail = interface_deep._build_context_assemble_rail(+ disabled_tools=["memory_search"],+ tool_name_allowlist=["tools_search", "invoke_tool"],+ )++ assert rail.disabled_tools == ["memory_search"]+ assert rail.allowlist_calls == [["tools_search", "invoke_tool"]]+++def test_build_context_assemble_rail_falls_back_to_no_args(monkeypatch):+ class OldContextAssembleRail:+ def __init__(self):+ self.disabled_calls = []++ def update_disabled_tools(self, tool_names):+ self.disabled_calls.append(tool_names)++ monkeypatch.setattr(+ interface_deep,+ "ContextAssembleRail",+ OldContextAssembleRail,+ )++ rail = interface_deep._build_context_assemble_rail(+ disabled_tools=["memory_search"],+ tool_name_allowlist=["tools_search"],+ )++ assert rail.disabled_calls == [["memory_search"]]+++def test_build_context_assemble_rail_fallback_logs_effective_not_requested(+ monkeypatch, caplog,+):+ """Without a setter, success log must not claim the requested allowlist stuck."""++ class OldContextAssembleRail:+ def __init__(self):+ self.disabled_calls = []++ def update_disabled_tools(self, tool_names):+ self.disabled_calls.append(tool_names)++ monkeypatch.setattr(+ interface_deep,+ "ContextAssembleRail",+ OldContextAssembleRail,+ )++ # jiuwenswarm root logger sets propagate=False and uses QueueHandler;+ # pytest caplog only hangs on root, so attach the handler to this logger.+ target = interface_deep.logger+ target.addHandler(caplog.handler)+ caplog.set_level(logging.INFO, logger=target.name)+ try:+ interface_deep._build_context_assemble_rail(+ disabled_tools=["memory_search"],+ tool_name_allowlist=["tools_search", "invoke_tool"],+ )+ finally:+ target.removeHandler(caplog.handler)++ success_logs = [+ record.getMessage()+ for record in caplog.records+ if "ContextAssembleRail create success" in record.getMessage()+ ]+ assert success_logs, "expected create-success log"+ message = success_logs[-1]+ assert "path=legacy_no_args" in message+ assert "allowlist=None" in message+ assert "tools_search" not in message+ assert "disabled_tools=['memory_search']" in message+++def test_sync_context_assemble_tool_allowlist_sets_and_clears():+ calls = []+ assemble = SimpleNamespace(+ set_tool_name_allowlist=lambda tool_names: calls.append(tool_names),+ )+ progressive = SimpleNamespace(+ eager_tools=["tools_search", "invoke_tool", "bash"],+ )++ interface_deep._sync_context_assemble_tool_allowlist(assemble, progressive)+ interface_deep._sync_context_assemble_tool_allowlist(assemble, None)++ assert calls == [["tools_search", "invoke_tool", "bash"], None]+++def test_sync_context_assemble_tool_allowlist_tolerates_missing_setter():+ interface_deep._sync_context_assemble_tool_allowlist(+ SimpleNamespace(),+ SimpleNamespace(eager_tools=["tools_search"]),+ )diff --git a/tests/unit_tests/agentserver/test_progressive_prefix_cache_stability.py b/tests/unit_tests/agentserver/test_progressive_prefix_cache_stability.pynew file mode 100644index 0000000000..b8554e197f--- /dev/null+++ b/tests/unit_tests/agentserver/test_progressive_prefix_cache_stability.py@@ -0,0 +1,230 @@+# Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.++"""Prefix-cache stability tests for ProgressiveToolRail schema/nav."""++# pylint: disable=protected-access++from types import SimpleNamespace++import pytest+from openjiuwen.harness.prompts.sections import SectionName++from jiuwenswarm.agents.harness.common.rails.progressive_tool_rail import (+ ProgressiveToolRail,+)+++def _card(name: str, tool_id: str | None = None) -> SimpleNamespace:+ return SimpleNamespace(+ name=name,+ id=tool_id or f"id-{name}",+ description=f"desc-{name}",+ input_params={},+ )+++class _RecordingSPB:+ """Minimal SystemPromptBuilder stand-in with has_section (mirrors !2840)."""++ def __init__(self) -> None:+ self.sections: list = []+ self._by_name: dict = {}++ def add_section(self, section) -> None:+ self.sections.append(section)+ self._by_name[section.name] = section++ def has_section(self, name) -> bool:+ return name in self._by_name+++async def test_before_model_call_orders_tools_by_eager_list():+ """ability_manager / MCP rebind order must not change the tools schema."""+ rail = ProgressiveToolRail(+ eager_tools=[+ "tools_search",+ "invoke_tool",+ "bash",+ "send_file_to_user",+ ],+ )+ tools = [+ _card("send_file_to_user"),+ _card("bash"),+ _card("invoke_tool"),+ _card("tools_search"),+ ]+ spb = _RecordingSPB()+ agent = SimpleNamespace(+ ability_manager=SimpleNamespace(list=lambda: list(tools) + [_card("office_claw_x")]),+ system_prompt_builder=spb,+ )+ rail._deep_agent = agent+ ctx = SimpleNamespace(agent=agent, inputs=SimpleNamespace(tools=list(tools)))++ await rail.before_model_call(ctx)++ assert [tool.name for tool in ctx.inputs.tools] == [+ "tools_search",+ "invoke_tool",+ "bash",+ "send_file_to_user",+ ]+++async def test_navigation_skips_rewrite_when_only_tool_ids_change():+ """OfficeClaw request-scoped id rebind must refresh instances, not nav text."""+ rail = ProgressiveToolRail(eager_tools=["tools_search", "invoke_tool", "bash"])+ old = _card("office_claw_co_writing_initialize", "old-hash")+ new = _card("office_claw_co_writing_initialize", "new-hash")+ read_file = _card("read_file")++ spb = _RecordingSPB()+ agent = SimpleNamespace(+ ability_manager=SimpleNamespace(list=lambda: [old, read_file, _card("bash")]),+ system_prompt_builder=spb,+ )+ rail._deep_agent = agent+ rail._runtime_agent = agent+ ctx = SimpleNamespace(+ agent=agent,+ inputs=SimpleNamespace(tools=[_card("bash"), _card("tools_search"), _card("invoke_tool")]),+ )++ await rail.before_model_call(ctx)+ assert len(spb.sections) == 1+ first = spb.sections[0]+ assert spb.has_section(SectionName.TOOL_NAVIGATION)++ agent.ability_manager = SimpleNamespace(list=lambda: [new, read_file, _card("bash")])+ await rail.before_model_call(ctx)+ assert len(spb.sections) == 1+ assert spb.sections[0] is first+ assert rail._cached_deferred_tool_infos[0].id == "new-hash"+++async def test_navigation_rewrites_when_deferred_names_change():+ rail = ProgressiveToolRail(eager_tools=["tools_search", "invoke_tool", "bash"])+ spb = _RecordingSPB()+ agent = SimpleNamespace(+ ability_manager=SimpleNamespace(+ list=lambda: [_card("read_file"), _card("bash")]+ ),+ system_prompt_builder=spb,+ )+ rail._deep_agent = agent+ rail._runtime_agent = agent+ ctx = SimpleNamespace(+ agent=agent,+ inputs=SimpleNamespace(tools=[_card("bash"), _card("tools_search")]),+ )++ await rail.before_model_call(ctx)+ assert len(spb.sections) == 1++ agent.ability_manager = SimpleNamespace(+ list=lambda: [_card("read_file"), _card("office_claw_x"), _card("bash")]+ )+ await rail.before_model_call(ctx)+ assert len(spb.sections) == 2+ assert "office_claw_x" in str(spb.sections[1].content)+++async def test_navigation_rewrites_when_system_prompt_builder_replaced():+ """Blank SPB after hot-reload must get TOOL_NAVIGATION even if fingerprint matches.++ Mirrors agent-core !2840 builder-replaced / has_section guard: DeepAgent+ rebuilds SystemPromptBuilder while keeping this rail instance.+ """+ rail = ProgressiveToolRail(eager_tools=["tools_search", "invoke_tool", "bash"])+ deferred = [_card("read_file"), _card("bash")]+ spb1 = _RecordingSPB()+ agent = SimpleNamespace(+ ability_manager=SimpleNamespace(list=lambda: list(deferred)),+ system_prompt_builder=spb1,+ )+ rail._deep_agent = agent+ rail._runtime_agent = agent+ ctx = SimpleNamespace(+ agent=agent,+ inputs=SimpleNamespace(tools=[_card("bash"), _card("tools_search")]),+ )++ await rail.before_model_call(ctx)+ assert spb1.has_section(SectionName.TOOL_NAVIGATION)+ assert rail._navigation_name_fingerprint is not None+ fingerprint_after_first = rail._navigation_name_fingerprint++ # Hot-reload: blank builder, same rail + same deferred names (no invalidate).+ spb2 = _RecordingSPB()+ agent.system_prompt_builder = spb2+ await rail.before_model_call(ctx)++ assert spb2.has_section(SectionName.TOOL_NAVIGATION)+ assert len(spb2.sections) == 1+ assert rail._navigation_name_fingerprint == fingerprint_after_first+++async def test_navigation_rewrites_after_agent_rebind_clears_fingerprint():+ """Agent swap via _resolve_runtime_agent must invalidate nav fingerprint."""+ rail = ProgressiveToolRail(eager_tools=["tools_search", "invoke_tool", "bash"])+ deferred = [_card("read_file"), _card("bash")]+ spb1 = _RecordingSPB()+ agent1 = SimpleNamespace(+ ability_manager=SimpleNamespace(list=lambda: list(deferred)),+ system_prompt_builder=spb1,+ )+ rail._deep_agent = agent1+ rail._runtime_agent = agent1+ ctx1 = SimpleNamespace(+ agent=agent1,+ inputs=SimpleNamespace(tools=[_card("bash"), _card("tools_search")]),+ )++ await rail.before_model_call(ctx1)+ assert spb1.has_section(SectionName.TOOL_NAVIGATION)+ assert rail._navigation_name_fingerprint is not None++ spb2 = _RecordingSPB()+ agent2 = SimpleNamespace(+ ability_manager=SimpleNamespace(list=lambda: list(deferred)),+ system_prompt_builder=spb2,+ )+ ctx2 = SimpleNamespace(+ agent=agent2,+ inputs=SimpleNamespace(tools=[_card("bash"), _card("tools_search")]),+ )++ await rail.before_model_call(ctx2)+ assert rail._deep_agent is agent2+ assert spb2.has_section(SectionName.TOOL_NAVIGATION)+ assert len(spb2.sections) == 1+++def test_update_disabled_tools_clears_navigation_fingerprint():+ rail = ProgressiveToolRail(eager_tools=["bash"])+ rail._navigation_name_fingerprint = frozenset({"read_file"})+ rail._cached_deferred_tool_infos = [_card("read_file")]++ rail.update_disabled_tools(["memory_search"])++ assert rail._navigation_name_fingerprint is None+ assert rail._cached_deferred_tool_infos == []+++def test_invalidate_deferred_tool_cache_clears_navigation_fingerprint():+ rail = ProgressiveToolRail(eager_tools=["bash"])+ rail._navigation_name_fingerprint = frozenset({"read_file"})+ rail._cached_all_tool_infos = [_card("bash")]+ rail._cached_deferred_tool_infos = [_card("read_file")]++ rail.invalidate_deferred_tool_cache()++ assert rail._navigation_name_fingerprint is None+ assert rail._cached_all_tool_infos == []+ assert rail._cached_deferred_tool_infos == []