cache gateway lookup and async checkpoint I/O#86
Merged
cchinchilla-dev merged 3 commits intomainfrom Apr 3, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR improves runtime performance and async responsiveness by (1) caching provider candidate resolution in ProviderGateway and (2) moving checkpoint file I/O off the event loop via anyio.to_thread.run_sync.
Changes:
- Cache
_get_candidates()results per model inProviderGateway, invalidating the cache onregister(). - Wrap checkpoint read/write operations in
StateManager.save_checkpoint()/StateManager.from_checkpoint()withanyio.to_thread.run_sync. - Update state checkpoint tests to await the now-async
StateManager.from_checkpoint().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/agentloom/providers/gateway.py |
Adds per-model candidate caching to avoid rebuilding fallback/provider lists on every request. |
src/agentloom/core/state.py |
Offloads checkpoint JSON read/write to a worker thread; makes from_checkpoint async. |
tests/core/test_state.py |
Updates checkpoint restore tests to await from_checkpoint. |
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
ProviderGateway._get_candidates()to avoid rebuilding the fallback list on everycomplete()/stream()call; cache invalidates onregister()save_checkpointandfrom_checkpointblocking I/O withanyio.to_thread.run_syncso disk operations don't block the event loop during concurrent step executionTest plan
uv run pytest— 690 pass, 7 e2e deselecteduv run mypy src/— no issuesuv run ruff check src/ tests/— all checks passedCloses #9
Closes #14