fix: inject SessionDB into AIAgent for WebUI sessions — enables session_search (closes #356) - #359
Merged
Merged
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This merges PR #356 by @DelightRun, with added tests and CHANGELOG.
Problem
session_searchalways returned "Session database not available" in WebUI sessions. The CLI and gateway paths both inject aSessionDBinstance intoAIAgent.__init__(), butapi/streaming.pywas missing this step.AIAgent._invoke_tool()short-circuits whenself._session_db is None.Fix (original PR #356)
Two lines in
api/streaming.pyinside_run_agent_streaming:SessionDB()before creating theAIAgentinstance, wrapped intry/except— init failures are non-fatal and log aWARNINGsession_db=_session_dbto theAIAgent()constructorAdded 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