HKUDS/Vibe-Trading · error · RuntimeError
Anthropic provider requires langchain-anthropic. Install the
Error message
Anthropic provider requires langchain-anthropic. Install the optional extra: pip install "vibe-trading-ai[anthropic]" (or pip install langchain-anthropic).
What it means
build_llm was configured to use the Anthropic provider, but the langchain_anthropic package cannot be imported. The library wraps the ImportError with an install hint pointing at the optional extra vibe-trading-ai[anthropic].
Source
Thrown at agent/src/providers/llm.py:1075
temperature: float,
callbacks: Any = None,
effort: str = "",
) -> Any:
"""Build the native Anthropic Messages API adapter.
Uses a temperature-safe subclass so models that deprecate the `temperature`
field (e.g. claude-opus-5 / claude-sonnet-5) work transparently while models
that still accept it keep the configured deterministic value.
`effort` is the configured LANGCHAIN_REASONING_EFFORT, forwarded only to
models that accept it (see `_anthropic_supports_effort`); an empty string
means unset.
"""
try:
module = import_module("langchain_anthropic")
chat_anthropic = getattr(module, "ChatAnthropic")
except Exception as exc: # noqa: BLE001 - dependency error with install hint
raise RuntimeError(
"Anthropic provider requires langchain-anthropic. Install the optional "
'extra: pip install "vibe-trading-ai[anthropic]" (or pip install langchain-anthropic).'
) from exc
safe_anthropic = _make_temperature_safe_anthropic(chat_anthropic)
use_effort = (
bool(effort)
and _anthropic_supports_effort(model)
and _adapter_accepts_effort(chat_anthropic)
)
# Effort makes langchain-anthropic enable adaptive thinking, and the API
# then rejects any temperature other than 1:
# `temperature` may only be set to 1 when thinking is enabled or in
# adaptive mode
# The platform's default is 0.0, so temperature is omitted entirely
# whenever effort is in play. The temperature-safe wrapper above does not
# cover this: it handles models that reject `temperature` outright, not
# this thinking-conditional variant.View on GitHub (pinned to 80ffdda44c)
Solutions
- Install the extra: pip install "vibe-trading-ai[anthropic]"
- Or install directly: pip install langchain-anthropic
- Verify import works: python -c "import langchain_anthropic"; if it fails, fix the underlying ImportError shown in the chain
Example fix
# before pip install vibe-trading-ai # after pip install "vibe-trading-ai[anthropic]"
Defensive patterns
Strategy: validation
Validate before calling
try:
import langchain_anthropic # noqa: F401
except ImportError:
raise SystemExit('Install first: pip install "vibe-trading-ai[anthropic]"') Try / catch
try:
llm = build_llm()
except RuntimeError as e:
if 'langchain-anthropic' in str(e):
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'langchain-anthropic'])
llm = build_llm() Prevention
- Declare extras in requirements/lockfile per provider you enable
- Add a startup dependency check that imports each provider package
When it happens
Trigger: Setting LANGCHAIN_PROVIDER=anthropic (or an Anthropic model name) without having installed langchain-anthropic; a broken/partial install where the package exists but raises on import (missing transitive deps).
Common situations: Fresh environments where only core dependencies were installed; upgrading broke a transitive dependency; running in a slim Docker image or CI cache that skipped extras.
Understand the failure class
Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.
Related errors
- langchain-openai is not installed
- VIBE_TRADING_DEEPSEEK_ADAPTER=native requires langchain-deep
- oauth-cli-kit is not installed. Run: pip install oauth-cli-k
- OpenAI Codex OAuth requires httpx. Install dependencies firs
- {source} produces a non-ASCII HTTP header ({name!r}). Use an
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/429ece1fbe18afe0.
Report an issue: GitHub.