{"record":{"id":"ed9e0c7fa9a6c230","repo":"VectifyAI/PageIndex","slug":"messages-requires-anthropic-0-108-0-the-tool-r","errorCode":null,"errorMessage":"messages requires anthropic >= 0.108.0 (the tool runner with ToolError) — pip install -U anthropic.","messagePattern":"messages requires anthropic >= 0\\.108\\.0 \\(the tool runner with ToolError\\) — pip install -U anthropic\\.","errorType":"exception","errorClass":"PageIndexAPIError","httpStatus":null,"severity":"error","filePath":"pageindex/local_chat.py","lineNumber":880,"sourceCode":"    return _stream_sync(agen)\n\n\n# ── Anthropic engine (messages) ──\n\ndef _require_anthropic() -> None:\n    try:\n        import anthropic  # noqa: F401\n    except ImportError as exc:\n        raise PageIndexAPIError(\n            \"messages drives your own chat model and requires the \"\n            \"Anthropic SDK — \"\n            \"pip install anthropic (or pip install 'pageindex[anthropic]').\"\n        ) from exc\n    try:\n        from anthropic import beta_tool  # noqa: F401\n        from anthropic.lib.tools import ToolError  # noqa: F401\n    except ImportError as exc:\n        raise PageIndexAPIError(\n            \"messages requires anthropic >= 0.108.0 (the tool \"\n            \"runner with ToolError) — pip install -U anthropic.\"\n        ) from exc\n\n\n_ANTHROPIC_CLIENTS: dict = {}  # backend key -> client, kept open for reuse\n\n\ndef _anthropic_client(backend=None):\n    \"\"\"The backend client — the seam tests replace with a fake transport.\n    One client per backend: each construction pays ~45 ms of SSL-context\n    build and a cold connection pool. A backend whose values defeat\n    hashing constructs per call, as before.\"\"\"\n    import anthropic\n    kwargs = _sdk_backend(backend)\n    try:\n        key = tuple(sorted(\n            (k, tuple(sorted(v.items())) if isinstance(v, dict) else v)","sourceCodeStart":862,"sourceCodeEnd":898,"githubUrl":"https://github.com/VectifyAI/PageIndex/blob/afb5e119766630af6014b04fe8b53357527bc05e/pageindex/local_chat.py#L862-L898","documentation":"pageindex's messages engine reads the conversation back through anthropic's beta_tool runner and its ToolError class, which only exist in anthropic >= 0.108.0. After confirming the SDK is importable, _require_anthropic() checks for these symbols and rejects older releases. An outdated SDK would otherwise silently lose tool turns.","triggerScenarios":"Calling client.messages(...) with an installed anthropic version older than 0.108.0, where `from anthropic import beta_tool` or `from anthropic.lib.tools import ToolError` raises ImportError.","commonSituations":"A requirements.txt pinned to an old anthropic version; a long-lived virtualenv upgraded for pageindex but not the SDK; a platform (Heroku, Lambda layer) shipping a stale anthropic build.","solutions":["pip install -U anthropic to get >= 0.108.0","Pin a floor in your dependency file: anthropic>=0.108.0","Confirm the version: python -c \"import anthropic; print(anthropic.__version__)\""],"exampleFix":"# before\n# requirements.txt\nanthropic==0.95.0\n# after\nanthropic>=0.108.0","handlingStrategy":"validation","validationCode":"import anthropic\nfrom packaging.version import Version\nassert Version(anthropic.__version__) >= Version(\"0.108.0\"), \"upgrade: pip install -U anthropic\"","typeGuard":null,"tryCatchPattern":"try:\n    client.messages(\"hi\")\nexcept PageIndexAPIError as e:\n    if \"anthropic >= 0.108.0\" in str(e):\n        subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"-U\", \"anthropic\"])\n    raise","preventionTips":["Pin anthropic>=0.108.0 in requirements.txt","Run a startup dependency check in long-lived services"],"tags":["anthropic","version","sdk","upgrade"],"backgroundTag":"sdk-version-incompatible","analyzedSha":"afb5e119766630af6014b04fe8b53357527bc05e","analyzedAt":"2026-08-27T11:20:48.519Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}