根据应用程序的输入和输出格式中的证据来选择模型。在 OpenRouter 上运行相同的任务,并比较分级准确率、计费成本和请求时间。在我们进行的 60 项合成任务中,GPT-6.1 Sol 在测试的合同和设置下,经过三次重复试验,全部通过了 180/180 次试验。
TL;DR(太长不看)
代码检查用于衡量正确性和输出合规性。
Sol 在我们的合成数据集上以 180/180 的通过率胜出;DeepSeek 的响应成本最低,通过率为 157/180。
与公开排名的吻合度较弱,Spearman 相关系数为 0.109。
在信任某个分数之前,请检查每个任务的运行次数、返回的答案数量以及每笔账单是否经过验证。
先定义行为,再定义其检查标准。
第 1 步:编写脚本可检查答案的任务
任务需要包含输入、预期答案和输出合同。对于发票,需指定包含的行数、舍入规则以及可接受的后缀货币。
我们在最终运行之前编写了所有 40 个基准任务和 20 个困难任务。
| 类别 | 示例 | 检查项 |
|---|---|---|
| 发票算术 | 折扣后未付行总数 | 小数总额及舍入 |
| 日期和日程安排 | 转换时间戳或匹配日期的列表 | 确切时刻或日期列表 |
| 电子邮件提取 | 将字段提取为 JSON | 键、类型和值 |
| Python 函数 | 针对隐藏输入实现函数 | 在隔离运行时中的结果 |
| 输出约束 | 在指定限制内生成文本 | 长度、词汇和格式 |
| 退款决策 | 在其边界处应用书面政策 | 每笔订单的决策 |
独立计算参考数据。将提示微调案例与最终评估分开。退款案例测试书面决策,而不执行交易。
第 2 步:使用代码进行评分并检查评分器
对 APPROVE(批准)使用精确匹配,对 JSON 使用模式/值检查。仅规范化允许的差异。如果消费者只需要一个数字,而你在数字周围接受了散文内容,则会掩盖失败。
测试已知正确、错误和格式错误的响应。对于退款阈值,包含恰好 $200 和 30 天,以及略高于每个边界的值。
我们的开发检查器因遗漏 ord 和 type 而拒绝了有效的 Python 代码。我们在最终研究之前对其进行了更正,指定了 CPython 3.12.10/WASI 及资源限制。否则,检查器的失败将被计入模型的得分中。
完整研究的运行器会隔离生成的代码,如果缺少沙箱设置则停止运行。教学示例不执行任何生成的代码。
第 3 步:运行三任务 Python 示例
下载配套 ZIP 文件。在解压之前,将其 SHA-256 校验和与以下值进行比较:
a38ee17a2eb7090f9f4849a605cc8214691c889ca0ae40c121259603592178e8
PowerShell:
Get-FileHash .\benchmark-reader-companion.zip -Algorithm SHA256
Linux 或 macOS:
sha256sum benchmark-reader-companion.zip
shasum -a 256 benchmark-reader-companion.zip
如果值不同,请停止并检查下载。在匹配后,解压 ZIP 文件。你需要 Python 3.12 或更高版本。标准库教学运行器、JSON 示例和比较在 Windows x64 和 Linux 上通过了离线检查。macOS 尚未测试。捆绑的完整研究沙箱和本地 Ori 设置仅支持 Windows x64。
从解压后的文件夹中:
python verify_package.py
python three_tasks.py check
check 命令会打印“OFFLINE reference and grader checks passed; zero inference calls”(离线参考和评分器检查通过;零次推理调用)。完整脚本按文件顺序如下。其配套模块处理请求、持久化和报告。
"""三个精确的合同;从解压后的配套文件夹(标准库)运行。"""
import argparse
from datetime import datetime, timezone
from decimal import Decimal
import json
from pathlib import Path
import re
from reader_core import execute, reconcile, report, read, load_config, finish_grade
TASKS = [
{ "id" : "invoice" , "prompt" : "两笔未付款项,分别为 3 x 12.50 美元和 2 x 4.25 美元。仅返回总和,保留两位小数。" , "expected" : "46.00" },
{ "id" : "utc" , "prompt" : "将 2026-10-18T10:30:00+02:00 转换为 UTC。仅返回 YYYY-MM-DDTHH:MM:SSZ 格式。" , "expected" : "2026-10-18T08:30:00Z" },
{ "id" : "refund" , "prompt" : "政策:仅当金额 <= 200 美元且天数 <= 30 天时批准。金额=200 美元;天数=30 天。仅返回 APPROVE 或 DENY。" , "expected" : "APPROVE" },
]
def refund_policy (amount, days):
return "APPROVE" if Decimal( str (amount)) <= 200 and days <= 30 else "DENY"
def grade (task, text, finish):
terminal = finish_grade(finish)
if terminal:
return terminal
if not isinstance (text, str ) or not text.strip():
return { "passed" : False , "classification" : "empty" }
text = text.strip()
patterns = { "invoice" : r " \d + . \d {2} " ,
"utc" : r " \d {4} - \d {2} - \d {2} T \d {2} : \d {2} : \d {2} Z " ,
"refund" : r " APPROVE | DENY " }
valid = bool (re.fullmatch(patterns.get(task[ "id" ], r " \d + . \d {2} " ), text))
passed = valid and text == task[ "expected" ] and finish == "stop"
return { "passed" : passed, "classification" : "pass" if passed else
( "incorrect" if valid else "malformed" )}
在使用分数之前,请检查其参考标准和拒绝规则。这些离线测试用例涵盖边界决策、无效格式和截断的答案,无需调用模型。
def offline ():
money = Decimal( 3 ) * Decimal( "12.50" ) + Decimal( 2 ) * Decimal( "4.25" )
assert format (money, ".2f" ) == TASKS [ 0 ][ "expected" ]
utc = datetime.fromisoformat( "2026-10-18T10:30:00+02:00" )
assert utc.astimezone(timezone.utc).strftime( "%Y-%m- %d T%H:%M:%SZ" ) == TASKS [ 1 ][ "expected" ]
assert refund_policy( 200 , 30 ) == TASKS [ 2 ][ "expected" ]
for amount, days, expected in [( 200.01 , 30 , "DENY" ), ( 200 , 31 , "DENY" ),
( 199.99 , 29 , "APPROVE" ), ( 0 , 0 , "APPROVE" )]:
assert refund_policy(amount, days) == expected
for task in TASKS :
assert grade(task, task[ "expected" ], "stop" )[ "passed" ]
for bad in ( "wrong" , None , "" , '{"answer": 46}' , "APPROVE please" ):
assert not grade(task, bad, "stop" )[ "passed" ]
assert not grade(task, task[ "expected" ], "length" )[ "passed" ]
assert not grade( TASKS [ 0 ], "47.00" , "stop" )[ "passed" ]
assert not grade( TASKS [ 2 ], "DENY" , "stop" )[ "passed" ]
print ( "OFFLINE reference and grader checks passed; zero inference calls." )
将检查与消耗分开。命令行界面默认为离线验证,在推理之前需要明确的实时选项和许可。
def main(tasks=None, grader=grade, default_config="demo-config.json", offline_check=None):
parser = argparse.ArgumentParser(description=doc)
parser.add_argument("operation", nargs="?", default="check",
choices=["check", "plan", "run", "report", "reconcile"])
parser.add_argument("--config", default=default_config)
parser.add_argument("--run-dir", type=Path, default=Path("runs/demo"))
parser.add_argument("--live", action="store_true")
parser.add_argument("--max-usd", default="0")
parser.add_argument("--resume", action="store_true")
parser.add_argument("--tasks", help="Optional exact-contract custom task JSON")
args = parser.parse_args()
if args.operation == "check":
if args.tasks:
parser.error("Use an example entry point with its own offline_check; check does not accept --tasks overrides")
if offline_check is not None:
offline_check()
elif tasks is not None or grader is not grade or args.tasks:
parser.error("Custom tasks/graders require offline_check=... for their own reference and fixture checks")
else:
offline()
return
selected = read(args.tasks) if args.tasks else (tasks if tasks is not None else TASKS)
config = load_config(args.config)
if args.operation == "report":
print(json.dumps(report(args.run_dir), indent=2))
elif args.operation == "reconcile":
reconcile(args.run_dir, live=args.live)
print(json.dumps(report(args.run_dir), indent=2))
else:
execute(args.run_dir, selected, config, grader, args.max_usd,
live=args.live, resume=args.resume, plan=args.operation == "plan")
if name == "main":
main()
配置和检查计划
使用提供的 Luna 配置来设置模型、重复次数、令牌配额以及提供商约束:
{
"models": [
"openai/gpt-6-luna"
],
"repeats": 1,
"max_tokens": 1024,
"settings": {
"openai/gpt-6-luna": {
"provider": {
"require_parameters": true,
"allow_fallbacks": true,
"max_price": {
"prompt": 0.09999999999999999,
"completion": 0.5,
"request": 0
}
},
"reasoning": {
"effort": "low"
}
}
}
}
Sol 的配置保留了重复/令牌设置,但使用了其自身的价格上限:
{
"models": [
"openai/gpt-6.1-sol"
],
"repeats": 1,
"max_tokens": 1024,
"settings": {
"openai/gpt-6.1-sol": {
"provider": {
"require_parameters": true,
"allow_fallbacks": true,
"max_price": {
"prompt": 2.0,
"completion": 10.0,
"request": 0
}
},
"reasoning": {
"effort": "low"
}
}
}
}
models 用于选择候选模型,repeats 指定每个任务的请求次数,max_tokens 设置完成令牌配额。推理过程可能会在可见输出之前消耗该配额。离线检查不会发出任何 API 调用。付费运行需要显式的 --live 标志。长度截断的响应在没有重试的情况下会失败。
价格上限以每百万令牌的美元计算;Luna 的提示上限约为 $0.10。如果提供商不再支持保存的设置,运行器必须停止,而不是静默地更改它们。提供商回退不会交换模型或重新发送推理请求。
python three_tasks.py plan --config luna-config.json
实际离线输出:
{ "planned_calls": 3, "max_tokens": 1024, "models": [ "openai/gpt-6-luna" ], "repeats": 1, "estimated_reservations_usd": "0.0023543749999999999565625" }
预留额度是本地成本估算,而非账户冻结或保证上限。在选择配额之前请先进行计划。
任务选择 调用次数 预估预留金额
Luna,三个任务 3 $0.0023544
Sol,三个任务 3 $0.0470875
Luna,下方的 JSON 任务 1 $0.00080725
Sol,下方的 JSON 任务 1 $0.016145
更改任务、重复次数或令牌数量会改变估算值。如果支出超过估算值,脚本将停止发送新请求。
进行小额付费运行
在 API-key settings 中创建密钥,添加余额,并配置合适的密钥限制。在终端中本地设置该变量。
PowerShell:
$env:OPENROUTER_API_KEY = "YOUR_OPENROUTER_API_KEY"
Bash 或 Zsh:
export OPENROUTER_API_KEY = "YOUR_OPENROUTER_API_KEY"
如果已配置,请复用现有变量。该包不会加载 .env 文件。对于随附的三任务 Luna 配置:
python three_tasks.py run --config luna-config.json --run-dir runs/my-luna --live --max-usd 0.01
python three_tasks.py reconcile --run-dir runs/my-luna --live
python three_tasks.py report --run-dir runs/my-luna
对账操作执行只读的生成元数据查找。报告展示响应覆盖率,即已完成响应数除以计划试验数,以及通过/已评分、失败、已验证成本和中间请求时间。在账单得到验证之前,报告中的成本将保持未解决状态。请求时间不包括评分和元数据处理;它不是首字延迟时间。
实时结果会有所不同。下面的合成示例仅用于说明报告功能,而非模型性能测量。
步骤 4. 添加您自己的任务和评分器
提供的 custom-tasks.json 展示了任务格式:
[
{
"id" : "custom-total" ,
"prompt" : "Four items cost 12.50 USD each. Return only the total with exactly two decimals." ,
"expected" : "50.00"
}
]
python custom_task.py check 独立计算其参考值,并测试正确、错误和格式错误的回答。自定义货币 ID 使用两位小数评分器。另一个合约需要其自己的评分器和检查逻辑。
完整的 json_extraction.py 分三部分按文件顺序列出。它允许 JSON 空白符和键顺序的差异,但会拒绝缺失、多余或重复的键以及错误的类型。具有正确模式但值错误的数据对象被视为不正确。过滤或异常终止的情况有单独的分类。
"""A complete exact-schema JSON extraction example; offline check by default."""
import json
from reader_core import finish_grade
from three_tasks import main
CUSTOMER_EMAIL = "mira@example.test"
ORDER_CODE = "A-104"
ITEM_COUNT = 3
SOURCE_TEXT = ( "Customer: Mira. Email: mira@example.test. Order: A-104. "
"Items: 3. Gift wrap: no." )
EXPECTED = { "email" : CUSTOMER_EMAIL , "order_id" : ORDER_CODE ,
"item_count" : ITEM_COUNT , "gift_wrap" : False }
TASKS = [{ "id" : "order-extraction" , "grader" : "exact-order-json-v1" ,
"prompt" : "Extract email, order_id, item_count and gift_wrap from this order. "
"Return a JSON object only, with exactly those keys. email and order_id "
"are strings; item_count is an integer; gift_wrap is a boolean. " + SOURCE_TEXT ,
"expected" : EXPECTED }]
仅靠 JSON 语法是不够的。拒绝重复的键和无效的数字值,然后在将字段与参考值进行比较之前验证模式。
def strict_json (text):
def pairs (items):
result = {}
for key, value in items:
if key in result:
raise ValueError ( "Duplicate JSON key" )
result[key] = value
return result
def nonfinite (value):
raise ValueError ( "Nonfinite JSON number" )
return json.loads(text, object_pairs_hook = pairs, parse_constant = nonfinite)
def grade (task, text, finish):
terminal = finish_grade(finish)
if terminal:
return terminal
if not isinstance (text, str ) or not text.strip():
return { "passed" : False , "classification" : "empty" }
try :
actual = strict_json(text)
except ( ValueError , TypeError ):
return { "passed" : False , "classification" : "malformed" }
types = { "email" : str , "order_id" : str , "item_count" : int , "gift_wrap" : bool }
schema_ok = ( type (actual) is dict and actual.keys() == types.keys()
and all ( type (actual[key]) is kind for key, kind in types.items()))
if not schema_ok:
return { "passed" : False , "classification" : "malformed" }
passed = actual == task[ "expected" ]
return { "passed" : passed, "classification" : "pass" if passed else "incorrect" }
同时检查接受和拒绝情况。这些测试用例区分了有效但错误的值与格式错误的输出,并验证过滤或截断不能算作通过。
CORRECT = '{"order_id":"A-104","email":"mira@example.test","gift_wrap":false,"item_count":3}'
WRONG = '{"email":"other@example.test","order_id":"A-104","item_count":3,"gift_wrap":false}'
MALFORMED = [ "not JSON" , 'json \n ' + CORRECT + ' \n' ,
'{"email":"mira@example.test"}' , CORRECT .replace( '3}' , 'true}' ),
CORRECT .replace( '3}' , '3.0}' ), CORRECT .replace( '3}' , 'NaN}' ),
CORRECT [: - 1 ] + ',"item_count":3}' , CORRECT [: - 1 ] + ',"extra":1}' ]
def offline ():
assert EXPECTED == { "email" : "mira@example.test" , "order_id" : "A-104" ,
"item_count" : 3 , "gift_wrap" : False }
assert f "Email: {CUSTOMER_EMAIL} ." in SOURCE_TEXT
assert f "Order: {ORDER_CODE} ." in SOURCE_TEXT
assert f "Items: {ITEM_COUNT} ." in SOURCE_TEXT and "Gift wrap: no." in SOURCE_TEXT
task = TASKS [ 0 ]
assert grade(task, CORRECT , "stop" )[ "passed" ]
assert grade(task, json.dumps( EXPECTED , indent = 2 ), "stop" )[ "passed" ]
assert grade(task, WRONG , "stop" )[ "classification" ] == "incorrect"
for text in MALFORMED :
assert grade(task, text, "stop" )[ "classification" ] == "malformed" , text
assert grade(task, "" , "stop" )[ "classification" ] == "empty"
assert grade(task, CORRECT , "content_filter" )[ "classification" ] == "content_filtered"
assert grade(task, CORRECT , "length" )[ "classification" ] == "truncated"
print ( "OFFLINE JSON extraction: independent source facts, schema, correct/wrong/malformed fixtures passed; zero requests." )
if name == "main" :
main( tasks = TASKS , grader = grade, offline_check = offline)
The final main(…) call connects tasks, grading, and reference checks to the runner. Adapt the source facts and expected fields, then run:
python json_extraction.py check
python json_extraction.py plan
Choose models using evidence from your application’s inputs and output formats. Run identical tasks through OpenRouter and compare graded accuracy, billed cost , and request time. On our 60 synthetic tasks, GPT-6.1 Sol passed 180/180 trials across three repeats under the tested contracts and settings.
TL;DR
Code checks measure correctness and output compliance.
Sol passed 180/180 trials on our synthetic set; DeepSeek had the lowest response cost, with 157/180 passes.
Agreement with the public ranking was weak, with a Spearman correlation of 0.109.
Before you trust a score, check how many times each task ran, how many answers came back, and whether each bill was verified.
Define the behavior first, then its checks.
Step 1. Write tasks with answers a script can check
A task needs an input, expected answer, and output contract. For invoices, specify included rows, rounding, and acceptable currency suffixes.
We wrote all 40 baseline tasks and 20 hard tasks before the final run.
Category Example Check
Invoice arithmetic Total unpaid rows after discounts Decimal total and rounding
Dates and schedules Convert a timestamp or list matching dates Exact instant or date list
Email extraction Extract fields into JSON Keys, types and values
Python functions Implement a function against hidden inputs Results in an isolated runtime
Output constraints Produce text within specified restrictions Length, vocabulary and format
Refund decisions Apply a written policy at its boundaries Decision for each order
Compute references independently. Separate prompt-tuning cases from final evaluation. Refund cases test written decisions, without executing transactions.
Step 2. Grade with code, and check the grader
Use exact matching for APPROVE, and schema/value checks for JSON. Normalize only permitted differences. Accepting prose around a number hides a failure when your consumer requires only a number.
Test known-correct, wrong, and malformed responses. For a refund threshold, include exactly $200 and 30 days, then values just above each boundary.
Our development checker rejected valid Python because it omitted ord and type. We corrected it before the final study, specifying CPython 3.12.10/WASI with resource limits. Otherwise, checker failures would have counted against models.
The full-study runner isolates generated code and stops if sandbox setup is missing. The teaching example executes no generated code.
Step 3. Run the three-task Python example
Download the companion ZIP . Before extracting it, compare its SHA-256 checksum with:
a38ee17a2eb7090f9f4849a605cc8214691c889ca0ae40c121259603592178e8
PowerShell:
Get-FileHash .\benchmark-reader-companion.zip -Algorithm SHA256
Linux or macOS:
sha256sum benchmark-reader-companion.zip
shasum -a 256 benchmark-reader-companion.zip
If the values differ, stop and check the download. After they match, extract the ZIP. You need Python 3.12 or later. The standard-library teaching runner, JSON example, and comparisons passed offline checks on Windows x64 and Linux. macOS remains untested. The bundled full-study sandbox and native Ori setup support Windows x64 only.
From the extracted folder:
python verify_package.py
python three_tasks.py check
The check prints OFFLINE reference and grader checks passed; zero inference calls. The complete script follows in file order. Its companion module handles requests, persistence, and reporting.
"""Three exact contracts; run from the extracted companion (standard library)."""
import argparse
from datetime import datetime, timezone
from decimal import Decimal
import json
from pathlib import Path
import re
from reader_core import execute, reconcile, report, read, load_config, finish_grade
TASKS = [
{ "id" : "invoice" , "prompt" : "Two unpaid lines cost 3 x 12.50 USD and 2 x 4.25 USD. Return only their total with exactly two decimal places." , "expected" : "46.00" },
{ "id" : "utc" , "prompt" : "Convert 2026-10-18T10:30:00+02:00 to UTC. Return only YYYY-MM-DDTHH:MM:SSZ." , "expected" : "2026-10-18T08:30:00Z" },
{ "id" : "refund" , "prompt" : "Policy: approve only if amount <= 200 USD and age <= 30 days. Amount=200 USD; age=30 days. Return only APPROVE or DENY." , "expected" : "APPROVE" },
]
def refund_policy (amount, days):
return "APPROVE" if Decimal( str (amount)) <= 200 and days <= 30 else "DENY"
def grade (task, text, finish):
terminal = finish_grade(finish)
if terminal:
return terminal
if not isinstance (text, str ) or not text.strip():
return { "passed" : False , "classification" : "empty" }
text = text.strip()
patterns = { "invoice" : r " \d + . \d {2} " ,
"utc" : r " \d {4} - \d {2} - \d {2} T \d {2} : \d {2} : \d {2} Z " ,
"refund" : r " APPROVE | DENY " }
valid = bool (re.fullmatch(patterns.get(task[ "id" ], r " \d + . \d {2} " ), text))
passed = valid and text == task[ "expected" ] and finish == "stop"
return { "passed" : passed, "classification" : "pass" if passed else
( "incorrect" if valid else "malformed" )}
Before using a score, check its reference and rejection rules. These offline fixtures cover boundary decisions, invalid formats, and truncated answers without calling a model.
def offline ():
money = Decimal( 3 ) * Decimal( "12.50" ) + Decimal( 2 ) * Decimal( "4.25" )
assert format (money, ".2f" ) == TASKS [ 0 ][ "expected" ]
utc = datetime.fromisoformat( "2026-10-18T10:30:00+02:00" )
assert utc.astimezone(timezone.utc).strftime( "%Y-%m- %d T%H:%M:%SZ" ) == TASKS [ 1 ][ "expected" ]
assert refund_policy( 200 , 30 ) == TASKS [ 2 ][ "expected" ]
for amount, days, expected in [( 200.01 , 30 , "DENY" ), ( 200 , 31 , "DENY" ),
( 199.99 , 29 , "APPROVE" ), ( 0 , 0 , "APPROVE" )]:
assert refund_policy(amount, days) == expected
for task in TASKS :
assert grade(task, task[ "expected" ], "stop" )[ "passed" ]
for bad in ( "wrong" , None , "" , '{"answer": 46}' , "APPROVE please" ):
assert not grade(task, bad, "stop" )[ "passed" ]
assert not grade(task, task[ "expected" ], "length" )[ "passed" ]
assert not grade( TASKS [ 0 ], "47.00" , "stop" )[ "passed" ]
assert not grade( TASKS [ 2 ], "DENY" , "stop" )[ "passed" ]
print ( "OFFLINE reference and grader checks passed; zero inference calls." )
Keep checking separate from spending. The command interface defaults to offline validation and requires an explicit live option and allowance before inference.
def main (tasks = None , grader = grade, default_config = "demo-config.json" , offline_check = None ):
parser = argparse.ArgumentParser( description = doc )
parser.add_argument( "operation" , nargs = "?" , default = "check" ,
choices = [ "check" , "plan" , "run" , "report" , "reconcile" ])
parser.add_argument( "--config" , default = default_config)
parser.add_argument( "--run-dir" , type = Path, default = Path( "runs/demo" ))
parser.add_argument( "--live" , action = "store_true" )
parser.add_argument( "--max-usd" , default = "0" )
parser.add_argument( "--resume" , action = "store_true" )
parser.add_argument( "--tasks" , help = "Optional exact-contract custom task JSON" )
args = parser.parse_args()
if args.operation == "check" :
if args.tasks:
parser.error( "Use an example entry point with its own offline_check; check does not accept --tasks overrides" )
if offline_check is not None :
offline_check()
elif tasks is not None or grader is not grade or args.tasks:
parser.error( "Custom tasks/graders require offline_check=... for their own reference and fixture checks" )
else :
offline()
return
selected = read(args.tasks) if args.tasks else (tasks if tasks is not None else TASKS )
config = load_config(args.config)
if args.operation == "report" :
print (json.dumps(report(args.run_dir), indent = 2 ))
elif args.operation == "reconcile" :
reconcile(args.run_dir, live = args.live)
print (json.dumps(report(args.run_dir), indent = 2 ))
else :
execute(args.run_dir, selected, config, grader, args.max_usd,
live = args.live, resume = args.resume, plan = args.operation == "plan" )
if name == "main" :
main()
Configure and inspect the plan
Use the supplied Luna configuration to set the model, repeat count, token allowance and provider constraints:
{
"models" : [
"openai/gpt-6-luna"
],
"repeats" : 1 ,
"max_tokens" : 1024 ,
"settings" : {
"openai/gpt-6-luna" : {
"provider" : {
"require_parameters" : true ,
"allow_fallbacks" : true ,
"max_price" : {
"prompt" : 0.09999999999999999 ,
"completion" : 0.5 ,
"request" : 0
}
},
"reasoning" : {
"effort" : "low"
}
}
}
}
Sol’s configuration preserves the repeat/token settings but uses its own price ceilings:
{
"models" : [
"openai/gpt-6.1-sol"
],
"repeats" : 1 ,
"max_tokens" : 1024 ,
"settings" : {
"openai/gpt-6.1-sol" : {
"provider" : {
"require_parameters" : true ,
"allow_fallbacks" : true ,
"max_price" : {
"prompt" : 2.0 ,
"completion" : 10.0 ,
"request" : 0
}
},
"reasoning" : {
"effort" : "low"
}
}
}
}
models selects candidates, repeats specifies requests per task, and max_tokens sets the completion allowance. Reasoning can consume that allowance before visible output. Offline checks make no API calls. Paid runs require the explicit —live flag. Length-truncated responses fail without retry.
Price ceilings use USD per million tokens; Luna’s prompt ceiling is approximately $0.10. If a provider no longer supports the saved settings, the runner must stop rather than silently change them. Provider fallback doesn’t swap models or resend inference.
python three_tasks.py plan --config luna-config.json
Actual offline output:
{ "planned_calls" : 3 , "max_tokens" : 1024 , "models" : [ "openai/gpt-6-luna" ], "repeats" : 1 , "estimated_reservations_usd" : "0.0023543749999999999565625" }
A reservation is a local cost estimate, not an account hold or guaranteed cap. Plan before choosing an allowance.
Teaching selection Calls Estimated reservations
Luna, three tasks 3 $0.0023544
Sol, three tasks 3 $0.0470875
Luna, JSON task below 1 $0.00080725
Sol, JSON task below 1 $0.016145
Changing tasks, repeats, or tokens changes the estimate. If spending goes over the estimate, the script stops sending new request.
Make a small paid run
Create a key in API-key settings , add credit , and configure a suitable key limit. Set the variable locally in your terminal.
PowerShell:
$env:OPENROUTER_API_KEY = "YOUR_OPENROUTER_API_KEY"
Bash or Zsh:
export OPENROUTER_API_KEY = "YOUR_OPENROUTER_API_KEY"
Reuse an existing variable if configured. The package doesn’t load .env. For the shipped three-task Luna configuration:
python three_tasks.py run --config luna-config.json --run-dir runs/my-luna --live --max-usd 0.01
python three_tasks.py reconcile --run-dir runs/my-luna --live
python three_tasks.py report --run-dir runs/my-luna
Reconciliation performs read-only generation metadata lookups. Reports show response coverage, meaning completed responses divided by planned trials, plus passes/graded, failures, verified cost, and median request time. Until a bill is verified, the report keeps its cost unresolved. Request time excludes grading and metadata; it’s not time to first token.
Live results vary. Synthetic examples below illustrate reporting, not model measurements.
Step 4. Add your own task and grader
The supplied custom-tasks.json shows the task format:
[
{
"id" : "custom-total" ,
"prompt" : "Four items cost 12.50 USD each. Return only the total with exactly two decimals." ,
"expected" : "50.00"
}
]
python custom_task.py check independently computes its reference with Decimal and tests correct, wrong, and malformed answers. Custom money IDs use the two-decimal grader. Another contract needs its own grader and checks.
The complete json_extraction.py follows in three parts, in file order. It permits JSON whitespace and key-order differences, but rejects missing, extra, or duplicate keys and wrong types. A schema-valid object with a wrong value is incorrect. Filtered or abnormal finishes have separate classifications.
"""A complete exact-schema JSON extraction example; offline check by default."""
import json
from reader_core import finish_grade
from three_tasks import main
CUSTOMER_EMAIL = "mira@example.test"
ORDER_CODE = "A-104"
ITEM_COUNT = 3
SOURCE_TEXT = ( "Customer: Mira. Email: mira@example.test. Order: A-104. "
"Items: 3. Gift wrap: no." )
EXPECTED = { "email" : CUSTOMER_EMAIL , "order_id" : ORDER_CODE ,
"item_count" : ITEM_COUNT , "gift_wrap" : False }
TASKS = [{ "id" : "order-extraction" , "grader" : "exact-order-json-v1" ,
"prompt" : "Extract email, order_id, item_count and gift_wrap from this order. "
"Return a JSON object only, with exactly those keys. email and order_id "
"are strings; item_count is an integer; gift_wrap is a boolean. " + SOURCE_TEXT ,
"expected" : EXPECTED }]
JSON syntax alone is insufficient. Reject duplicate keys and invalid number values, then validate the schema before comparing fields with the reference.
def strict_json (text):
def pairs (items):
result = {}
for key, value in items:
if key in result:
raise ValueError ( "Duplicate JSON key" )
result[key] = value
return result
def nonfinite (value):
raise ValueError ( "Nonfinite JSON number" )
return json.loads(text, object_pairs_hook = pairs, parse_constant = nonfinite)
def grade (task, text, finish):
terminal = finish_grade(finish)
if terminal:
return terminal
if not isinstance (text, str ) or not text.strip():
return { "passed" : False , "classification" : "empty" }
try :
actual = strict_json(text)
except ( ValueError , TypeError ):
return { "passed" : False , "classification" : "malformed" }
types = { "email" : str , "order_id" : str , "item_count" : int , "gift_wrap" : bool }
schema_ok = ( type (actual) is dict and actual.keys() == types.keys()
and all ( type (actual[key]) is kind for key, kind in types.items()))
if not schema_ok:
return { "passed" : False , "classification" : "malformed" }
passed = actual == task[ "expected" ]
return { "passed" : passed, "classification" : "pass" if passed else "incorrect" }
Check both acceptance and rejection. These fixtures distinguish valid but wrong values from malformed output, and verify that filtering or truncation can’t count as a pass.
CORRECT = '{"order_id":"A-104","email":"mira@example.test","gift_wrap":false,"item_count":3}'
WRONG = '{"email":"other@example.test","order_id":"A-104","item_count":3,"gift_wrap":false}'
MALFORMED = [ "not JSON" , 'json \n ' + CORRECT + ' \n' ,
'{"email":"mira@example.test"}' , CORRECT .replace( '3}' , 'true}' ),
CORRECT .replace( '3}' , '3.0}' ), CORRECT .replace( '3}' , 'NaN}' ),
CORRECT [: - 1 ] + ',"item_count":3}' , CORRECT [: - 1 ] + ',"extra":1}' ]
def offline ():
assert EXPECTED == { "email" : "mira@example.test" , "order_id" : "A-104" ,
"item_count" : 3 , "gift_wrap" : False }
assert f "Email: {CUSTOMER_EMAIL} ." in SOURCE_TEXT
assert f "Order: {ORDER_CODE} ." in SOURCE_TEXT
assert f "Items: {ITEM_COUNT} ." in SOURCE_TEXT and "Gift wrap: no." in SOURCE_TEXT
task = TASKS [ 0 ]
assert grade(task, CORRECT , "stop" )[ "passed" ]
assert grade(task, json.dumps( EXPECTED , indent = 2 ), "stop" )[ "passed" ]
assert grade(task, WRONG , "stop" )[ "classification" ] == "incorrect"
for text in MALFORMED :
assert grade(task, text, "stop" )[ "classification" ] == "malformed" , text
assert grade(task, "" , "stop" )[ "classification" ] == "empty"
assert grade(task, CORRECT , "content_filter" )[ "classification" ] == "content_filtered"
assert grade(task, CORRECT , "length" )[ "classification" ] == "truncated"
print ( "OFFLINE JSON extraction: independent source facts, schema, correct/wrong/malformed fixtures passed; zero requests." )
if name == "main" :
main( tasks = TASKS , grader = grade, offline_check = offline)
The final main(…) call connects tasks, grading, and reference checks to the runner. Adapt the source facts and expected fields, then run:
python json_extraction.py check
python json_extraction.py plan
| 刊期 | 得分 | 排名 | 结果 |
|---|---|---|---|
| 2026-11-25 | 8.4 | 32 | 未入选 |
| 2026-11-24 | 8.4 | 30 | 未入选 |
| 2026-11-16 | 8.49 | 14 | 入选 |
| 2026-11-15 | 8.77 | 23 | 未入选 |
| 2026-11-14 | 9.22 | 35 | 未入选 |
| 2026-11-13 | 9.95 | 31 | 未入选 |