SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.04271 · NeurIPS · 2024

Buffer of Thoughts: Thought-Augmented Reasoning with Large Language Models

Joseph Gonzalez, Minkai Xu, Ling Yang, Tianjun Zhang, Wentao Zhang, Bin Cui, Zhaochen Yu, Shiyi Cao

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 2 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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/2406.04271.json · badge: /api/ran/2406.04271.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
YangLing0818/buffer-of-thought-llm canonical (classifier label)
classifier basis not recorded on the link
4 ran · 1 no recorded run
gen-verse/reasonflux community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
MemoryBuffer Ran
ran on a synthesized input · constructed an object; no result was computed
gen-verse/reasonflux/ReasonFlux_PRM/Application/verl/utils/memory_buffer.py
pointer only (licence: NONE) · get_code("726d727041563e62")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, gen-verse/reasonflux 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.

azure_openai_complete_if_cache Ran
ran on a synthesized input
YangLing0818/buffer-of-thought-llm/lightrag/llm.py
code served (permissive licence) · get_code("9768f858484cc024")
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 coroutine. 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 os
from unittest.mock import AsyncMock, MagicMock, patch
import asyncio

# Mock the required classes and functions
class BaseKVStorage:
    async def get_by_id(self, key):
        return None
    
    async def upsert(self, data):
        pass

class MockMessage:
    def __init__(self, content):
        self.content = content

class MockChoice:
    def __init__(self, content):
        self.message = MockMessage(content)

class MockResponse:
    def __init__(self, content):
        self.choices = [MockChoice(content)]

def compute_args_hash(model, messages):
    """Simple hash function for caching"""
    import hashlib
    content = f"{model}:{str(messages)}"
    return hashlib.md5(content.encode()).hexdigest()

# Set up environment variables
os.environ['AZURE_OPENAI_ENDPOINT'] = 'https://test.openai.azure.com/'
os.environ['AZURE_OPENAI_API_KEY'] = 'test-api-key'
os.environ['AZURE_OPENAI_API_VERSION'] = '2023-05-15'

# Create mock hashing_kv storage
mock_kv_storage = BaseKVStorage()

