Skip to content

fix: inject SessionDB into AIAgent for WebUI sessions — enables session_search (closes #356) - #359

Merged
nesquena-hermes merged 2 commits into
masterfrom
pr-356-review
Apr 13, 2026
Merged

nesquena-hermes merged 2 commits into
masterfrom
pr-356-review

Conversation

@nesquena-hermes

Copy link
Copy Markdown
Collaborator

Summary

This merges PR #356 by @DelightRun, with added tests and CHANGELOG.

Problem

session_search always returned "Session database not available" in WebUI sessions. The CLI and gateway paths both inject a SessionDB instance into AIAgent.__init__(), but api/streaming.py was missing this step. AIAgent._invoke_tool() short-circuits when self._session_db is None.

Fix (original PR #356)

Two lines in api/streaming.py inside _run_agent_streaming:

  1. Initialize SessionDB() before creating the AIAgent instance, wrapped in try/except — init failures are non-fatal and log a WARNING
  2. Pass session_db=_session_db to the AIAgent() constructor

Added in this branch

  • tests/test_sprint42.py: 7 new tests covering SessionDB injection, try/except guard, WARNING log on failure, ordering (DB init before agent construction), and an AST check that the try/except is not inside _ENV_LOCK (the deadlock-risk pattern)
  • CHANGELOG.md: v0.50.13 entry; 822 tests total (up from 815)

Test results

  • 822/822 tests pass
  • Browser sanity check (port 8789): all 7 checks clean, zero JS errors

王昌旭 and others added 2 commits April 13, 2026 20:46
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.
…n_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)
@nesquena-hermes
nesquena-hermes merged commit 0440178 into master Apr 13, 2026
3 checks passed
@nesquena-hermes
nesquena-hermes deleted the pr-356-review branch April 13, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants