#34471 [Bug]: safe_deep_copy and safe_dumps crash with 'dictionary changed size during iteration' under concurrent mutation
### Check for existing issues
- [x] I have searched the existing issues and checked that my issue is not a duplicate.
### What happened?
Under concurrent load, `safe_deep_copy` (`litellm/litellm_core_utils/core_helpers.py`) and `safe_dumps` (`litellm/litellm_core_utils/safe_json_dumps.py`) both crash with:
``` RuntimeError: dictionary changed size during iteration ```
Both helpers iterate a live dict's `.items()` directly:
- `core_helpers.py` — `safe_deep_copy`, the per-key deepcopy loop: `for k, v in data.items():` - `safe_json_dumps.py` — `_serialize`, the dict branch: `for k, v in obj.items():`
These run on the request-data logging / spend-tracking path. An async hook or logging callback that inserts a key into the same top-level dict while the loop is running invalidates the iterator and raises, failing the request (intermittent 500s under load).
**Expected:** deep-copy / JSON-serialization of request data should tolerate a concurrent top-level insert and not crash.
### Steps to Reproduce
1. Call `safe_deep_copy(data)` (or `safe_dumps(data)`) where a value's `__deepcopy__`/`__str__` (standing in for a concurrent hook) inserts a new key into `data` during iteration. 2.…