Fix resource leak, replace print with logger, fix O(n²) string concat #3803
+181
−28
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.
Targeted fixes for three code quality issues found during repo review.
Resource leak in
openai_audio_models.pyFile handles from
open()were never closed inspeech_to_text(). Both the chunked and non-chunked paths leaked descriptors.print()instead of logging inhermes_function_formatter.pyParse failure warnings used
print(), bypassing the logging framework. Replaced withlogger.warning().O(n²) string concatenation in
search_agent.pyresults += result + "\n"in a loop replaced with list append +"\n".join().Tests
test_hermes_function_formatter.py— validates warnings go through logger, not stdouttest_openai_audio_resource_leak.py— validates file handle lifecycle with mocked OpenAI client💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.