Skip to content

Fix async provider reuse to prevent httpx loop-closed warnings#81

Merged
DeveshParagiri merged 2 commits intomainfrom
codex/issue-71-httpx-event-loop-closed
Feb 17, 2026
Merged

Fix async provider reuse to prevent httpx loop-closed warnings#81
DeveshParagiri merged 2 commits intomainfrom
codex/issue-71-httpx-event-loop-closed

Conversation

@RandomOscillations
Copy link
Copy Markdown
Collaborator

Summary

  • route async simulation calls through cached simulation providers instead of creating a fresh provider instance per request
  • allow get_simulation_provider to accept an optional model string so both Pass-1 and Pass-2 providers are cached/reused by provider
  • add regression tests to ensure async calls use simulation cache (default and explicit model), while sync simple_call keeps existing provider-factory behavior

Why

Async simulation calls were bypassing provider cache and creating transient async SDK/httpx clients repeatedly. Those clients could be finalized during loop teardown and trigger Event loop is closed warnings.

Testing

  • pytest tests/test_llm.py tests/test_providers.py -q
  • pytest tests/test_engine.py tests/test_simulation.py tests/test_conversations.py -q

Closes #71

@DeveshParagiri DeveshParagiri merged commit 3f21580 into main Feb 17, 2026
4 of 5 checks passed
@DeveshParagiri DeveshParagiri deleted the codex/issue-71-httpx-event-loop-closed branch February 17, 2026 02:54
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.

Fix httpx 'Event loop is closed' warnings during async cleanup

2 participants