feat(provider): allow scoped LLM provider injection (#243)#249
Open
rodboev wants to merge 1 commit into
Open
Conversation
Signed-off-by: Rod Boev <rod.boev@gmail.com>
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.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
.\.venv\Scripts\python.exe -m pytest tests/unit/test_providers.py -k "injected_provider".\.venv\Scripts\python.exe -m pytest tests/unit/test_providers.py -k "provider_token".\.venv\Scripts\python.exe -m pytest tests/unit/test_providers.py -k "injected_provider or provider_token".\.venv\Scripts\python.exe -m pytest tests/unit/test_llm_utils.py -k "injected_provider or llm_available or GetChatModel".\.venv\Scripts\python.exe -m pytest tests/unit/test_mcp_server.py -k "bound_provider or llm_available".\.venv\Scripts\python.exe -m pytest tests/unit/test_llm_utils.py tests/unit/test_mcp_server.py -k "injected_provider or bound_provider".\.venv\Scripts\python.exe -m pytest tests/unit/test_llm_utils.py -k "does_not_fall_back".\.venv\Scripts\python.exe -m pytest tests/unit/test_providers.py tests/unit/test_llm_utils.py tests/unit/test_mcp_server.py tests/nodes/test_build_context.pyuv run ruff check src/ tests/uv run ruff format --check src/ tests/