fix: removeBody raising an error with undefined agent

Not to pass `i` of deleted agent to `detachFrom`.