fix(provider): honor ANTHROPIC_BASE_URL in native Anthropic provider#197
Open
rodboev wants to merge 3 commits into
Open
fix(provider): honor ANTHROPIC_BASE_URL in native Anthropic provider#197rodboev wants to merge 3 commits into
rodboev wants to merge 3 commits into
Conversation
Signed-off-by: Rod Boev <rod.boev@gmail.com>
…ide env Signed-off-by: Rod Boev <rod.boev@gmail.com>
…rride 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
The native
anthropicprovider ignoresANTHROPIC_BASE_URL, so local proxy or gateway setups still hard-routeChatAnthropictohttps://api.anthropic.comeven whenSKILLSPECTOR_PROVIDER=anthropicandANTHROPIC_API_KEYare set. This change makes the native provider honor an optionalANTHROPIC_BASE_URL, while keeping the default endpoint unchanged when the override is unset.Closes #195
Root cause
src/skillspector/providers/anthropic/provider.py:50-55currently resolves onlyANTHROPIC_API_KEYand returns(api_key, None), andsrc/skillspector/providers/anthropic/provider.py:69-76then instantiatesChatAnthropicwith the module constantANTHROPIC_BASE_URLevery time. The surrounding provider flow already supports(api_key, base_url)tuples, as shown bysrc/skillspector/providers/openai/provider.py:52-58,src/skillspector/providers/__init__.py:56-67,95-101, andsrc/skillspector/llm_utils.py:47-59,88-99.Diff Notes
src/skillspector/providers/anthropic/provider.pyANTHROPIC_BASE_URLalongsideANTHROPIC_API_KEY.ChatAnthropic, while preservinghttps://api.anthropic.comas the unset default.tests/unit/test_providers.pyANTHROPIC_BASE_URLin the autouse provider fixture so default-endpoint assertions stay environment-independent.tests/unit/test_llm_utils.pytests/provider/test_provider_endpoint.pyANTHROPIC_BASE_URLbefore the live default-endpoint assertion so the native provider test stays pinned to Anthropic's default URL.README.mdANTHROPIC_BASE_URLfor the nativeanthropicprovider in the provider matrix and env-var reference.Scope
anthropiconly. Noanthropic_proxychanges.ANTHROPIC_API_KEYremains the credential env var for the native provider.https://api.anthropic.comremains the behavior whenANTHROPIC_BASE_URLis unset.Verification
python -m pytest tests/unit/test_providers.py tests/unit/test_llm_utils.py- passed,55 passed, 9 skipped.python -m pytest tests/unit/test_providers.py tests/unit/test_llm_utils.pywith ambientANTHROPIC_BASE_URL=http://ambient.example/v1- passed,55 passed, 9 skipped, confirming the new test-isolation fixes.uv run ruff check src/ tests/- passed.uv run ruff format --check src/ tests/- still reports pre-existing out-of-scope files:src/skillspector/nodes/analyzers/static_runner.py,tests/nodes/analyzers/test_binary_and_pe3_filtering.py,tests/nodes/analyzers/test_mp2_regex_backtracking.py, andtests/nodes/test_llm_analyzer_base.py.python -m pytest tests/provider/test_provider_endpoint.pycurrently deselects under the repo's provider marker setup in this environment, so it was not needed for this branch's proof.Lint & Test (Python 3.12),Lint & Test (Python 3.13), andDCO Check- pending.Notes
anthropic_proxyis a separate provider surface, so this fix stays inside the nativeanthropicpath.python -m pytest -m "not integration and not provider" tests/, with 989 passed, 2 failed, 12 skipped, 26 deselected, and 6 xfailed in 6.60s. The existing failures weretests/nodes/test_meta_analyzer.py::test_rejected_finding_still_droppedandtests/nodes/test_meta_analyzer.py::test_low_confidence_finding_dropped.ANTHROPIC_BASE_URL, and the unit-test autouse provider fixture clears that env var before default-endpoint assertions run.