Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion plugins/memory/hindsight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down
10 changes: 10 additions & 0 deletions tests/plugins/memory/test_hindsight_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading