agent Edit function