fix(provider): honor ANTHROPIC_BASE_URL in native Anthropic provider#197
fix(provider): honor ANTHROPIC_BASE_URL in native Anthropic provider#197rodboev wants to merge 4 commits into
Conversation
Signed-off-by: Rod Boev <[email protected]>
…ide env Signed-off-by: Rod Boev <[email protected]>
…rride Signed-off-by: Rod Boev <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Approving — adds optional ANTHROPIC_BASE_URL support, mirroring the existing OPENAI_BASE_URL override. resolve_credentials() now returns (api_key, base_url) and create_chat_model falls back to the default constant when unset. Same operator-controlled trust model as the OpenAI path, so no new exposure. Tests cover default vs. override base URL, the credential waterfall, and the live test correctly delenvs ANTHROPIC_BASE_URL so it still targets the real endpoint.
rng1995
left a comment
There was a problem hiding this comment.
[Automated SkillSpector Review]
Re-review: approved. The only commit after the prior approval is formatting-only normalization of static_runner.py and three tests. The approved ANTHROPIC_BASE_URL behavior is unchanged; focused provider/unit tests and ruff checks pass.
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.