connect.c: refactor sending of agent & object-format