SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.17612 · NeurIPS · 2025

Distilling LLM Agent into Small Models with Retrieval and Code Tools

Sung Hwang, Kaist, Seanie Lee, Minki Kang, - Madison, Deepauto Ai, Krafton, Jaewoong Cho, Jongwon Jeong

arXiv · PDF · Open in the Atlas

Code that ran

6 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 2 failures of our instrument; 4 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2505.17612.json · badge: /api/ran/2505.17612.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
Nardien/agent-distillation canonical (classifier label)
classifier basis not recorded on the link
6 ran · 4 no recorded run
FunctionStatusWhere it lives
calculate_cost Ran
ran on a synthesized input
Nardien/agent-distillation/exps_research/unified_framework/score_answers.py
code served (permissive licence) · get_code("e258c84c64bc8827")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function calculate_cost takes two integer parameters:
# - input_tokens: number of input tokens
# - output_tokens: number of output tokens
# Both are used in simple arithmetic operations (division and multiplication)

ARGS = {
    "input_tokens": 1000000,
    "output_tokens": 500000,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_imports Ran
ran on a synthesized input
Nardien/agent-distillation/src/smolagents/_function_type_hints_utils.py
code served (permissive licence) · get_code("d95514b00dccdcc3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re
from typing import List

def get_imports(code: str) -> List[str]:
    """
    Extracts all the libraries (not relative imports) that are imported in a code.

    Args:
        code (`str`): Code text to inspect.

    Returns:
        `list[str]`: List of all packages required to use the input code.
    """
    code = re.sub('\\s*try\\s*:.*?except.*?:', '', code, flags=re.DOTALL)
    code = re.sub('if is_flash_attn[a-zA-Z0-9_]+available\\(\\):\\s*(from flash_attn\\s*.*\\s*)+', '', code, flags=re.MULTILINE)
    imports = re.findall('^\\s*import\\s+(\\S+?)(?:\\s+as\\s+\\S+)?\\s*$', code, flags=re.MULTILINE)
    imports += re.findall('^\\s*from\\s+(\\S+)\\s+import', code, flags=re.MULTILINE)
    imports = [imp.split('.')[0] for imp in imports if not imp.startswith('.')]
    return list(set(imports))


# Setup code to construct valid arguments
test_code_1 = """
import torch
import numpy as np
from typing import List
from transformers import AutoTokenizer
"""

test_code_2 = """
try:
    import custom_lib
except ImportError:
    pass
from sklearn.metrics import accuracy_score
import pandas as pd
"""

test_code_3 = """
if is_flash_attn_available():
    from flash_attn import flash_attn_func
import os
from .relative_import import something
import json as j
"""

ARGS = {
    "code": test_code_1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_api_key Ran
ran on a synthesized input
Nardien/agent-distillation/exps_research/unified_framework/models.py
code served (permissive licence) · get_code("275569501ce6d570")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
import os

# Create a temporary directory and a mock key file
temp_dir = tempfile.mkdtemp()
key_path = os.path.join(temp_dir, "key.env")

# Write a mock API key to the temporary file
with open(key_path, 'w') as f:
    f.write("sk-test-1234567890abcdefghijklmnop\n")

ARGS = {
    'key_path': key_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_docs Ran
ran; our contract draft was wrong, not the code
Nardien/agent-distillation/search/retriever_server.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from tengxiao1/MR-Search, is pointer only (licence: NONE) · get_code("38fb2b7a0a23bbe3")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from tengxiao1/MR-Search, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

open_jsonl Ran
ran on a synthesized input
Nardien/agent-distillation/exps_research/build_prefix_memory.py
code served (permissive licence) · get_code("4c5bbbd23a0145f0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
import os

# Create a temporary JSONL file with sample data
temp_dir = tempfile.gettempdir()
datapath = os.path.join(temp_dir, "test_data.jsonl")

# Write sample JSONL data
with open(datapath, 'w') as f:
    f.write(json.dumps({"id": 1, "text": "hello"}) + "\n")
    f.write(json.dumps({"id": 2, "text": "world"}) + "\n")
    f.write(json.dumps({"id": 3, "text": "test"}) + "\n")

ARGS = {
    "datapath": datapath
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
read_jsonl Ran
ran; our contract draft was wrong, not the code
Nardien/agent-distillation/search/retriever_server.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from iSEngLab/LLM4UT_Empirical, is pointer only (licence: NONE) · get_code("02171abe8492fcfd")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from iSEngLab/LLM4UT_Empirical, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_json_schema Not yet run
unverified (harvested, no recorded run)
Nardien/agent-distillation/src/smolagents/_function_type_hints_utils.py
code served (permissive licence) · get_code("7a727ab9fd21129f")
How it ran

no invocation recorded.

handle_agent_output_types Not yet run
unverified (harvested, no recorded run)
Nardien/agent-distillation/src/smolagents/agent_types.py
code served (permissive licence) · get_code("b0a2cc8694b513e0")
How it ran

no invocation recorded.

load_corpus Not yet run
unverified (harvested, no recorded run)
Nardien/agent-distillation/search/retriever_server.py
code served (permissive licence) · get_code("de61bda51ce45fe7")
How it ran

no invocation recorded.

setup_savedir Not yet run
unverified (harvested, no recorded run)
Nardien/agent-distillation/exps_research/finetune_sft.py
code served (permissive licence) · get_code("bf1561bd0dbfe155")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 3 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
read_jsonl 4 other papers
2 dated earlier, 1 later, 1 same year, order not determinable
2401.10768 (2024-01)
Knowledge Verification to Nip Hallucination in the Bud
2412.16620 (2024-12)
A Large-scale Empirical Study on Fine-tuning Large Language Models for Unit Testing
2025.emnlp-main.1337 (2025 (year only))
CopySpec: Accelerating LLMs with Speculative Copy-and-Paste
and 1 more not named here
load_docs 3 other papers
3 later
2601.14896 (2026-01)
Language-Coupled Reinforcement Learning for Multilingual Retrieval-Augmented Generation
2602.02258 (2026-02)
Alignment-Aware Model Adaptation via Feedback-Guided Optimization
2603.11327 (2026-03)
Meta-Reinforcement Learning with Self-Reflection for Agentic Search
load_corpus 1 other paper
1 later
2601.14896 (2026-01)
Language-Coupled Reinforcement Learning for Multilingual Retrieval-Augmented Generation

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large language models (LLMs) excel at complex reasoning tasks but remain computationally expensive, limiting their practical deployment. To address this, recent works have focused on distilling reasoning capabilities into smaller language models (sLMs) using chain-of-thought (CoT) traces from teacher LLMs. However, this approach struggles in scenarios requiring rare factual knowledge or precise computation, where sLMs often hallucinate due to limited capability. In this work, we propose Agent Distillation, a framework for transferring not only reasoning capability but full task-solving behavior from LLM-based agents into sLMs with retrieval and code tools. We improve agent distillation along two complementary axes: (1) we introduce a prompting method called first-thought prefix to enhance the quality of teacher-generated trajectories; and (2) we propose a self-consistent action generation for improving test-time robustness of small agents. We evaluate our method on eight reasoning tasks across factual and mathematical domains, covering both in-domain and out-of-domain generalization. Our results show that sLMs as small as 0.5B, 1.5B, 3B parameters can achieve performance competitive with nexttier larger 1.5B, 3B, 7B models fine-tuned using CoT distillation, demonstrating the potential of agent distillation for building practical, tool-using small agents. Our code is available at https://github.com/Nardien/agent-distillation.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2505.17612")
get_code_for_paper("2505.17612")
have("2505.17612")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2505.17612.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2505.17612.svg)](https://syntology.ai/paper/2505.17612)

Connect an agent — have() is free.