Fix 4 runtime bugs: crash, streaming None, discarded replace, memory leak#258
Open
sanjibani wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
Open
Fix 4 runtime bugs: crash, streaming None, discarded replace, memory leak#258sanjibani wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
sanjibani wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
Conversation
…ace, memory leak Fixes The-OpenROAD-Project#243 - Fix UnboundLocalError in rag_agent fallback path by initializing tool_calls before the if/else block. Also replace list mutation during iteration with a filter pattern. - Fix streaming endpoint yielding literal "None" to clients by moving yield inside the `if msg:` guard. - Fix discarded str.replace() result so tool descriptions are actually cleaned before being sent to the LLM. - Fix unbounded in-memory chat_history growth by using OrderedDict with a cap of 1000 conversations, evicting oldest on overflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Fixes #243 — four bugs, two of which cause runtime crashes or corrupt client output.
UnboundLocalErrorinretriever_rag.py—tool_callsreferenced before assignment when LLM response lackstool_names. Also fixes list mutation during iteration (.remove()while looping)."None\n\n"to clients whenmessage_contentis not anAIMessageChunk. Movedyieldinside theif msg:guard.str.replace()result discarded inrag_initialize()— tool descriptions sent to LLM were never actually cleaned.chat_historydict grows unboundedly when DB is disabled. Replaced withOrderedDictcapped at 1000 entries, evicting oldest on overflow.Test plan
pytest -m unit)USE_DB=falsefor 1000+ conversations — oldest should be evicted🤖 Generated with Claude Code