Skip to content

Conversation

Copy link

Copilot AI commented Feb 8, 2026

Targeted fixes for three code quality issues found during repo review.

Resource leak in openai_audio_models.py

File handles from open() were never closed in speech_to_text(). Both the chunked and non-chunked paths leaked descriptors.

# Before
audio_data = open(chunk_path, "rb")

# After
with open(chunk_path, "rb") as audio_data:

print() instead of logging in hermes_function_formatter.py

Parse failure warnings used print(), bypassing the logging framework. Replaced with logger.warning().

O(n²) string concatenation in search_agent.py

results += result + "\n" in a loop replaced with list append + "\n".join().

Tests

  • test_hermes_function_formatter.py — validates warnings go through logger, not stdout
  • test_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.

…n in loop

- Fix file handle resource leak in openai_audio_models.py: use context
  managers (with statement) for open() calls at lines 245 and 262
- Replace print() with logger.warning() in hermes_function_formatter.py
  for proper logging of parse failures
- Fix string concatenation in loop in search_agent.py: use list append
  and join pattern for better performance
- Add tests for hermes formatter logging and audio model resource handling

Co-authored-by: lightaime <[email protected]>
Copilot AI changed the title [WIP] Review repo and create issues for suggested fixes and refactoring Fix resource leak, replace print with logger, fix O(n²) string concat Feb 8, 2026
Copilot AI requested a review from lightaime February 8, 2026 02:14
@lightaime lightaime marked this pull request as ready for review February 8, 2026 02:20
Copy link
Collaborator

@waleedalzarooni waleedalzarooni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment, nothing major

)
final_prompt = final_prompt.format(query=query)
prompt = final_prompt + results
prompt = final_prompt + "\n".join(results)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prompt = final_prompt + "\n".join(results)
prompt = final_prompt + "\n".join(results) + "\n"

This preserves the original behaviour

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.

3 participants