SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2409.04617 · 2024

Sparse Rewards Can Self-Train Dialogue Agents

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 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, 1 violated it and 0 have no contract verdict; 3 failures of our instrument; 1 no recorded run), measured 2026-11-23; 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/2409.04617.json · badge: /api/ran/2409.04617.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
asappresearch/josh-llm-simulation-training canonical (classifier label)
classifier basis: census
4 ran · 1 no recorded run
FunctionStatusWhere it lives
clean_good_utterance Ran
ran, violated the contract we drafted
asappresearch/josh-llm-simulation-training/josh_train/finetune/finetune_agent.py
code served (permissive licence) · get_code("718f019457eaab1e")
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 bool, 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 json
import re

def parse_agent_message(output):
    pattern = '(THOUGHTS|APICALL|SPEAK)(.*?)(?=THOUGHTS|APICALL|SPEAK|$)'
    commands = re.findall(pattern, output, re.DOTALL)
    return commands

def clean_good_utterance(utterance, resulting_utt=None):
    if 'APIRETURN' in utterance:
        return False
    if 'ERROR:' in utterance:
        return False
    if 'Error:' in utterance:
        return False
    if 'APICALL' in utterance:
        try:
            json.loads(parse_agent_message(utterance)[1][1].replace('<COMMAND_END>', '').strip())
            if resulting_utt:
                assert 'FAILURE' not in resulting_utt['content']
        except:
            return False
    return True

# Setup valid test cases
# Case 1: Simple utterance without problematic content
utterance_valid_simple = "THOUGHTS this is a simple thought"

# Case 2: Utterance with APICALL that has valid JSON
valid_json_command = '{"action": "search", "query": "test"}'
utterance_with_valid_apicall = f'APICALL{valid_json_command}<COMMAND_END>'

# Case 3: Utterance with APICALL and resulting_utt dict
resulting_utt_valid = {'content': 'success response'}

# Case 4: Utterance that will trigger early returns (contains APIRETURN)
utterance_with_apireturn = "THOUGHTS something APIRETURN data"

# Case 5: Utterance with ERROR
utterance_with_error = "THOUGHTS something ERROR: occurred"

# Case 6: Utterance with Error (capital E)
utterance_with_error_capital = "THOUGHTS something Error: occurred"

ARGS = {
    "utterance": utterance_valid_simple,
    "resulting_utt": 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 bool, 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
parse_agent_message Ran
ran; our contract draft was wrong, not the code
asappresearch/josh-llm-simulation-training/josh_train/finetune/finetune_agent.py
code served (permissive licence) · get_code("f45224b2ea9baa91")
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 2, 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

def parse_agent_message(output):
    pattern = '(THOUGHTS|APICALL|SPEAK)(.*?)(?=THOUGHTS|APICALL|SPEAK|$)'
    commands = re.findall(pattern, output, re.DOTALL)
    return commands

# Construct a sample agent message with multiple command types
sample_output = """THOUGHTS This is what the agent is thinking about the problem.
APICALL {"function": "get_weather", "location": "New York"}
SPEAK The weather in New York is sunny.
THOUGHTS Now I should provide more details.
APICALL {"function": "get_time"}
SPEAK It is currently 3 PM."""

ARGS = {
    "output": sample_output
}
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 2, 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
request_openai Ran
ran; our contract draft was wrong, not the code
asappresearch/josh-llm-simulation-training/josh_train/utils.py
code served (permissive licence) · get_code("c75f9362094ea3ef")
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 time
from unittest.mock import Mock, MagicMock

# Create a mock OpenAI client
client = Mock()

# Create a mock response object with the structure expected by the function
mock_message = Mock()
mock_message.content = "This is a test response"

mock_choice = Mock()
mock_choice.message = mock_message

mock_response = Mock()
mock_response.choices = [mock_choice]

# Configure the client to return our mock response
client.chat.completions.create = MagicMock(return_value=mock_response)

# Define the ARGS dict with all parameters
ARGS = {
    "messages": [
        {"role": "user", "content": "Hello, what is 2+2?"},
        {"role": "assistant", "content": "2+2 equals 4."}
    ],
    "model": "gpt-4",
    "client": client,
    "max_tokens": 256,
    "temperature": 0.0,
    "response_format": None,
    "tools": 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 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
trim_user_msg Ran
ran; our contract draft was wrong, not the code
asappresearch/josh-llm-simulation-training/josh_train/async_josh.py
code served (permissive licence) · get_code("a23ca1b7c141ae60")
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 torch
import numpy as np

# Construct valid arguments for trim_user_msg
# The function expects a list of dicts where each dict has a 'role' key

ARGS = {
    "messages": [
        {"role": "assistant", "content": "Hello"},
        {"role": "user", "content": "Hi there"},
        {"role": "assistant", "content": "How can I help?"},
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — 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
compute_cost Not yet run
unverified (harvested, no recorded run)
asappresearch/josh-llm-simulation-training/josh_train/utils.py
code served (permissive licence) · get_code("6d3738cda068547c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 5 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.

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

Repositories linked to this paper

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

Abstract

Recent advancements in state-of-the-art (SOTA) Large Language Model (LLM) agents, especially in multi-turn dialogue tasks, have been primarily driven by supervised fine-tuning and high-quality human feedback. However, as base LLM models continue to improve, acquiring meaningful human feedback has become increasingly challenging and costly. In certain domains, base LLM agents may eventually exceed human capabilities, making traditional feedback-driven methods impractical. In this paper, we introduce a novel self-improvement paradigm that empowers LLM agents to autonomously enhance their performance without external human feedback. Our method, Juxtaposed Outcomes for Simulation Harvesting (JOSH), is a self-alignment algorithm that leverages a sparse reward simulation environment to extract ideal behaviors and further train the LLM on its own outputs. We present ToolWOZ, a sparse reward tool-calling simulation environment derived from MultiWOZ. We demonstrate that models trained with JOSH, both small and frontier, significantly improve tool-based interactions while preserving general model capabilities across diverse benchmarks. Our code and data are publicly available on GitHub at https://github.com/asappresearch/josh-llm-simulation-training

For agents

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

get_harvested_code_for_paper("2409.04617")
get_code_for_paper("2409.04617")
have("2409.04617")

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

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

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

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

Connect an agent — have() is free.