feat(provider): allow scoped LLM provider injection (#243)#249
Open
rodboev wants to merge 1 commit into
Open
Conversation
rng1995
requested changes
Jul 9, 2026
rng1995
left a comment
Collaborator
There was a problem hiding this comment.
[Automated SkillSpector Review]
Requesting changes. Context-local provider dispatch is the right shape, but unusable bindings are reported as available, injected CLI providers take the wrong construction path, and model-limit caching can leak values across provider contexts. These make scoped injection unreliable and can produce dishonest LLM accounting.
Signed-off-by: Rod Boev <rod.boev@gmail.com>
295fdb8 to
f0f2f3e
Compare
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
Embedding applications can now bind a governed in-process LLM provider for the current scan context. That lets hosts reuse their existing completion API without exporting raw keys, invoking an agent CLI, or monkeypatching SkillSpector internals.
Closes #243
Root cause
Provider selection lived entirely behind
SKILLSPECTOR_PROVIDERand the built-in fallback chain. Every public helper routed through_select_active_provider(), but that selector had no scoped override for a provider object that the embedding application already owns.The first implementation also left three provider-context edges open: bound HTTP providers could be treated as available even when their native chat-model construction failed, bound CLI providers could be sent through the HTTP provider path, and model context length was cached only by label even though the same label can resolve differently under different providers.
Diff Notes
ContextVar-backed provider binding API inskillspector.providers.Scope
This does not add a new provider family, credential store, CLI transport, or graph-level policy. The hook stays in the provider adapter layer, and MCP scan accounting only observes whether a provider is bound for the current context.
Attribution
The upstream issue proposed the
ContextVarbinding shape; this PR implements that design in the existing provider selector.Verification
pytest tests/unit/test_llm_utils.py tests/unit/test_mcp_server.py tests/unit/test_model_info.py tests/unit/test_providers.py- passruff check src/ tests/ruff format --check src/ tests/24 rows, state domains checkedLint & Test (Python 3.12),Lint & Test (Python 3.13), andDCO Check- pending maintainer approval and rerun after push