@dnkl the protocol actually has a way to set $DISPLAY without needing a command arg. In fact, there are two different ways to set various variables.
Also there is a handy error code to indicate your implementation doesn't support some feature. But don't think about using it, because gpg-agent will just abort. Instead always say OK and silently drop it.
gpg is the best argument against hand-rolling IPC.