fix: inject SessionDB into AIAgent for WebUI sessions — enables session_search (#356)
* fix: inject SessionDB into AIAgent for WebUI sessions session_search tool requires a SessionDB instance passed via the session_db parameter. The CLI and gateway paths already do this, but the WebUI streaming path was missing it, causing every session_search call to return 'Session database not available'. Initialize SessionDB before creating the AIAgent and pass it through. Failure is non-fatal — a warning is printed and session_search gracefully degrades. * fix: inject SessionDB into AIAgent for WebUI sessions (enables session_search) (#356) - api/streaming.py: initialize SessionDB() before AIAgent construction and pass session_db= kwarg so session_search works in WebUI sessions - tests/test_sprint42.py: 7 new tests covering SessionDB injection, try/except guard, WARNING log, ordering, and AST lock-safety check - CHANGELOG.md: v0.50.13 entry; 822 tests total (up from 815) --------- Co-authored-by: 王昌旭 <wangchangxu@xiaohongshu.com> Co-authored-by: Nathan Esquenazi <nesquena@gmail.com>
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
|
||||
---
|
||||
|
||||
## [v0.50.13] Fix session_search in WebUI sessions — inject SessionDB into AIAgent (PR #356)
|
||||
|
||||
- **`session_search` now works in WebUI sessions** (`api/streaming.py`): The agent's `session_search` tool returned "Session database not available" for all WebUI sessions. The CLI and gateway code paths both initialize a `SessionDB` instance and pass it via `session_db=` to `AIAgent.__init__()`, but the WebUI streaming path was missing this step. `_run_agent_streaming` now initializes `SessionDB()` before constructing the agent and passes it in. A `try/except` wrapper makes the init non-fatal — if `hermes_state` is unavailable (older installs, test environments), a `WARNING` is printed and `session_db=None` is passed instead, preserving the prior behavior gracefully.
|
||||
- 7 new tests in `tests/test_sprint42.py`; 822 tests total (up from 815)
|
||||
|
||||
## [v0.50.12] Profile .env isolation — prevent API key leakage on profile switch (fixes #351)
|
||||
|
||||
- **API keys no longer leak between profiles on switch** (`api/profiles.py`): `_reload_dotenv()` now tracks which env vars were loaded from the active profile's `.env` and clears them before loading the next profile. Previously, switching from a profile with `OPENAI_API_KEY=X` to a profile without that key left `X` in `os.environ` for the duration of the process — effectively leaking credentials across the profile boundary. A module-level `_loaded_profile_env_keys: set[str]` tracks loaded keys; it is cleared and repopulated on every `_reload_dotenv()` call.
|
||||
|
||||
Reference in New Issue
Block a user