Skip to content

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 testcase

yt2026cba9df288bda
diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
index 66f853ae34..90e59d908f 100644
--- a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
+++ b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
@@ -3396,7 +3396,9 @@ class JiuWenSwarmDeepAdapter:
``skill_tool`` call fails with ``Skill not found``. When the request
carries a session id that maps to a live session adapter here, run the
same lazy refresh immediately under the session lock; failures fall
- back to the lazy next-turn semantics and other sessions are untouched.
+ back to the lazy next-turn semantics (a failed refresh records the
+ shared 30s retry-suppression stamp, so the immediately following
+ boundary retry may be suppressed) and other sessions are untouched.
"""
session_id = str(getattr(request, "session_id", None) or "").strip()
if not session_id:
diff --git a/tests/unit_tests/agentserver/test_skill_session_lazy_refresh.py b/tests/unit_tests/agentserver/test_skill_session_lazy_refresh.py
index eb28728217..18c480aaa0 100644
--- a/tests/unit_tests/agentserver/test_skill_session_lazy_refresh.py
+++ b/tests/unit_tests/agentserver/test_skill_session_lazy_refresh.py
@@ -247,6 +247,36 @@ async def test_push_refresh_failure_falls_back_to_lazy(
assert "sess_a" not in root._session_skill_versions
+async def test_push_refresh_raise_is_swallowed_and_records_failure(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """A raising refresh must not escape the push; it records a failure stamp.
+
+ Pins the exception-safety that makes flag-based (not raise-based)
+ sentinels mandatory in the eviction test: the refresh chain swallows
+ exceptions by design — warning + failure stamp + shared 30s retry
+ suppression — and falls back to the lazy next-turn semantics.
+ """
+ root = _make_push_root(_skill_enabled_version=2)
+ child = _make_session_child(root, session_id="sess_a")
+ root._session_adapters["sess_a"] = child
+ monkeypatch.setattr(interface_deep_module, "is_skill_prebuilt_tenant", lambda *_a, **_k: True)
+ monkeypatch.setattr(interface_deep_module, "_skill_session_lazy_refresh_enabled", lambda: True)
+
+ async def _child_refresh() -> bool:
+ raise RuntimeError("db unavailable")
+
+ child.refresh_enabled_skills_from_db = _child_refresh # type: ignore[method-assign]
+
+ await root._push_skill_refresh_to_bound_session(SimpleNamespace(session_id="sess_a"))
+
+ # Swallowed: no raise escapes, session stays stale for the next boundary.
+ assert "sess_a" not in root._session_skill_versions
+ failure = root._session_skill_refresh_failures.get("sess_a")
+ assert failure is not None and failure[0] == 2
+
+
@pytest.mark.asyncio
async def test_push_survives_adapter_evicted_while_waiting_on_lock(
monkeypatch: pytest.MonkeyPatch,
@@ -277,8 +307,16 @@ async def test_push_survives_adapter_evicted_while_waiting_on_lock(
holder = asyncio.create_task(_evict_holder())
await lock_held.wait()
- async def _child_refresh() -> bool: # must not be reached
- raise AssertionError("refresh must not run after eviction")
+ refresh_ran = False
+
+ async def _child_refresh() -> bool:
+ # Flag, not a raise: the refresh chain swallows exceptions by design
+ # (``_refresh_session_skills_if_stale`` logs and records a failure
+ # stamp instead of propagating), so a raising sentinel would be
+ # swallowed and this regression would pass silently.
+ nonlocal refresh_ran
+ refresh_ran = True
+ return False
child.refresh_enabled_skills_from_db = _child_refresh # type: ignore[method-assign]
@@ -291,4 +329,7 @@ async def test_push_survives_adapter_evicted_while_waiting_on_lock(
await push_task
await holder
+ assert refresh_ran is False
+ # No refresh was even attempted: no version stamp, no failure stamp.
assert root._session_skill_versions == {}
+ assert root._session_skill_refresh_failures == {}