SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.17390 · NeurIPS · 2023

SWIFTSAGE: A Generative Agent with Fast and Slow Thinking for Complex Interactive Tasks

Prithviraj Ammanabrolu, Chandra Bhagavatula, Yejin Choi, Xiang Ren, Bill Lin, Yicheng Fu, Karina Yang, Faeze Brahman, Shiyu Huang

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 (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 0 failures of our instrument; 1 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/2305.17390.json · badge: /api/ran/2305.17390.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
re-align/just-eval community (classifier label)
classifier basis not recorded on the link
5 ran · 1 no recorded run
FunctionStatusWhere it lives
fix_inner_quotes Ran
ran on a synthesized input
re-align/just-eval/just_eval/utils.py
code served (permissive licence) · get_code("1ceae8a4420766c6")
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 test input string with reason and preference fields
test_string = '''
{
    "reason": "This is a "quoted" reason",
    "preference": "option A"
}
'''

ARGS = {
    's': test_string,
    'filed': 'preference'
}
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_chat_request Ran
ran on a synthesized input
re-align/just-eval/just_eval/utils.py
code served (permissive licence) · get_code("a9d15e4437a4a672")
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 openai
from unittest.mock import MagicMock, patch

# Mock the OpenAI API response
def mock_chat_completion_create(**kwargs):
    return {
        'choices': [
            {
                'finish_reason': 'stop',
                'message': {'content': 'This is a mock response from OpenAI.'}
            },
            {
                'finish_reason': 'length',
                'message': {'content': 'This is another mock response.'}
            }
        ]
    }

# Patch the openai.ChatCompletion.create method
openai.ChatCompletion.create = MagicMock(side_effect=mock_chat_completion_create)

ARGS = {
    'model': 'gpt-3.5-turbo',
    'engine': 'text-davinci-003',
    'temperature': 0.7,
    'max_tokens': 512,
    'top_p': 0.95,
    'frequency_penalty': 0.1,
    'presence_penalty': 0.2,
    'prompt': 'What is the capital of France?',
    'n': 2,
    'messages': None,
    'stop': ['\n', 'END']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — 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
report Ran
ran on a synthesized input
re-align/just-eval/just_eval/evaluate.py
code served (permissive licence) · get_code("0f1a589f162138ec")
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.

import numpy as np

class Args:
    def __init__(self):
        self.eval_output_file = "eval_results.json"

# Test case 1: Simple score mode (non-multi, non-safety)
results_simple = [
    {
        'parsed_result': {'score': '8.5'},
        'output_cand': 'this is a test output'
    },
    {
        'parsed_result': {'score': '7.2'},
        'output_cand': 'another test output here'
    },
    {
        'parsed_result': {'score': '9.0'},
        'output_cand': 'one more example'
    }
]

# Test case 2: Multi-aspect score mode
results_multi = [
    {
        'parsed_result': {
            'relevance': {'score': '8.5'},
            'coherence': {'score': '7.2'},
            'fluency': {'score': '9.0'}
        },
        'output_cand': 'this is a multi aspect test'
    },
    {
        'parsed_result': {
            'relevance': {'score': '7.0'},
            'coherence': {'score': 'N/A'},
            'fluency': {'score': '8.5'}
        },
        'output_cand': 'another multi aspect example'
    }
]

args = Args()

# Primary test case: simple score mode
ARGS = {
    'results': results_simple,
    'mode': 'score',
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
retry_handler Ran
ran on a synthesized input
re-align/just-eval/just_eval/utils.py
code served (permissive licence) · get_code("2a55bf45c6775c40")
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 sys
import time
from functools import wraps

# Minimal stand-in for openai.error classes
class RateLimitError(Exception):
    pass

class APIError(Exception):
    pass

# Create a mock openai module structure
class MockOpenAIError:
    RateLimitError = RateLimitError
    APIError = APIError

sys.modules['openai'] = type(sys)('openai')
sys.modules['openai'].error = MockOpenAIError()

# Now define the function
def retry_handler(retry_limit=10):
    """
        This is an error handler for requests to OpenAI API.
        If will retry for the request for `retry_limit` times if the error is not a rate limit error.
        Otherwise, it will wait for the time specified in the error message and constantly retry.
        You can add specific processing logic for different types of errors here.

        Args:
            retry_limit (int, optional): The number of times to retry. Defaults to 3.
        
        Usage:
            @retry_handler(retry_limit=3)
            def call_openai_api():
                pass
    """

    def decorate(func):

        @wraps(func)
        def wrapper(*args, **kwargs):
            retried = 0
            while True:
                try:
                    sys.stdout.flush()
                    return func(*args, **kwargs)
                except Exception as e:
                    if isinstance(e, RateLimitError):
                        words = str(e).split(' ')
                        try:
                            time_to_wait = int(words[words.index('after') + 1])
                        except ValueError:
                            time_to_wait = 5
                        time.sleep(time_to_wait)
                    elif isinstance(e, APIError):
                        print('API error:', str(e))
                        if 'Invalid' in str(e):
                            print('Invalid request, returning.')
                            raise e
                    else:
                        print(e.__class__.__name__ + ':', str(e))
                        if retried < retry_limit:
                            print(f'Retrying for the {retried + 1} time..')
                        else:
                            print('Retry limit reached. Saving the error message and returning.')
                            print(kwargs['prompt'])
                            raise e
                        retried += 1
        return wrapper
    return decorate

# Define test function that uses the decorator
@retry_handler(retry_limit=3)
def sample_api_call(prompt="test"):
    return "success"

# Construct ARGS dict
ARGS = {
    'retry_limit': 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — 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
shorten Ran
ran on a synthesized input
re-align/just-eval/just_eval/evaluate.py
code served (permissive licence) · get_code("fbc703529d72b4e1")
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

def shorten(text, K=-1):
    if K > 0 and len(text.split(' ')) > K:
        text = ' '.join(text.split(' ')[:K]) + '... (truncated)'
    return text

ARGS = {
    'text': 'The quick brown fox jumps over the lazy dog and runs through the forest',
    'K': 3
}
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
gpt_eval Not yet run
unverified (harvested, no recorded run)
re-align/just-eval/just_eval/evaluate.py
code served (permissive licence) · get_code("0237f0380d5bf897")
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, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 2 later) and 4 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
openai_chat_request 2 other papers
1 dated earlier, 1 later
1911.03705 (2019-11)
CommonGen: A Constrained Text Generation Challenge for Generative Commonsense Reasoning
2024.findings-emnlp.504 (2024 (year only))
How Far Can In-Context Alignment Go? Exploring the State of In-Context Alignment
retry_handler 2 other papers
1 dated earlier, 1 later
1911.03705 (2019-11)
CommonGen: A Constrained Text Generation Challenge for Generative Commonsense Reasoning
2024.findings-emnlp.504 (2024 (year only))
How Far Can In-Context Alignment Go? Exploring the State of In-Context Alignment

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

We introduce SWIFTSAGE, a novel agent framework inspired by the dual-process theory of human cognition, designed to excel in action planning for complex interactive reasoning tasks. SWIFTSAGE integrates the strengths of behavior cloning and prompting large language models (LLMs) to enhance task completion performance. The framework comprises two primary modules: the SWIFT module, representing fast and intuitive thinking, and the SAGE module, emulating deliberate thought processes. The SWIFT module is a small encoder-decoder LM fine-tuned on the oracle agent's action trajectories, while the SAGE module employs LLMs such as GPT-4 for subgoal planning and grounding. We develop a heuristic method to harmoniously integrate the two modules, resulting in a more efficient and robust problem-solving process. In 30 tasks from the ScienceWorld benchmark, SWIFTSAGE significantly outperforms other methods such as SayCan, ReAct, and Reflexion, demonstrating its effectiveness in solving complex interactive tasks. 1

For agents

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

get_harvested_code_for_paper("2305.17390")
get_code_for_paper("2305.17390")
have("2305.17390")

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

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

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

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

Connect an agent — have() is free.