I found one gap in the patch:
agent_start returns an error when the new main agent is blocked during startup, and that path returns before saving its terminal ID. Once unblocked, the daemon could mistake it for a legacy agent and recover it unnecessarily. I’ll preserve the ID from agent_get on that blocked path.commit a7e0934