feat(api): add Session runtime and provider readiness probes#214
Merged
Conversation
Make multi-turn agent loops first-class without re-creating a provider per call: - Session owns one provider instance across many interact()/stream()/ run_many() turns and closes it on exit; the one-shot helpers now delegate to a single-use Session so behavior stays identical. - ReadinessProvider protocol + ProviderReadiness let a provider expose a fast preflight. Session.check_ready() and the module-level check_ready() probe before packing context; the local provider implements it against /health and /v1/models (verifying the configured model when set). - local_reasoning() helper returns the scoped provider_options for local servers that honor enable_thinking.
ff4df6f to
d90c1a4
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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
Make multi-turn agent loops first-class without re-creating a provider per call.
Sessionowns one provider instance across manyinteract()/stream()/run_many()turns and closes it on exit. The one-shot module helpers now delegate to a single-useSession, so their behavior is unchanged.ReadinessProviderprotocol +ProviderReadinessresult let a provider expose a fast preflight.Session.check_ready()and the module-levelcheck_ready()probe before packing context. The local provider implements it against/healthand/v1/models, verifying the configured model when one is set.local_reasoning()helper returns the scopedprovider_optionsfor local servers that honorenable_thinking.Related issue
None
Test plan
just checkpasses (ruff format, ruff check, mypy, 443 tests). New tests:tests/interaction/test_interact_frontdoor.py:Sessionreuses and closes its provider; module-levelcheck_ready()uses the provider probe;local_reasoning()shape.tests/providers/test_local_contract.py: localcheck_readyhealth-endpoint path, models fallback, missing-model reporting, model-unset skip, and model-verification requirement.Notes
Third and final PR in the v2 RC stack. Stacked on #213 (which is on #212).
just checkpasses