Distilling LLM Agent into Small Models with Retrieval and Code Tools