litellm: capture & re-apply LiteLLM distro source patches; sync custom_callbacks.py
LiteLLM is pip-installed, but we depend on edits to its installed source files. Those are wiped on every install/upgrade, so this vendors them and re-applies them from the role after the pip step.
- files/distro-patches/: 4 unified patches (pinned to litellm 1.89.2) + full/ reference
copies + README explaining each:
- proxy/anthropic_endpoints/endpoints.py — honour failure-hook rewrite on /v1/messages (enables the Claude Agent SDK context-window self-heal via custom_callbacks.py)
- proxy/proxy_server.py — inject global success/failure_callback before schedule_acompletion
- litellm_core_utils/litellm_logging.py — return ResponsesAPIResponse directly (chat_template_kwargs)
- litellm_core_utils/streaming_handler.py — whitespace-only, captured for byte-exact match
- tasks/apply-distro-patches.yml: idempotent apply (skip if already present, fail loudly on version drift), imported after the pip install task.
- files/custom_callbacks.py: synced to the live host version — adds the context-window error rewrite (x-agent-context-error: anthropic gate) and the langfuse trace-linking header fix that had drifted out of the repo.
- README: documents the distro-patch mechanism.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com