# Create arguments dictionary
ARGS = {
    'model': 'gpt-4',
    'prompt': 'What is machine learning?',
    'system_prompt': 'You are a helpful AI assistant.',
    'history_messages': [
        {'role': 'user', 'content': 'Hello'},
        {'role': 'assistant', 'content': 'Hi there!'}
    ],
    'base_url': 'https://test.openai.azure.com/',
    'api_key': 'test-api-key',
    'hashing_kv': mock_kv_storage,
    'temperature': 0.7,
    'max_tokens': 100
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai, tenacity — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine 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
extract_and_execute_code Ran
ran; our contract draft was wrong, not the code
YangLing0818/buffer-of-thought-llm/meta_buffer_utilis.py
code served (permissive licence) · get_code("15dd38c0c4a5e24b")
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 io
import sys

def extract_and_execute_code(text):
    code_start_markers = ['```python', '```Python', '```']
    code_end_marker = '```'
    code_start_index = -1
    code_start_marker_used = None
    for marker in code_start_markers:
        code_start_index = text.lower().find(marker.lower())
        if code_start_index != -1:
            code_start_marker_used = marker
            break
    if code_start_index != -1:
        code_end_index = text.find(code_end_marker, code_start_index + len(code_start_marker_used))
        if code_end_index == -1:
            code_end_index = len(text)
        code_str = text[code_start_index + len(code_start_marker_used):code_end_index].strip()
        for marker in code_start_markers:
            code_str = code_str.replace(marker, '')
        code_str = code_str.replace(code_end_marker, '').strip()
        old_stdout = sys.stdout
        new_stdout = io.StringIO()
        sys.stdout = new_stdout
        try:
            exec(code_str, globals())
        except Exception as e:
            sys.stdout = old_stdout
            return (f'An error occurred: {e}', code_str)
        sys.stdout = old_stdout
        return (new_stdout.getvalue(), code_str)
    else:
        return ('No Python code found in the provided string.', None)

ARGS = {
    'text': 'Here is some Python code:\n```python\nprint("Hello, World!")\nx = 42\nprint(x)\n```\nAnd that was the code.'
}
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 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
extract_answer Ran
ran; our contract draft was wrong, not the code
YangLing0818/buffer-of-thought-llm/meta_buffer_utilis.py
code served (permissive licence) · get_code("92d7b41138b8da5b")
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 extract_answer(text):
    pattern = re.compile('Answer:\\s*(.*?)\\s*$', re.DOTALL)
    match = pattern.search(text)
    return match.group(1).strip() if match else None

ARGS = {
    'text': 'Some question here.\nAnswer:   This is the answer.   '
}
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
openai_complete_if_cache Ran
ran on a synthesized input
YangLing0818/buffer-of-thought-llm/lightrag/llm.py
code served (permissive licence) · get_code("7e668b3293f54805")
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 coroutine. 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 os
from unittest.mock import AsyncMock, MagicMock, patch
import asyncio


class BaseKVStorage:
    """Stand-in KV storage class with async get_by_id and upsert methods"""
    def __init__(self):
        self.storage = {}
    
    async def get_by_id(self, key):
        return self.storage.get(key)
    
    async def upsert(self, data):
        self.storage.update(data)


def compute_args_hash(model, messages):
    """Stand-in hash function for caching"""
    import hashlib
    content = f"{model}:{str(messages)}"
    return hashlib.md5(content.encode()).hexdigest()


class MockMessage:
    def __init__(self, content):
        self.content = content


class MockChoice:
    def __init__(self, content):
        self.message = MockMessage(content)


class MockResponse:
    def __init__(self, content):
        self.choices = [MockChoice(content)]


class MockAsyncClient:
    async def __aenter__(self):
        return self
    
    async def __aexit__(self, exc_type, exc_val, exc_tb):
        pass
    
    class Completions:
        async def create(self, model, messages, **kwargs):
            return MockResponse("This is a test response from the model.")
    
    def __init__(self, base_url=None):
        self.chat = MagicMock()
        self.chat.completions = self.Completions()


ARGS = {
    'model': 'gpt-4',
    'prompt': 'What is the meaning of life?',
    'system_prompt': 'You are a helpful assistant.',
    'history_messages': [
        {'role': 'user', 'content': 'Hello'},
        {'role': 'assistant', 'content': 'Hi there!'}
    ],
    'base_url': None,
    'api_key': 'sk-test-key-12345',
    'hashing_kv': BaseKVStorage(),
    'temperature': 0.7,
    'max_tokens': 100
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai, tenacity — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine 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
chunking_by_token_size Not yet run
unverified (harvested, no recorded run)
YangLing0818/buffer-of-thought-llm/lightrag/operate.py
code served (permissive licence) · get_code("d91c95543a58a3c6")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 5 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 5 later) and 1 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
chunking_by_token_size 2 other papers
2 later
2506.18896 (2025-06)
ReasonFlux-PRM: Trajectory-Aware PRMs for Long Chain-of-Thought Reasoning in LLMs
2507.21892 (2025-07)
Graph-R1: Towards Agentic GraphRAG Framework via End-to-end Reinforcement Learning
azure_openai_complete_if_cache 1 other paper
1 later
2506.18896 (2025-06)
ReasonFlux-PRM: Trajectory-Aware PRMs for Long Chain-of-Thought Reasoning in LLMs
extract_and_execute_code 1 other paper
1 later
2506.18896 (2025-06)
ReasonFlux-PRM: Trajectory-Aware PRMs for Long Chain-of-Thought Reasoning in LLMs
extract_answer 1 other paper
1 later
2506.18896 (2025-06)
ReasonFlux-PRM: Trajectory-Aware PRMs for Long Chain-of-Thought Reasoning in LLMs
openai_complete_if_cache 1 other paper
1 later
2506.18896 (2025-06)
ReasonFlux-PRM: Trajectory-Aware PRMs for Long Chain-of-Thought Reasoning in LLMs

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-22.

Repositories linked to this paper

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

Abstract

We introduce Buffer of Thoughts (BoT), a novel and versatile thought-augmented reasoning approach for enhancing accuracy, efficiency and robustness of large language models (LLMs). Specifically, we propose meta-buffer to store a series of informative high-level thoughts, namely thought-template, distilled from the problem-solving processes across various tasks. Then for each problem, we retrieve a relevant thought-template and adaptively instantiate it with specific reasoning structures to conduct efficient reasoning. To guarantee the scalability and stability, we further propose buffer-manager to dynamically update the meta-buffer, thus enhancing the capacity of meta-buffer as more tasks are solved. We conduct extensive experiments on 10 challenging reasoning-intensive tasks, and achieve significant performance improvements over previous SOTA methods: 11% on Game of 24, 20% on Geometric Shapes and 51% on Checkmate-in-One. Further analysis demonstrate the superior generalization ability and model robustness of our BoT, while requiring only 12% of the cost of multi-query prompting methods (e.g., tree/graph of thoughts) on average. Notably, we find that our Llama3-8B + BoT has the potential to surpass Llama3-70B model. Our project is available at https://github.com/YangLing0818/buffer-of-thought-llm

For agents

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

get_harvested_code_for_paper("2406.04271")
get_code_for_paper("2406.04271")
have("2406.04271")

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

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

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

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

Connect an agent — have() is free.