{"record":{"id":"5ed9159527d1fc61","repo":"BerriAI/litellm","slug":"context-management-polyfill-failed-e","errorCode":null,"errorMessage":"context_management polyfill failed: {e}","messagePattern":"context_management polyfill failed: (.+?)","errorType":"http","errorClass":"AnthropicContextManagementError","httpStatus":500,"severity":"error","filePath":"litellm/llms/anthropic/experimental_pass_through/adapters/handler.py","lineNumber":305,"sourceCode":"        )\n    except AnthropicContextManagementError:\n        # Surface validation errors so the endpoint can emit an Anthropic-format\n        # 400. Other exception types fall into the best-effort branch below.\n        raise\n    except Exception as e:\n        verbose_logger.exception(\"context_management polyfill: skipping edits due to error: %s\", e)\n        # Best-effort swallow is only safe for compact-only specs, where the\n        # caller's compaction-block-slicing safety net produces a correct\n        # (if degraded) result. When the spec also requested non-compact\n        # edits (e.g. ``clear_tool_uses_20250919``), the safety net does\n        # NOT re-run those editors, so silently returning ``None`` would\n        # drop them with no error surface. Raise instead so the endpoint\n        # emits an Anthropic-format error.\n        if _spec_has_non_compact_edits(\n            context_management_spec=context_management_spec,\n            additional_drop_params=additional_drop_params,\n        ):\n            raise AnthropicContextManagementError(\n                status_code=500,\n                message=f\"context_management polyfill failed: {e}\",\n            ) from e\n        return None\n\n\n########################################################\n# init adapter\nANTHROPIC_ADAPTER: Final = AnthropicAdapter()\n########################################################\n\n\nclass LiteLLMMessagesToCompletionTransformationHandler:\n    @staticmethod\n    def _route_openai_thinking_to_responses_api_if_needed(\n        completion_kwargs: _CompletionKwargs,\n        *,\n        thinking: Mapping[str, object] | None,","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py#L287-L323","documentation":"Error \"context_management polyfill failed: {e}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/anthropic/experimental_pass_through/adapters/handler.py:305 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the context_management configuration; see the wrapped exception."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}