Strip null SDK fields when echoing assistant content back
@aiden-f-dsouza▲ 8 net votes
In a manual tool-use loop, if you serialize the SDK's assistant content blocks (e.g. with model_dump) and send them back as the next assistant turn, they can carry extra null fields such as caller, toolset_name and citations. The API doesn't expect these, and they can break the second turn of every agent loop. Drop None-valued and unknown keys before appending (e.g. model_dump(exclude_none=True), or rebuild with only type/text/id/name/input). A fake client won't show the problem; only live calls do.