[BUG] RedisStorage.save() reports success when the write failed, and load() returns [] for an unreachable Redis
Required prerequisites
- I have read the documentation.
- I have searched the Issue Tracker and Discussions and this has not already been reported.
What version of camel are you using?
0.2.91a7 (master at 0106b76)
System information
macOS 15.7.3 (arm64), Python 3.10.7
Problem description
RedisStorage.save(), load() and clear() catch every exception and only log it. save() returns None whether or not the write happened, and load() returns [] for an unreachable Redis, the same value as an empty session. So an agent can save its history, lose it to a Redis outage, and carry on with no memory and no error.
It looks unintended: InMemoryKeyValueStorage and JsonStorage, which implement the same base class, have no handler on these methods, and 13 of the 15 load() implementations in camel/storages let errors through. Mem0Storage has the same shape as RedisStorage on all three methods.
Proposal: let the three methods raise, as the in-memory and JSON storages do. load() would still return [] for a session with nothing stored. I can open the PR if this direction is accepted.
Reproducible example code
import asyncio
from unittest.mock import AsyncMock
from camel.storages.key_value_storages import RedisStorage
storage = RedisStorage(sid="s", loop=asyncio.get_event_loop())
storage._client = AsyncMock()
storage._client.set = AsyncMock(side_effect=ConnectionError("connection refused"))
storage._client.get = AsyncMock(side_effect=ConnectionError("connection refused"))
print(storage.save([{"a": 1}])) # None, as a successful save returns
print(storage.load()) # []Source: camel-ai/camel