implement agent mode