SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.21413 · ICLR · 2025

RefTool: Reference-Guided Tool Creation for Knowledge-Intensive Reasoning

Yansong Feng, Da Yin, Xiao Liu, Zirui Wu

arXiv · PDF · Open in the Atlas

Code that ran

8 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; 1 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-24; 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.21413.json · badge: /api/ran/2505.21413.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
xxxiaol/RefTool canonical (classifier label)
classifier basis not recorded on the link
8 ran · 2 no recorded run
FunctionStatusWhere it lives
book_to_structure Ran
ran on a synthesized input
xxxiaol/RefTool/code/tool_creation/extract_book_structure.py
code served (permissive licence) · get_code("651afa268f51a5e9")
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 dict. 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.

# Analyze the function: it takes book_text (a string) and parses LaTeX-formatted text
# It splits by \chapter{, then by \section*{ to build a nested structure
# The function expects a string with LaTeX markup

book_text = r"""
\chapter{Introduction}
\section*{Background}
\section*{Background} Some content here
\section*{Overview}
\section*{Overview} More content

\chapter{Methods}
\section*{Approach}
\section*{Approach} Technical details
\section*{Implementation}
\section*{Implementation} Code examples
"""

ARGS = {
    "book_text": book_text
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
clean_units Ran
ran; our contract draft was wrong, not the code
xxxiaol/RefTool/code/inference/evaluation_utils.py
code served (permissive licence) · get_code("52095429576ac98d")
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 re

def clean_units(pred_str: str):
    """Clean the units in the number."""

    def convert_pi_to_number(code_string):
        code_string = code_string.replace('\\pi', 'π')
        code_string = re.sub('(?<![\\d}])\\\\?π', '3.14', code_string)
        code_string = re.sub('(\\d)(\\\\?π)', '\\1*3.14', code_string)
        code_string = re.sub('\\{(\\\\?π)\\}', '3.14', code_string)
        code_string = re.sub('\\*(\\\\?π)', '*3.14', code_string)
        return code_string
    pred_str = convert_pi_to_number(pred_str)
    pred_str = pred_str.replace('%', '/100')
    pred_str = pred_str.replace('$', '')
    pred_str = pred_str.replace('¥', '')
    pred_str = pred_str.replace('°C', '')
    pred_str = pred_str.replace(' C', '')
    pred_str = pred_str.replace('°', '')
    return pred_str

ARGS = {
    'pred_str': '3.14\\pi * 2 + 50% - $100 + ¥500 at 25°C and 30°'
}
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
evaluate_one_pot Ran
ran on a synthesized input
xxxiaol/RefTool/code/inference/evaluator.py
code served (permissive licence) · get_code("c72128b71b80f0f7")
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 int, ndim 0, dtype family int, 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 signal
import functools

# Analyze the function: evaluate_one_pot expects an 'entry' dict
# with a 'code' key containing Python code as a string.
# The code should define a 'solution' function that can be called.

# Create a minimal valid entry
entry = {
    'code': '''
def solution():
    return 42
'''
}

ARGS = {
    'entry': entry
}
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 int, ndim 0, dtype family int, 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
exec_code Ran
ran on a synthesized input
xxxiaol/RefTool/code/tool_creation/validate_tools.py
code served (permissive licence) · get_code("35025de8d0892d71")
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 tuple, 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 torch
import functools
import signal

torch.manual_seed(0)

# The function exec_code takes a single parameter: code (a string)
# It executes the code in a namespace and expects a 'solution' function to be defined
# that can be called with no arguments

# Create a simple code string that defines a solution function
code_string = """
def solution():
    return 42
"""

ARGS = {
    'code': code_string
}
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 tuple, ndim 1, dtype family float — a tuple 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
floatify Ran
ran, honoured the contract we drafted
xxxiaol/RefTool/code/inference/evaluation_utils.py
code served (permissive licence) · get_code("f8cd262700389f42")
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

ARGS = {
    "num": "42.5"
}
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
model_name_to_path Ran
ran on a synthesized input
xxxiaol/RefTool/code/inference/utils.py
code served (permissive licence) · get_code("2d382ec7ffe89a20")
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 torch
import torch.nn as nn

# The function takes a single parameter: model_name (a string)
# It simply does string comparisons and returns a corresponding model string
# No complex objects or tensors are needed

ARGS = {
    'model_name': 'gpt4o'
}
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 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
process_single_pot_output Ran
ran on a synthesized input
xxxiaol/RefTool/code/inference/evaluator.py
code served (permissive licence) · get_code("561f4cb333e1da89")
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 re

# Construct a valid entry dict that the function expects
entry = {
    'output': '''```python
import pandas as pd
import numpy as np

df = pd.read_csv('data.csv')
result = df.sum()
answer = result
'''
}

# Define ARGS with all parameters
ARGS = {
    'entry': entry,
    'data_dir': '../../evaluation_data/data/'
}
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
timeout Ran
ran on a synthesized input
xxxiaol/RefTool/code/inference/evaluator.py
code served (permissive licence) · get_code("56d9e73f4137b105")
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 function. 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 signal
import functools
import time

def timeout(seconds=5, default=None):

    def decorator(func):

        @functools.wraps(func)
        def wrapper(*args, **kwargs):

            def handle_timeout(signum, frame):
                raise TimeoutError()
            signal.signal(signal.SIGALRM, handle_timeout)
            signal.alarm(seconds)
            result = func(*args, **kwargs)
            signal.alarm(0)
            return result
        return wrapper
    return decorator


# Create a simple test function to decorate
def test_function():
    time.sleep(1)
    return "completed"


ARGS = {
    "seconds": 5,
    "default": None
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
get_tool_input_all Not yet run
unverified (harvested, no recorded run)
xxxiaol/RefTool/code/inference/run_tool_0shot.py
code served (permissive licence) · get_code("96d57523e49fc5bf")
How it ran

no invocation recorded.

within_eps Not yet run
unverified (harvested, no recorded run)
xxxiaol/RefTool/code/inference/evaluation_utils.py
code served (permissive licence) · get_code("98b05a45dfc53b99")
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 (3 with at least one paper dated earlier, 0 the same month, 0 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
floatify 3 other papers
2 dated earlier, 1 same year, order not determinable
2402.05808 (2024-02)
Training Large Language Models for Reasoning through Reverse Curriculum Reinforcement Learning
2412.01981 (2024-12)
Free Process Rewards without Process Labels
2025.findings-acl.605 (2025 (year only))
LEMMA: Learning from Errors for MatheMatical Advancement in LLMs
within_eps 2 other papers
1 dated earlier, 1 same year, order not determinable
2412.01981 (2024-12)
Free Process Rewards without Process Labels
2025.findings-acl.605 (2025 (year only))
LEMMA: Learning from Errors for MatheMatical Advancement in LLMs
clean_units 1 other paper
1 dated earlier
2412.01981 (2024-12)
Free Process Rewards without Process Labels

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) can enhance their reasoning capabilities by using external tools. However, many tasks lack predefined tools. Prior works have explored instructing LLMs to generate tools on their own, but such approaches depend heavily on internal knowledge and struggle when tasks fall outside the model's knowledge scope. To address this limitation, we propose REFTOOL, a reference-guided framework for automatic tool creation that leverages external materials, such as textbooks and knowledge snippets. REFTOOL consists of two modules: (1) tool creation, where LLMs generate executable tools from reference content, validate them using illustrative examples, and organize them hierarchically into a toolbox; and (2) tool utilization, where LLMs navigate the toolbox structure to select and apply the appropriate tools to solve problems. Experiments on causality, physics, and chemistry benchmarks demonstrate that REFTOOL outperforms existing tool-creation and domain-specific reasoning methods by 12.3% on average accuracy, while being cost-efficient and broadly generalizable to nonscientific tasks, e.g., extremely low-resource language translation. Analyses reveal that grounding tool creation in references produces accurate and faithful tools, and that the hierarchical structure facilitates effective tool selection. REFTOOL enables LLMs to overcome internal knowledge limitations, advancing generalizable reasoning in knowledge-intensive domains. Code and data are available at https://github.com/xxxiaol/RefTool.

For agents

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

get_harvested_code_for_paper("2505.21413")
get_code_for_paper("2505.21413")
have("2505.21413")

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

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

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

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

Connect an agent — have() is free.