Add local OpenAI-compatible backend routing#68
Add local OpenAI-compatible backend routing#68Pro777 wants to merge 1 commit intohuggingface:mainfrom
Conversation
Verdict: NEEDS-CHANGES · Risk: MED (potential SSRF) · State: Mergeable
|
|
@claude please review this PR. Focus on correctness, security, LiteLLM/Bedrock routing impact, and whether it's safe to merge against current main. Keep it concise and prefer inline comments where it matters. |
|
Claude finished @akseljoonas's task in 1m 42s —— View job PR #68 Review: Add local OpenAI-compatible backend routingTasks
Verdict: Conditionally safe to mergeThe core logic is correct and additive — no existing routing paths are touched. Two items need resolution before merge: overlap with #60, and a CorrectnessRouting logic ( Effort handling — correct.
Issues[Blocking] Overlap with #60 — #60 also adds [Medium]
# model_switcher.py — instead of a hardcoded tuple:
from agent.core.llm_params import _OPENAI_COMPAT_PROVIDERS
_DIRECT_PREFIXES = ("anthropic/", "openai/", *_OPENAI_COMPAT_PROVIDERS)[Low] No URL validation on
Test gapsThe existing tests only exercise the happy path. These cases are uncovered:
The 5 passing tests are a reasonable baseline for a first merge, but the strict-mode path in particular is exercised only through integration and should have a unit test. Fix this → LiteLLM / Bedrock routing impactNo impact on Bedrock. The PR adds no LiteLLM routing — clean integration. Merge safety summary
The implementation is solid and intentionally scoped. Resolve the #60 conflict, fix the |
Summary
Implements the narrow local-backend slice of
#67without pulling in the larger provider-registry work from#55/#60.This PR adds direct routing for these OpenAI-compatible prefixes:
ollama/<model>lm_studio/<model>vllm/<model>openai-compat/<model>Each prefix resolves to a configurable
api_base+ API key env var while keeping the existing Hugging Face Router fallback path unchanged.Why this shape
#67asks for an escape hatch to local OpenAI-compatible backends. There is already broader work in#55/#60around provider registries and additional hosted providers.This PR intentionally stays smaller:
It only teaches the current resolver and CLI validation layer about local/OpenAI-compatible prefixes.
New prefixes
ollama/->OLLAMA_BASE_URL(defaulthttp://localhost:11434/v1)lm_studio/->LMSTUDIO_BASE_URL(defaulthttp://127.0.0.1:1234/v1)vllm/->VLLM_BASE_URL(defaulthttp://127.0.0.1:8000/v1)openai-compat/->OPENAI_COMPAT_BASE_URL(defaulthttp://127.0.0.1:8000/v1)The local prefixes set sensible default API keys for backends that typically ignore auth (
ollama,lm-studio,EMPTY) while still allowing override via env.Tests
Ran:
Result:
5 passedThe new tests cover:
/modelvalidation for the new local prefixesCloses #67.