rewrite agentsvr