An idea to start could be something along the lines of an agent given tasks incrementally, where the agent would be required to extend/generalize a piece of functionality. A possible reward could then be the amount of code the agent had to add/remove to complete the task.