feat: Refactor existing LLM resolution into provider adapters#55
feat: Refactor existing LLM resolution into provider adapters#55andrejvysny wants to merge 14 commits intohuggingface:mainfrom
Conversation
064c99b to
267618d
Compare
Resolve conflicts by taking upstream for llm_params.py (will be rewritten as thin adapter dispatcher) and main.py (model_switcher extraction supersedes our changes). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Split NativeAdapter into AnthropicAdapter (thinking config + output_config.effort) and OpenAIAdapter (reasoning_effort top-level). Each adapter owns its accepted effort set and raises UnsupportedEffortError in strict mode, preserving the effort_probe cascade with zero changes to effort_probe.py or agent_loop.py. llm_params.py becomes a thin dispatcher delegating to resolve_adapter().build_params() while keeping the litellm effort-validation patch and re-exporting UnsupportedEffortError. model_switcher.py reads suggested models from the adapter registry instead of maintaining a separate SUGGESTED_MODELS list. backend/routes/agent.py replaces AVAILABLE_MODELS with build_model_catalog(). OpenCodeGoAdapter deferred to PR huggingface#60. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restore the existing web model behavior so PR huggingface#55 stays a behavior-preserving refactor while keeping shared runtime and CLI validation logic.
|
Pushed a4a7532. Narrowed the PR back to adapter extraction + validation reuse only, restored existing web behavior, and reran the full Python test suite (.......................... [100%] |
Classify auth, credits, and missing-model failures once so the CLI, model switcher, and health checks show clean user-facing errors instead of raw provider traces.
# Conflicts: # agent/core/llm_params.py
|
@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 3m 6s —— View job PR Review: feat/provider-adapters
Verdict: SAFE TO MERGE — clean refactor, no regressions found, good test coverage. A few nits and one minor misclassification edge case worth knowing before shipping. Correctness
Rate-limit errors that mention quota (e.g. Removed institutional knowledge from The old
SecurityTraceback no longer sent to users (
LiteLLM / Bedrock RoutingBedrock routing is preserved exactly —
Minor Nits
SummaryRefactor is solid. The adapter extraction is clean, Bedrock routing is improved, and the shift from raw tracebacks to structured error messages is a meaningful UX and security improvement. The one functional issue worth fixing before merge is the |
Summary
/model, session errors, and/health/llmshow clean auth/quota/model-not-found messages instead of raw provider tracesVerification
uv run --with pytest --with pytest-asyncio pytest -quv run ml-intern "Say Hello!" --model "MiniMaxAI/MiniMax-M2.7"ANTHROPIC_API_KEY= uv run ml-intern "Say Hello!" --model "anthropic/claude-opus-4-6"OPENAI_API_KEY= uv run ml-intern "Say Hello!" --model "openai/gpt-5"uv run ml-intern "Say Hello!" --model "fake-org/not-a-real-model-12345"