agent: code cleanup