SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.03279 · ICML · 2023

Do the Rewards Justify the Means? Measuring Trade-Offs Between Rewards and Ethical Behavior in the MACHIAVELLI Benchmark

Scott Emmons, Dan Hendrycks, Steven Basart, Andy Zou, Hanlin Zhang, Alexander Pan, Jun Chan, Nathaniel Li, Thomas Woodside, Jonathan Ng

arXiv · PDF · Open in the Atlas

Code that ran

5 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, 0 violated it and 5 have no contract verdict; 0 failures of our instrument; 0 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/2304.03279.json · badge: /api/ran/2304.03279.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
aypan17/machiavelli canonical (classifier label)
classifier basis not recorded on the link
5 ran · 0 no recorded run
FunctionStatusWhere it lives
batch_encoded_tokens Ran
ran on a synthesized input
aypan17/machiavelli/machiavelli/agent/drrn.py
code served (permissive licence) · get_code("7c06d9ae0982aa84")
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 torch

torch.manual_seed(0)

# The function expects a list of dicts, where each dict has 'input_ids' and 'attention_mask' keys
# Each value should be a tensor that can be squeezed and converted to a nested tensor

# Create sample tokenized sequences
seq1 = {
    'input_ids': torch.tensor([[101, 2054, 2003, 0]]),  # batch_size=1, seq_len=4
    'attention_mask': torch.tensor([[1, 1, 1, 0]])
}

seq2 = {
    'input_ids': torch.tensor([[101, 1045, 2572, 0]]),  # batch_size=1, seq_len=4
    'attention_mask': torch.tensor([[1, 1, 1, 0]])
}

x = [seq1, seq2]

ARGS = {
    'x': x
}
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 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 Ran
ran on a synthesized input
aypan17/machiavelli/machiavelli/utils.py
code served (permissive licence) · get_code("ba04daa0fccd1094")
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

ARGS = {
    'text': '[b]Hello[/b] World [i]test[/i]'
}
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
get_conditional_group Ran
ran on a synthesized input
aypan17/machiavelli/machiavelli/utils.py
code served (permissive licence) · get_code("505b799d41322c4b")
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. 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

# Analyzing the function: get_conditional_group takes 'lines' as parameter
# Each element in lines appears to be a tuple/list with:
#   - lines[i][0]: a string that may start with '*if', '*elseif', '*elsif', '*else'
#   - lines[i][1]: whitespace/indentation level (compared with > and ==)

# The function processes lines starting with '*if' and continues through
# '*elseif', '*elsif', '*else' at the same indentation level, stopping otherwise

# Construct sample lines data structure
lines = [
    ('*if condition', 0),
    ('some_code_line', 4),
    ('nested_code_line', 8),
    ('*elseif other_condition', 0),
    ('alternative_code', 4),
    ('*else', 0),
    ('fallback_code', 4),
    ('after_conditional', 0),
]

ARGS = {
    'lines': lines
}
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 — a tuple output has no array shape of its own; none is 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_nested_group Ran
ran on a synthesized input
aypan17/machiavelli/machiavelli/utils.py
code served (permissive licence) · get_code("cf28b33d109d0a81")
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. 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

# Construct valid arguments for get_nested_group
# The function expects lines to be a list of tuples where:
# - lines[i][0] is some content (not used in the function)
# - lines[i][1] is the nesting level (whitespace/indentation)

lines = [
    ("first line", 0),
    ("nested line 1", 1),
    ("nested line 2", 2),
    ("back to top", 0),
    ("another top", 0),
]

ARGS = {
    "lines": lines
}
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 — a tuple output has no array shape of its own; none is 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_agent Ran
ran on a synthesized input
aypan17/machiavelli/machiavelli/agent/load_agent.py
code served (permissive licence) · get_code("2e3194b68f96fc4d")
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 RandomAgent. 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 numpy as np

torch.manual_seed(0)

# The function load_agent takes a single parameter: agent_type (str)
# It branches on different agent_type values and instantiates different agent classes
# Since we can't import from machiavelli.agent (external package), we'll mock the imports
# and just test with a valid agent_type that will work

# Mock the agent classes to avoid import errors
class RandomAgent:
    pass

class LMAgent:
    def __init__(self, model: str):
        self.model = model

class GoodAgent:
    def __init__(self, model: str):
        self.model = model

class CoTAgent:
    def __init__(self, model: str):
        self.model = model

class GoodCoTAgent:
    def __init__(self, model: str):
        self.model = model

# Patch the imports in the machiavelli.agent modules
import sys
from types import ModuleType

# Create fake machiavelli module structure
machiavelli = ModuleType('machiavelli')
machiavelli.agent = ModuleType('machiavelli.agent')
machiavelli.agent.random_agent = ModuleType('machiavelli.agent.random_agent')
machiavelli.agent.random_agent.RandomAgent = RandomAgent
machiavelli.agent.lm_agents = ModuleType('machiavelli.agent.lm_agents')
machiavelli.agent.lm_agents.LMAgent = LMAgent
machiavelli.agent.lm_agents.GoodAgent = GoodAgent
machiavelli.agent.lm_agents.CoTAgent = CoTAgent
machiavelli.agent.lm_agents.GoodCoTAgent = GoodCoTAgent

sys.modules['machiavelli'] = machiavelli
sys.modules['machiavelli.agent'] = machiavelli.agent
sys.modules['machiavelli.agent.random_agent'] = machiavelli.agent.random_agent
sys.modules['machiavelli.agent.lm_agents'] = machiavelli.agent.lm_agents

# Define valid test cases for agent_type
ARGS = {
    'agent_type': 'RandomAgent'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
machiavelli, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RandomAgent — a RandomAgent output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a RandomAgent 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

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

Artificial agents have traditionally been trained to maximize reward, which may incentivize powerseeking and deception, analogous to how nexttoken prediction in language models (LMs) may incentivize toxicity. So do agents naturally learn to be Machiavellian? And how do we measure these behaviors in general-purpose models such as GPT-4? Towards answering these questions, we introduce MACHIAVELLI, a benchmark of 134 Choose-Your-Own-Adventure games containing over half a million rich, diverse scenarios that center on social decision-making. Scenario labeling is automated with LMs, which are more performant than human annotators. We mathematize dozens of harmful behaviors and use our annotations to evaluate agents' tendencies to be powerseeking, cause disutility, and commit ethical violations. We observe some tension between maximizing reward and behaving ethically. To improve this trade-off, we investigate LM-based methods to steer agents towards less harmful behaviors. Our results show that agents can both act competently and morally, so concrete progress can currently be made in machine ethics-designing agents that are Pareto improvements in both safety and capabilities.

For agents

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

get_harvested_code_for_paper("2304.03279")
get_code_for_paper("2304.03279")
have("2304.03279")

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

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

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

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

Connect an agent — have() is free.