Learning API Functionality from In-Context Demonstrations for Tool-based Agents