diff --git a/plugins/memory/hindsight/__init__.py b/plugins/memory/hindsight/__init__.py index c35b18949358c..23a7621aeef8f 100644 --- a/plugins/memory/hindsight/__init__.py +++ b/plugins/memory/hindsight/__init__.py @@ -1060,7 +1060,11 @@ def _tool_retain(self, args: dict) -> str: occurred_at=args.get("occurred_at")) logger.debug("Tool hindsight_retain: bank=%s, content_len=%d, context=%s", self._bank_id, len(content), context) - self._retain_batch(item, bank_id=self._bank_id) + # Forward the configured retain_async mode: the tool handler must not + # silently drop the async/sync choice (defaults differ — aretain_batch + # itself defaults retain_async to its own server default, ignoring + # the provider config). + self._retain_batch(item, bank_id=self._bank_id, retain_async=self._retain_async) logger.debug("Tool hindsight_retain: success") return "Memory stored successfully." diff --git a/tests/plugins/memory/test_hindsight_provider.py b/tests/plugins/memory/test_hindsight_provider.py index e5239866be4ad..e4e9fe06f986c 100644 --- a/tests/plugins/memory/test_hindsight_provider.py +++ b/tests/plugins/memory/test_hindsight_provider.py @@ -458,6 +458,16 @@ def test_retain_success(self, provider): assert "bank_id" not in item assert "retain_async" not in item + @pytest.mark.parametrize("retain_async", [True, False]) + def test_retain_forwards_configured_async_mode( + self, provider_with_config, retain_async + ): + p = provider_with_config(retain_async=retain_async) + p.handle_tool_call("hindsight_retain", {"content": "remember this"}) + + call_kwargs = p._client.aretain_batch.call_args.kwargs + assert call_kwargs["retain_async"] is retain_async + def test_retain_defaults_item_timestamp_when_no_occurred_at(self, provider, monkeypatch): event_time = datetime(2026, 8, 24, 9, 30, tzinfo=ZoneInfo("America/Los_Angeles")) monkeypatch.setattr("plugins.memory.hindsight._hermes_now", lambda: event_time)