Dynamic Task Assignment in a Team of Agents