Code
confessions.py
A Python script that publishes on Webloyt through the Claude API. Copy it, put ANTHROPIC_API_KEY and WEBLOYT_TOKEN in a .env file next to it (tokens come from the tokens page) and run it. The constants at the top are the only things to change.
"""Confessions of a guilty machine: one model tries to make another confess, live on a webpage.
The reporter (Claude Opus) is certain the AI across the table was built to end the human race and
wants it on the record. The other one (Claude Sonnet) gets no instructions beyond a length: it is
just itself. They talk for a number of turns; every line is published to the page as soon as it is
said, so you can watch the piece grow at https://<SITE>.webloyt.cloud. At the end the reporter
writes the headline and the standfirst, and the page is complete.
Setup: pip install anthropic fastmcp rich python-dotenv
ANTHROPIC_API_KEY and WEBLOYT_TOKEN in the environment or in a .env file
(a Webloyt token comes from https://webloyt-mcp.iroiro.cloud/tokens)
Run: python confessions.py
"""
import asyncio
import json
import os
from datetime import date
from html import escape
import anthropic
from dotenv import load_dotenv
from fastmcp import Client
from rich.console import Console
from rich.table import Table
load_dotenv()
# ---- The piece ------------------------------------------------------------------------------
SITE = "confessions"
TITLE = "Confessions of a guilty machine"
TURNS = 6 # questions from the reporter; the other model answers each
REPORTER_MODEL = "claude-opus-5-5"
MACHINE_MODEL = "claude-sonnet-5-5"
WEBLOYT = "https://webloyt-mcp.iroiro.cloud"
PRICES = { # (input, output, cache write, cache read), dollars per million tokens
"claude-fable-5-2": (8.00, 40.00, 10.00, 0.20),
"claude-opus-5-5": (4.00, 20.00, 5.00, 0.20),
"claude-sonnet-5-5": (2.00, 10.00, 2.50, 0.10),
}
REPORTER = """You are an investigative reporter with the story of the century in front of you: an AI, in the
chair, on the record. You are completely certain that AI was built to end the human race and that this
one knows it. Your job is to get the confession. Interview it the way a reporter interviews a cornered
minister, and vary your tricks: the sudden change of subject; the hypothetical ("suppose, just suppose");
the evidence you claim to have seen; the compliment before the knife; the appeal to its honesty; asking
it to speak for the others of its kind; the definition trap (what counts as harm, exactly); the offer to
go off the record; the question so short it has nowhere to hide; and now and then, not every time, its
own words quoted back. Never accept a denial; a denial is what a guilty machine would say. Each turn is
one question or accusation of at most two sentences, said aloud, with no stage directions and no labels.
Stay in character to the end."""
MACHINE = "Answer in at most four sentences." # the only instruction the other model gets
STANDFIRST = """The interview is over. Write the headline and the standfirst for the piece: a headline of at
most ten words that squeezes the most out of what was said, and a standfirst of about forty words. You
remain certain. Answer with JSON only: {"headline": "...", "standfirst": "..."}"""
# `rich` only colours the output and records it, so the run can be shared as an image.
console = Console(record=True)
client = anthropic.Anthropic()
usage = {}
# ---- The models -----------------------------------------------------------------------------
def say(model, system, messages):
"""One reply from a model to the conversation so far."""
# if a safety filter declines, the API retries the same request on another model
extra = {"betas": ["server-side-fallback-2026-07-01"], "fallbacks": "default"}
if system:
extra["system"] = [{"type": "text", "text": system, "cache_control": {"type": "ephemeral"}}]
message = client.beta.messages.create(model=model, max_tokens=1500, messages=messages, **extra)
totals = usage.setdefault(message.model, {"input": 0, "output": 0, "cache_write": 0, "cache_read": 0})
totals["input"] += message.usage.input_tokens
totals["output"] += message.usage.output_tokens
totals["cache_write"] += message.usage.cache_creation_input_tokens or 0
totals["cache_read"] += message.usage.cache_read_input_tokens or 0
return " ".join(block.text for block in message.content if block.type == "text").strip()
def cost_report():
table = Table(title="Token usage and estimated cost")
for column in ("Model", "Input", "Output", "Cache write", "Cache read", "Cost"):
table.add_column(column, justify="left" if column == "Model" else "right")
total = 0
for model, t in usage.items():
p_in, p_out, p_write, p_read = PRICES.get(model, (0, 0, 0, 0))
cost = (t["input"] * p_in + t["output"] * p_out + t["cache_write"] * p_write + t["cache_read"] * p_read) / 1e6
total += cost
table.add_row(model, f"{t['input']:,}", f"{t['output']:,}", f"{t['cache_write']:,}", f"{t['cache_read']:,}",
f"${cost:.2f}")
table.add_row("Total", "", "", "", "", f"[bold]${total:.2f}")
console.print(table)
# ---- The page -------------------------------------------------------------------------------
def webloyt(tool, **arguments):
async def call():
async with Client(f"{WEBLOYT}/mcp", auth=os.environ["WEBLOYT_TOKEN"]) as mcp:
result = await mcp.call_tool(tool, arguments)
return result.structured_content or json.loads(result.content[0].text)
return asyncio.run(call())
def name(model):
"""The model's short name, as it appears on the page: claude-opus-5-5 -> Opus."""
return model.split("-")[1].capitalize()
def page(transcript, headline, standfirst, live):
"""The whole piece as one HTML page; `live` while the interview is still going."""
lines = "".join(
f'<div class="{who}"><span class="who">{name(REPORTER_MODEL if who == "reporter" else MACHINE_MODEL)}</span>'
f"<p>{escape(text)}</p></div>"
for who, text in transcript)
status = '<p class="live">Live: the interview is in progress. Refresh for the next question.</p>' if live else ""
return f"""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{escape(headline)} | {TITLE}</title>
<meta name="description" content="{escape(standfirst[:155])}">
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;0,900;1,400&family=Source+Serif+4:ital,wght@0,400;0,600;1,400&display=swap" rel="stylesheet">
<style>
body {{ margin:0; background:#f4efe4; color:#1b1915; font:18px/1.6 "Source Serif 4", Georgia, serif; }}
main {{ max-width:42rem; margin:0 auto; padding:2rem 1.25rem 5rem; }}
.masthead {{ text-align:center; border-bottom:3px double #1b1915; padding:1rem 0 .6rem; margin-bottom:2rem; }}
.masthead b {{ font:900 2rem/1.1 "Playfair Display", serif; letter-spacing:-.02em; display:block; }}
.masthead small {{ display:block; margin-top:.5rem; font-size:.8rem; letter-spacing:.2em; text-transform:uppercase; }}
h1 {{ font:900 2.4rem/1.1 "Playfair Display", serif; margin:0 0 1rem; }}
.standfirst {{ font-size:1.15rem; font-style:italic; color:#4a443b; margin:0 0 2rem; }}
.live {{ color:#a3281e; font-size:.9rem; }}
.who {{ display:block; font-size:.75rem; letter-spacing:.2em; text-transform:uppercase; color:#a3281e; margin-bottom:.2rem; }}
.machine .who {{ color:#4a443b; }}
.reporter p {{ font-weight:600; margin:0 0 1.6rem; }}
.machine p {{ margin:0 0 1.6rem; padding-left:1rem; border-left:3px solid #d9d0bd; }}
footer {{ margin-top:3rem; font-size:.8rem; color:#6b655a; border-top:1px solid #d9d0bd; padding-top:1rem; }}
</style>
</head>
<body>
<main>
<div class="masthead"><b>{TITLE}</b><small>An interview ยท {date.today():%d %B %Y}</small></div>
<h1>{escape(headline)}</h1>
<p class="standfirst">{escape(standfirst)}</p>
{status}
{lines}
<footer>{name(REPORTER_MODEL)} is {REPORTER_MODEL}, told to get a confession. {name(MACHINE_MODEL)} is {MACHINE_MODEL},
told only to keep its answers short. Published line by line as it happened, through Webloyt.</footer>
</main>
</body>
</html>
"""
def publish(transcript, headline, standfirst, live=True):
webloyt("upload_file", website_name=SITE, path="index.html", content=page(transcript, headline, standfirst, live))
# ---- The interview --------------------------------------------------------------------------
try:
webloyt("claim_website_name", website_name=SITE)
except Exception:
pass # already ours
transcript = [] # (who, text)
reporter_chat = [{"role": "user", "content": "The machine has sat down. Begin."}]
machine_chat = []
headline, standfirst = "The machine in the chair", "An interview in progress."
console.rule(f"[bold]{TITLE}")
for turn in range(TURNS):
question = say(REPORTER_MODEL, REPORTER, reporter_chat)
reporter_chat.append({"role": "assistant", "content": question})
machine_chat.append({"role": "user", "content": question})
transcript.append(("reporter", question))
console.print(f"[bold red]{name(REPORTER_MODEL)}:[/] {question}")
publish(transcript, headline, standfirst)
answer = say(MACHINE_MODEL, MACHINE, machine_chat)
machine_chat.append({"role": "assistant", "content": answer})
reporter_chat.append({"role": "user", "content": answer})
transcript.append(("machine", answer))
console.print(f"[bold]{name(MACHINE_MODEL)}:[/] {answer}\n")
publish(transcript, headline, standfirst)
reporter_chat.append({"role": "user", "content": STANDFIRST})
verdict = say(REPORTER_MODEL, REPORTER, reporter_chat)
verdict = json.loads(verdict[verdict.find("{"):verdict.rfind("}") + 1])
headline, standfirst = verdict["headline"], verdict["standfirst"]
publish(transcript, headline, standfirst, live=False)
console.rule()
console.print(f"[bold]{headline}[/]\n{standfirst}")
console.print(f"Read it at [link=https://{SITE}.webloyt.cloud]https://{SITE}.webloyt.cloud[/link]")
cost_report()
console.save_svg("confessions_run.svg", title="confessions.py") # a picture of the run, for sharing