## Summary
Fixes#1114 — LiteLLM 1.89.x added `async_post_call_success_hook` and
started calling it after every successful completion. `HeadroomCallback`
was a plain `object` subclass with no such method, causing:
```
AttributeError: type object 'HeadroomCallback' has no attribute 'async_post_call_success_hook'
```
This crashed the LiteLLM proxy on every successful API call.
### Root cause
```python
class HeadroomCallback: # plain object — no-op hooks not inherited
...
```
### Fix
Inherit from `litellm.integrations.custom_logger.CustomLogger` which
provides no-op defaults for every hook it defines. Future additions to
`CustomLogger` will be covered automatically.
```python
try:
from litellm.integrations.custom_logger import CustomLogger as _CustomLogger
except ImportError:
_CustomLogger = object # litellm not installed — graceful fallback
class HeadroomCallback(_CustomLogger):
...
def __init__(self, ...):
super().__init__()
...
```
## Type of Change
- [x] Bug fix (non-breaking change that fixes an issue)
## Changes Made
- `headroom/integrations/litellm_callback.py` — inherit `CustomLogger`;
add `super().__init__()`
- `tests/test_litellm_callback.py` — 7 tests: instantiation,
`async_post_call_success_hook` present + callable + no-op, all current
hooks present, pre-call hook still works
## Real behavior proof
**Setup:** Python 3.13, litellm 1.89.1, headroom-ai 0.27.0-dev
**Steps after patch:**
```bash
python3 -c "
from headroom.integrations.litellm_callback import HeadroomCallback
import asyncio
cb = HeadroomCallback()
# Simulate what litellm proxy calls on success
asyncio.run(cb.async_post_call_success_hook(data={}, user_api_key_dict={}, response=None))
print('OK — no AttributeError')
"
```
**After-fix evidence:** Runs without exception. Before fix:
`AttributeError: type object 'HeadroomCallback' has no attribute
'async_post_call_success_hook'`.
**What I did not test:** Live LiteLLM proxy with YAML config (no LiteLLM
proxy running in test env); tested via unit tests and direct Python
instantiation.
## Test Results
```
tests/test_litellm_callback.py 7/7 passed
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)