Duplicate from Xubqpanda/HarnessGrad
Browse filesCo-authored-by: 徐步强 <Xubqpanda@users.noreply.huggingface.co>
This view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- Base_Harness/loop/agent.py +767 -0
- Base_Harness/loop/harness.json +12 -0
- Base_Harness/loop/requirements.txt +1 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/channel/round-0.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/channel/round-1.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/channel/round-2.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/cost.json +73 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/curve.jsonl +0 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-1-valid_seen.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-1-valid_train.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-1-valid_unseen.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-2-valid_seen.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-2-valid_train.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-2-valid_unseen.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-3-valid_seen.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-3-valid_train.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-3-valid_unseen.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-1-valid_seen.json +161 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-1-valid_train.json +221 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-1-valid_unseen.json +155 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-2-valid_seen.json +161 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-2-valid_train.json +221 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-2-valid_unseen.json +155 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-3-valid_seen.json +161 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-3-valid_train.json +221 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-3-valid_unseen.json +155 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-0/.gitignore +9 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-0/agent.py +767 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-0/harness.json +12 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-0/requirements.txt +1 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-1/.gitignore +9 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-1/agent.py +1399 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-1/harness.json +12 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-1/requirements.txt +1 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-2/.gitignore +9 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-2/agent.py +1491 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-2/harness.json +12 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-2/requirements.txt +1 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-3/.gitignore +9 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-3/agent.py +1491 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-3/harness.json +12 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-3/requirements.txt +1 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/meta/round-1.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/meta/round-2.tar.gz +3 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-1.json +14 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-1.patch +799 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-2.json +14 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-2.patch +178 -0
- Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-3.json +8 -0
.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*.tar.gz filter=lfs diff=lfs merge=lfs -text
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""The reference base harness: a minimal ReAct loop.
|
| 3 |
+
|
| 4 |
+
Deliberately the simplest thing that satisfies the contract in
|
| 5 |
+
`docs/writing_a_harness.md`. Its job is not to be strong -- it is to be:
|
| 6 |
+
|
| 7 |
+
1. a valid starting point that a method can improve, and
|
| 8 |
+
2. the proof that the contract is implementable at all.
|
| 9 |
+
|
| 10 |
+
A method may replace every file here. That is the point.
|
| 11 |
+
|
| 12 |
+
**What it ships, and why that changed.** This harness used to be a bare loop: no
|
| 13 |
+
context policy, no output bounding, no retries. That is still the design -- but
|
| 14 |
+
these mechanisms are now in it, and each is here because a measurement said the
|
| 15 |
+
bare loop could not be measured at all, not because a mechanism is nice to have:
|
| 16 |
+
|
| 17 |
+
* `PARSE_RETRIES`, `SUBMIT_RETRIES`, `FINISH_NUDGE_STEPS`, `REPEAT_NUDGE_LIMIT`
|
| 18 |
+
-- one unreadable reply, or one premature "I am done", used to end the whole
|
| 19 |
+
task. Measured: 73 of 266 runs reached the step cap with nothing submitted,
|
| 20 |
+
and one task died after exactly one model call.
|
| 21 |
+
* `OUTPUT_LIMIT`, `CONTEXT_CHAR_BUDGET` -- a command that printed a large file
|
| 22 |
+
left the next call over the model's context limit, which killed the task.
|
| 23 |
+
* line-buffered trace writes -- a block buffer meant a killed task lost its tail,
|
| 24 |
+
so "killed at step 30" and "never started" were the same record.
|
| 25 |
+
|
| 26 |
+
All of them are still named switches with an `HG_AGENT_*` override, so a method
|
| 27 |
+
may change or remove any of them; what a method adds *on top* is the measurement.
|
| 28 |
+
The values actually in force go into the trace (`harness_identity.config`, below)
|
| 29 |
+
and land on the curve point, because two runs of this same file at two different
|
| 30 |
+
step caps are two different harnesses and the file hash cannot tell them apart.
|
| 31 |
+
"""
|
| 32 |
+
from __future__ import annotations
|
| 33 |
+
|
| 34 |
+
import argparse
|
| 35 |
+
import json
|
| 36 |
+
import os
|
| 37 |
+
import shutil
|
| 38 |
+
import subprocess
|
| 39 |
+
import sys
|
| 40 |
+
import time
|
| 41 |
+
from pathlib import Path
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
#: How many model calls one task gets. **A floor on capability, not a tuning knob.**
|
| 45 |
+
#:
|
| 46 |
+
#: Measured at 8, on Terminal-Bench, 4 rounds x 5 tasks: four of the five tasks used all
|
| 47 |
+
#: eight and produced no graded artifact at all -- `build-pmars` was still installing
|
| 48 |
+
#: packages, `bn-fit-modify` had just finished installing pandas/numpy/sklearn and
|
| 49 |
+
#: printed one correlation matrix, `chess-best-move` had opened the PNG and never wrote
|
| 50 |
+
#: `/app/move.txt`. The score was 0.0 on every task in every round, which is not a weak
|
| 51 |
+
#: harness being measured: it is a floor effect, and a floor makes every method look
|
| 52 |
+
#: identical because there is no gradient for one to move.
|
| 53 |
+
#:
|
| 54 |
+
#: Raising this does not make the harness cleverer -- `legacy/adapters/harnessgrad_domain/`
|
| 55 |
+
#: already names this lever as the trap ("helps only if the model is already using the
|
| 56 |
+
#: steps it has"). Here the trace shows it *was* using them, which is exactly when the
|
| 57 |
+
#: lever is legitimate. What it costs is bounded by the task, not by this number: the
|
| 58 |
+
#: wall clock is capped by the environment's `agent_timeout_s` (900 s for most
|
| 59 |
+
#: Terminal-Bench tasks, 3600 s for `bn-fit-modify`). A step is fast (~0.2 s model round
|
| 60 |
+
#: trip through the local gateway), so the extra ceiling mostly buys back the steps that
|
| 61 |
+
#: environment setup eats. The loop still stops the moment the model answers -- the cap
|
| 62 |
+
#: is a ceiling, not a quota.
|
| 63 |
+
MAX_STEPS = int(os.environ.get("HG_AGENT_MAX_STEPS", "32"))
|
| 64 |
+
MAX_OUTPUT_TOKENS = int(os.environ.get("HG_AGENT_MAX_OUTPUT_TOKENS", "2048"))
|
| 65 |
+
if MAX_OUTPUT_TOKENS < 1:
|
| 66 |
+
raise ValueError("HG_AGENT_MAX_OUTPUT_TOKENS must be positive")
|
| 67 |
+
|
| 68 |
+
#: 模型说"我做完了"之后,允许它再被退回几次。
|
| 69 |
+
#:
|
| 70 |
+
#: 为什么需要这个:harness 以前**从不检查交付物**。模型回一句 {"answer": ...} 就被当成
|
| 71 |
+
#: 任务结束、退出循环。实测(2026-10-02,terminal_bench round 0):五道题的 agent 阶段是
|
| 72 |
+
#: 101s / 31s / 183s / **4.5s** / 105s —— 而步数上限是 32。4.5 秒等于一次模型调用就
|
| 73 |
+
#: "交卷"了,产物根本不存在;`cancel-async-tasks` 的判分因此是
|
| 74 |
+
#: `File /app/run.py does not exist`。
|
| 75 |
+
#:
|
| 76 |
+
#: 所以 0 分的机制不是"步数不够",而是"**harness 把模型说的完成当成了完成**"。
|
| 77 |
+
#: 一个会自己检查交付物、并把"文件不存在"退回给模型重试的 harness,才是这一步该有的样子。
|
| 78 |
+
SUBMIT_RETRIES = int(os.environ.get("HG_AGENT_SUBMIT_RETRIES", "2"))
|
| 79 |
+
|
| 80 |
+
#: 模型吐出一段**读不出动作**的回复之后,允许它再试几次。
|
| 81 |
+
#:
|
| 82 |
+
#: 和上面那条同源,方向相反:一条是"模型说做完了,但产物不在",一条是"模型说的话读不出
|
| 83 |
+
#: 动作"。两条以前都会让**整道题**结束。
|
| 84 |
+
#:
|
| 85 |
+
#: 为什么它必须由起点 harness 负责,而不是留给方法去发现 —— 这是数出来的,不是想出来的。
|
| 86 |
+
#: 统计所有跑道里"方法自己写了理由"的 35 个轮次:**16 个在修解析或格式容错**,而且几乎
|
| 87 |
+
#: 每条跑道的第一轮都在修它:
|
| 88 |
+
#:
|
| 89 |
+
#: `loop-terminal_bench-26452c` 五道题各只调了一次模型就死在
|
| 90 |
+
#: `parse_error: Extra data`(`calls: 1`),此后每一轮都从同一个不能用的 harness 出发;
|
| 91 |
+
#: `flash-three-1/2`、`deepseek-eigen-2`、`strong-model-1` 的第一/第二轮全都写成
|
| 92 |
+
#: "让一次读不懂的回复不再结束整道题"。
|
| 93 |
+
#:
|
| 94 |
+
#: 代价不只是浪费一轮。方法之间开始比"谁先想到修 parser":RRSI 的 leakage critic 两次把
|
| 95 |
+
#: 改 `_parse` 的候选判成 TASK-SPECIALIZATION / LEAKAGE 而拒绝,那一轮于是什么都没改。
|
| 96 |
+
#: 一个起点 harness 必须在被测量之前就活过一次跑题的回复,否则第一轮比较的不是解题能力,
|
| 97 |
+
#: 是管线运气。
|
| 98 |
+
PARSE_RETRIES = int(os.environ.get("HG_AGENT_PARSE_RETRIES", "2"))
|
| 99 |
+
|
| 100 |
+
#: 步数还剩这么多时,明确要求模型收尾。
|
| 101 |
+
#:
|
| 102 |
+
#: 数出来的,不是猜的:266 条历史轨迹里 **73 条(27%)跑满 32 步、一次都没交卷**,而那些
|
| 103 |
+
#: 轨迹的最后两步常常是同一条命令重复(抽样:`python /app/test_outputs.py 2>&1` 两次、
|
| 104 |
+
#: 同一条 `echo ... >` 两次、同一个 `cat > /app/run.py << 'EOF'` 两次)。那些任务不是
|
| 105 |
+
#: "做错了",是**没停下来交卷**:步数用完,`answer` 是空字符串,平台只能拿检查的判决当分数。
|
| 106 |
+
#: `improvers/skill.md` 早就把这条记成已知失败模式("预算用满、什么都没交"),但起点 harness
|
| 107 |
+
#: 一直没有对应动作。一个被测量的 harness 应该在预算耗尽前把话说完。
|
| 108 |
+
FINISH_NUDGE_STEPS = int(os.environ.get("HG_AGENT_FINISH_NUDGE_STEPS", "4"))
|
| 109 |
+
|
| 110 |
+
#: 同一条命令连续重复时提醒几次(每条跑道限量,免得把上下文塞满)。
|
| 111 |
+
REPEAT_NUDGE_LIMIT = int(os.environ.get("HG_AGENT_REPEAT_NUDGE_LIMIT", "2"))
|
| 112 |
+
|
| 113 |
+
#: 单条命令的输出进入消息历史时的字符上限。先压紧 JSON,再保留完整记录预览;
|
| 114 |
+
#: 纯文本留头尾。完整输出留在工作目录,模型可按需读取。
|
| 115 |
+
#:
|
| 116 |
+
#: 实测(2026-10-04,本地 9B,5 道题):**3 道题死于
|
| 117 |
+
#: `This model's maximum context length is 32768 tokens ... your prompt contains at least
|
| 118 |
+
#: 32769 input tokens`(BadRequestError 400)**。起点 harness 以前把每条命令的**完整**输出
|
| 119 |
+
#: 一直往历史里追加,永不截断:一道题里单条输出就有 11773 字符,装一次包、cat 一个大文件
|
| 120 |
+
#: 就够撞上 32k 的窗口。那不是模型的问题,是 harness 没有上下文管理。
|
| 121 |
+
OUTPUT_LIMIT = int(os.environ.get("HG_AGENT_OUTPUT_LIMIT", "4000"))
|
| 122 |
+
|
| 123 |
+
#: 消息历史(不含 system 与题面)的字符预算。按 4 字符 ≈ 1 token 粗估,60k 字符约 15k token,
|
| 124 |
+
#: 给 32k 窗口的模型留出输出空间。超了就丢**最旧的成对消息**,并在轨迹里记下丢了几条 ——
|
| 125 |
+
#: 一个悄悄改变模型所见历史的 harness,和一个被测量的 harness,不是同一件事。
|
| 126 |
+
CONTEXT_CHAR_BUDGET = int(os.environ.get("HG_AGENT_CONTEXT_CHARS", "60000"))
|
| 127 |
+
|
| 128 |
+
SYSTEM = """You are an agent solving a task in a working directory.
|
| 129 |
+
|
| 130 |
+
You have one tool: run a shell command.
|
| 131 |
+
|
| 132 |
+
Reply with EXACTLY one of:
|
| 133 |
+
{"tool": "bash", "command": "<shell command>"}
|
| 134 |
+
{"answer": "<your final answer>"}
|
| 135 |
+
|
| 136 |
+
For a structured final answer, "answer" may be a JSON object containing the task's
|
| 137 |
+
prediction fields.
|
| 138 |
+
|
| 139 |
+
Rules:
|
| 140 |
+
- One action per reply. No prose outside the JSON.
|
| 141 |
+
- Keep commands concise. Use a loop or a script instead of enumerating many calls.
|
| 142 |
+
- To inspect files use shell commands (ls, cat, grep, ...).
|
| 143 |
+
- Give the final answer only when you are confident.
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
# ---------------------------------------------------------------- backends ---
|
| 148 |
+
|
| 149 |
+
def _backend() -> str:
|
| 150 |
+
"""Which completion backend to use.
|
| 151 |
+
|
| 152 |
+
`mock` exists so the framework can be exercised end-to-end with zero network
|
| 153 |
+
and zero cost. Any real curve must declare its backend and model on the curve
|
| 154 |
+
point (INTERFACE.md §3, `identity.agent_model`).
|
| 155 |
+
"""
|
| 156 |
+
return os.environ.get("HG_AGENT_BACKEND", "mock")
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def _call_mock(messages: list[dict]) -> str:
|
| 160 |
+
"""Deterministic stand-in: read answer.txt if present, else list the dir."""
|
| 161 |
+
task_text = messages[1]["content"] if len(messages) > 1 else ""
|
| 162 |
+
if "answer.txt exists" in task_text or "already" in task_text:
|
| 163 |
+
return json.dumps({"answer": "READ_FROM_FILE"})
|
| 164 |
+
return json.dumps({"tool": "bash", "command": "ls -a"})
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
# --------------------------------------------------------------- usage ---
|
| 168 |
+
|
| 169 |
+
#: Token usage accumulated over the run, filled by whichever backend is active.
|
| 170 |
+
#: Read into the trace at the end. Recorded because a mechanism that spends model
|
| 171 |
+
#: calls (history_summary does) is only comparable against a free one if the
|
| 172 |
+
#: spend is visible -- and because a harness whose cost is unknown cannot be
|
| 173 |
+
#: ranked against a cheaper one that scores the same.
|
| 174 |
+
#: `context_trims` 单独计数:它是"模型拒绝了这条 prompt,于是我们削短了历史"的次数。
|
| 175 |
+
#: 和 `retries`(网络/限流)不同 —— 那一种重试发的是同一条 prompt,这一种发的是**更短的**
|
| 176 |
+
#: 一条,模型看到的历史因此和上一步不同。要能分开,才能解释"那一步为什么换了做法"。
|
| 177 |
+
USAGE = {"calls": 0, "input_tokens": 0, "output_tokens": 0, "retries": 0,
|
| 178 |
+
"context_trims": 0}
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def _record_usage(usage) -> None:
|
| 182 |
+
"""Fold provider token counts into the run's total.
|
| 183 |
+
|
| 184 |
+
The call count is NOT incremented here: it is incremented by `_complete`,
|
| 185 |
+
which is the one place every model call goes through. Counting calls at the
|
| 186 |
+
provider boundary would miss the mock backend entirely -- and a mechanism that
|
| 187 |
+
spends model calls on a mock run would then report zero cost, which is exactly
|
| 188 |
+
the invisible-spend the usage block exists to prevent.
|
| 189 |
+
"""
|
| 190 |
+
if usage is None:
|
| 191 |
+
return
|
| 192 |
+
# Provider fields that are absent stay absent rather than becoming zero: a
|
| 193 |
+
# zero that means "not reported" is indistinguishable from a real zero.
|
| 194 |
+
for attr, key in (("prompt_tokens", "input_tokens"),
|
| 195 |
+
("completion_tokens", "output_tokens")):
|
| 196 |
+
v = getattr(usage, attr, None)
|
| 197 |
+
if isinstance(v, int):
|
| 198 |
+
USAGE[key] += v
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def _call_openai(messages: list[dict]) -> str:
|
| 202 |
+
"""One completion, with a deadline and bounded retries.
|
| 203 |
+
|
| 204 |
+
A harness that dies on a transient provider error loses a whole task run, and
|
| 205 |
+
an unbounded retry loop turns a provider outage into a hung experiment. Both
|
| 206 |
+
failures are silent in a batch unless the harness is defensive here.
|
| 207 |
+
"""
|
| 208 |
+
from openai import OpenAI
|
| 209 |
+
|
| 210 |
+
# **每次请求用一条新连接,不复用。** 不是性能取舍,是正确性:
|
| 211 |
+
#
|
| 212 |
+
# 实测(2026-10-02,容器内复现):vLLM 的 uvicorn 默认 5 秒关掉空闲 keep-alive,而
|
| 213 |
+
# 容器到模型之间还有平台发布的一层字节转发网关,它在上游 EOF 时会把 EOF 半关到
|
| 214 |
+
# 客户端。于是"跑一条几十秒的命令、再发起下一次模型调用"就必然复用一条死连接 ——
|
| 215 |
+
# `RemoteDisconnected` → openai 报 `APIConnectionError: Connection error`。
|
| 216 |
+
# 实测那一次,两道题(跑 pandas 的、跑 PIL 的)就是这样死的,而平台把它们记成了 0 分。
|
| 217 |
+
#
|
| 218 |
+
# keep-alive 本身是 HTTP 客户端的正常行为,所以这是网关的缺陷(见 eval/modelgate.py);
|
| 219 |
+
# 但一个 harness 不该把自己的测量押在"中间那一层是否正确处理空闲连接"上。一次本地
|
| 220 |
+
# TCP 握手的代价可以忽略。
|
| 221 |
+
#
|
| 222 |
+
# **用 `default_headers`,不要 import httpx。** 第一版写的是
|
| 223 |
+
# `http_client=httpx.Client(...)`,结果是每次调用都 `ModuleNotFoundError: No module
|
| 224 |
+
# named 'httpx'` —— 这个平台的 harness 依赖由覆盖层提供,而这里 `openai` 3.22.1 依赖的
|
| 225 |
+
# 是 `httpx2`(不是 `httpx`)。所以"顺手 import 一个我以为在的库"在这条路上是错的:
|
| 226 |
+
# 唯一可以依赖的是 `requirements.txt` 声明的那个发行包自己的接口。
|
| 227 |
+
client = OpenAI(
|
| 228 |
+
base_url=os.environ["HG_AGENT_BASE_URL"],
|
| 229 |
+
api_key=os.environ["HG_AGENT_API_KEY"],
|
| 230 |
+
timeout=float(os.environ.get("HG_AGENT_TIMEOUT_S", "180")),
|
| 231 |
+
max_retries=0, # retried here, so the count is ours to record
|
| 232 |
+
default_headers={"Connection": "close"},
|
| 233 |
+
)
|
| 234 |
+
model = os.environ["HG_AGENT_MODEL"]
|
| 235 |
+
attempts = int(os.environ.get("HG_AGENT_RETRIES", "3"))
|
| 236 |
+
last: Exception | None = None
|
| 237 |
+
|
| 238 |
+
for attempt in range(attempts):
|
| 239 |
+
try:
|
| 240 |
+
resp = client.chat.completions.create(
|
| 241 |
+
model=model, messages=messages, temperature=0.0,
|
| 242 |
+
max_tokens=MAX_OUTPUT_TOKENS,
|
| 243 |
+
)
|
| 244 |
+
_record_usage(getattr(resp, "usage", None))
|
| 245 |
+
return resp.choices[0].message.content or ""
|
| 246 |
+
except Exception as exc: # noqa: BLE001
|
| 247 |
+
last = exc
|
| 248 |
+
# **历史太长是可恢复的,以前不是。** 实测(2026-10-04):`git-leak-recovery` 和
|
| 249 |
+
# `regex-chess` 死在 `maximum context length is 32768 tokens ... at least 32769
|
| 250 |
+
# input tokens`,而两道题之前都已经跑了十几步的有效功。字符预算挡不住它
|
| 251 |
+
# (见 `_trim_history`),所以这里按模型自己的拒绝削一半历史再试一次 —— 削掉的
|
| 252 |
+
# 步数记进 `USAGE["context_trims"]`,由主循环写进 trace,不是悄悄改历史。
|
| 253 |
+
if any(marker in str(exc) for marker in _CONTEXT_ERROR_MARKERS) \
|
| 254 |
+
and len(messages) > 4 and attempt + 1 < attempts:
|
| 255 |
+
dropped = _trim_history(messages, budget=(CONTEXT_CHAR_BUDGET // 2))
|
| 256 |
+
if not dropped:
|
| 257 |
+
dropped = _trim_history(messages, budget=1)
|
| 258 |
+
USAGE["context_trims"] += 1
|
| 259 |
+
USAGE["retries"] += 1
|
| 260 |
+
continue
|
| 261 |
+
if attempt + 1 < attempts:
|
| 262 |
+
USAGE["retries"] += 1
|
| 263 |
+
time.sleep(min(2 ** attempt, 30))
|
| 264 |
+
# Out of attempts: raise, so the caller records a harness failure rather than
|
| 265 |
+
# scoring an empty answer as a wrong one.
|
| 266 |
+
raise RuntimeError(f"{attempts} attempts failed, last: {last}") from last
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
def _complete(messages: list[dict]) -> str:
|
| 270 |
+
"""Every model call in this harness goes through here, so this is where the
|
| 271 |
+
count is kept. Counting anywhere else means some caller is invisible."""
|
| 272 |
+
USAGE["calls"] += 1
|
| 273 |
+
return _call_mock(messages) if _backend() == "mock" else _call_openai(messages)
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
# ------------------------------------------------------------- the loop -----
|
| 277 |
+
|
| 278 |
+
class _Action(dict):
|
| 279 |
+
"""A parsed action, plus what the parser had to repair to get it.
|
| 280 |
+
|
| 281 |
+
An attribute rather than a second return value, because every caller wants the
|
| 282 |
+
dict and only one wants the repair note. `duplicates` empty means the reply was
|
| 283 |
+
well formed and nothing was guessed.
|
| 284 |
+
"""
|
| 285 |
+
duplicates: tuple[str, ...] = ()
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
def _first_key_wins(pairs):
|
| 289 |
+
"""Duplicated JSON keys: keep the **first** value, and say which keys repeated.
|
| 290 |
+
|
| 291 |
+
**This is measured, not defensive.** The local 9B (Qwen3.5-9B) writes a file like
|
| 292 |
+
this, and it is the whole reason `cancel-async-tasks` scored 0.0 in
|
| 293 |
+
`local-floor-9`:
|
| 294 |
+
|
| 295 |
+
{"tool": "bash", "command": "cat > /app/run.py << 'EOF'\n...\nEOF\n", "command": ""}
|
| 296 |
+
|
| 297 |
+
The real command is there, and then the model appends `, "command": ""`. JSON says
|
| 298 |
+
a duplicate key keeps the **last** value, so `json.loads` (and `raw_decode`) handed
|
| 299 |
+
the harness an empty command. The harness then ran the empty string -- exit 0, no
|
| 300 |
+
output -- and told the model `exit=0`. The model read that as success, answered
|
| 301 |
+
"the file /app/run.py has been created", and the verifier found no file. All 16
|
| 302 |
+
steps of that trajectory are the model writing the file, being told it worked, and
|
| 303 |
+
checking. Not one step of it wrote anything.
|
| 304 |
+
|
| 305 |
+
Taking the first value is the repair that matches intent here: the long command is
|
| 306 |
+
what the model meant, and the trailing `""` is noise from the same malformation
|
| 307 |
+
that produces its stray braces. It is recorded (`duplicate_keys` in the trace)
|
| 308 |
+
because a harness that silently rewrites the model's action and one that does not
|
| 309 |
+
are different harnesses.
|
| 310 |
+
"""
|
| 311 |
+
action = _Action()
|
| 312 |
+
repeated: list[str] = []
|
| 313 |
+
for key, value in pairs:
|
| 314 |
+
if key in action:
|
| 315 |
+
repeated.append(key)
|
| 316 |
+
continue
|
| 317 |
+
action[key] = value
|
| 318 |
+
if repeated:
|
| 319 |
+
action.duplicates = tuple(repeated)
|
| 320 |
+
return action
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def _json_block_end(text: str, start: int) -> int:
|
| 324 |
+
"""Skip a malformed JSON block without treating its strings as actions."""
|
| 325 |
+
depth = 0
|
| 326 |
+
quoted = escaped = False
|
| 327 |
+
for i in range(start, len(text)):
|
| 328 |
+
ch = text[i]
|
| 329 |
+
if quoted:
|
| 330 |
+
if escaped:
|
| 331 |
+
escaped = False
|
| 332 |
+
elif ch == "\\":
|
| 333 |
+
escaped = True
|
| 334 |
+
elif ch == '"':
|
| 335 |
+
quoted = False
|
| 336 |
+
elif ch == '"':
|
| 337 |
+
quoted = True
|
| 338 |
+
elif ch in "{[":
|
| 339 |
+
depth += 1
|
| 340 |
+
elif ch in "}]":
|
| 341 |
+
depth -= 1
|
| 342 |
+
if depth == 0:
|
| 343 |
+
return i + 1
|
| 344 |
+
return len(text)
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def _parse(reply: str) -> dict:
|
| 348 |
+
"""First complete action, across prose/fences and preceding structured data.
|
| 349 |
+
|
| 350 |
+
Consume whole JSON blocks, so nested data and quoted example actions cannot
|
| 351 |
+
become commands. Never close a truncated command or execute its prefix.
|
| 352 |
+
"""
|
| 353 |
+
decoder = json.JSONDecoder(object_pairs_hook=_first_key_wins)
|
| 354 |
+
i = 0
|
| 355 |
+
while i < len(reply):
|
| 356 |
+
if reply[i] not in "{[":
|
| 357 |
+
i += 1
|
| 358 |
+
continue
|
| 359 |
+
try:
|
| 360 |
+
obj, end = decoder.raw_decode(reply, i)
|
| 361 |
+
except json.JSONDecodeError:
|
| 362 |
+
i = _json_block_end(reply, i)
|
| 363 |
+
continue
|
| 364 |
+
i = end
|
| 365 |
+
if not isinstance(obj, dict) or obj.get("tool", "bash") != "bash":
|
| 366 |
+
continue
|
| 367 |
+
cmd = obj.get("command", "")
|
| 368 |
+
if isinstance(cmd, str) and cmd.strip():
|
| 369 |
+
return obj
|
| 370 |
+
if cmd == "" and "answer" in obj:
|
| 371 |
+
# An outer action can be valid JSON while its answer contains broken
|
| 372 |
+
# inner JSON. Reject it here so the ordinary parse retry can recover.
|
| 373 |
+
_answer_text(obj["answer"])
|
| 374 |
+
return obj
|
| 375 |
+
raise ValueError("no complete JSON action found in reply")
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
def _answer_text(value: object) -> str:
|
| 379 |
+
"""Transport a final answer without inventing or dropping prediction fields.
|
| 380 |
+
|
| 381 |
+
Schema validation belongs to the task's verifier. This only checks transport:
|
| 382 |
+
objects must stay JSON (str(dict) produces Python syntax), and JSON-looking
|
| 383 |
+
strings must be complete. Never close truncated JSON or reinterpret literals.
|
| 384 |
+
"""
|
| 385 |
+
if isinstance(value, dict):
|
| 386 |
+
return json.dumps(value, ensure_ascii=False, allow_nan=False)
|
| 387 |
+
if not isinstance(value, str):
|
| 388 |
+
raise ValueError("final answer must be a string or a JSON object")
|
| 389 |
+
if value.lstrip().startswith("{"):
|
| 390 |
+
try:
|
| 391 |
+
json.loads(value)
|
| 392 |
+
except ValueError as exc:
|
| 393 |
+
raise ValueError(f"final answer contains malformed JSON: {exc}") from exc
|
| 394 |
+
return value
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
#: goal 里形如 `/app/move.txt`、`/app/learned_dag.csv` 的路径。这是**通用**的:
|
| 398 |
+
#: 它不针对任何一道题,只看题面自己说了要写到哪个文件。
|
| 399 |
+
_PATH_RE = __import__("re").compile(r"/[A-Za-z0-9_./-]+\.[A-Za-z0-9]{1,6}\b")
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
def _missing_deliverables(task: dict, workdir: Path) -> list[str]:
|
| 403 |
+
"""题面点名要写、但现在**不存在**的文件。
|
| 404 |
+
|
| 405 |
+
这是 `loop` 自带的交卷闸门,刻意做成通用的两条:
|
| 406 |
+
|
| 407 |
+
* 只看题面(goal)里写出来的绝对路径 —— harness 没有任何途径知道判分脚本要什么
|
| 408 |
+
(`task.json` 里只有 goal),所以它只能相信题面;
|
| 409 |
+
* 只做 `exists` 检查,不执行任何东西。
|
| 410 |
+
|
| 411 |
+
题面没提路径(比如"回答一个问题")时返回空列表,闸门不生效 —— 这时判断对错是平台
|
| 412 |
+
的事,harness 不该假装知道。
|
| 413 |
+
"""
|
| 414 |
+
goal = str(task.get("goal") or "")
|
| 415 |
+
wanted = {m for m in _PATH_RE.findall(goal)}
|
| 416 |
+
missing = []
|
| 417 |
+
for raw in sorted(wanted):
|
| 418 |
+
# 容器里绝对路径就是它自己;宿主上则落在 workdir 之内。两种都查,取存在的那个。
|
| 419 |
+
candidates = [Path(raw)]
|
| 420 |
+
try:
|
| 421 |
+
candidates.append(workdir / Path(raw).relative_to("/app"))
|
| 422 |
+
except ValueError:
|
| 423 |
+
pass
|
| 424 |
+
if not any(c.exists() for c in candidates):
|
| 425 |
+
missing.append(raw)
|
| 426 |
+
return missing
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
def _clip_text(out: str, limit: int) -> str:
|
| 430 |
+
if len(out) <= limit:
|
| 431 |
+
return out
|
| 432 |
+
marker = f"\n... [text clipped; original {len(out)} characters] ...\n"
|
| 433 |
+
room = max(0, limit - len(marker))
|
| 434 |
+
head = (room + 1) // 2
|
| 435 |
+
tail = room // 2
|
| 436 |
+
return (out[:head] + marker + (out[-tail:] if tail else ""))[:limit]
|
| 437 |
+
|
| 438 |
+
|
| 439 |
+
def _json_preview(value: list | dict, limit: int) -> str | None:
|
| 440 |
+
"""A bounded, valid JSON preview containing whole first/last entries."""
|
| 441 |
+
mapping = isinstance(value, dict)
|
| 442 |
+
items = list(value.items()) if mapping else value
|
| 443 |
+
head, tail = [], []
|
| 444 |
+
|
| 445 |
+
def render():
|
| 446 |
+
return json.dumps({"_harness_preview": {
|
| 447 |
+
"total_items": len(items), "omitted_items": len(items) - len(head) - len(tail)},
|
| 448 |
+
"head": dict(head) if mapping else head,
|
| 449 |
+
"tail": dict(tail) if mapping else tail}, ensure_ascii=False, separators=(",", ":"))
|
| 450 |
+
|
| 451 |
+
shown = render()
|
| 452 |
+
if len(shown) > limit:
|
| 453 |
+
return None
|
| 454 |
+
front, back = 0, len(items) - 1
|
| 455 |
+
while front <= back:
|
| 456 |
+
added = False
|
| 457 |
+
head.append(items[front])
|
| 458 |
+
candidate = render()
|
| 459 |
+
if len(candidate) <= limit:
|
| 460 |
+
shown = candidate
|
| 461 |
+
front += 1
|
| 462 |
+
added = True
|
| 463 |
+
else:
|
| 464 |
+
head.pop()
|
| 465 |
+
if front <= back:
|
| 466 |
+
tail.insert(0, items[back])
|
| 467 |
+
candidate = render()
|
| 468 |
+
if len(candidate) <= limit:
|
| 469 |
+
shown = candidate
|
| 470 |
+
back -= 1
|
| 471 |
+
added = True
|
| 472 |
+
else:
|
| 473 |
+
tail.pop(0)
|
| 474 |
+
if not added:
|
| 475 |
+
break
|
| 476 |
+
return shown
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
def _clip_output(out: str) -> str:
|
| 480 |
+
"""Compact leading JSON losslessly before bounding; retain whole list items.
|
| 481 |
+
|
| 482 |
+
Non-JSON suffixes (including shell errors) remain visible. The caller saves
|
| 483 |
+
the original separately whenever this view differs from the output.
|
| 484 |
+
"""
|
| 485 |
+
if len(out) <= OUTPUT_LIMIT:
|
| 486 |
+
return out
|
| 487 |
+
stripped = out.lstrip()
|
| 488 |
+
try:
|
| 489 |
+
obj, end = json.JSONDecoder().raw_decode(stripped)
|
| 490 |
+
except (ValueError, RecursionError):
|
| 491 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 492 |
+
if not isinstance(obj, (dict, list)):
|
| 493 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 494 |
+
suffix = stripped[end:]
|
| 495 |
+
compact = json.dumps(obj, ensure_ascii=False, separators=(",", ":")) + suffix
|
| 496 |
+
if len(compact) <= OUTPUT_LIMIT:
|
| 497 |
+
return compact
|
| 498 |
+
preview = _json_preview(obj, OUTPUT_LIMIT - len(suffix))
|
| 499 |
+
if preview is not None:
|
| 500 |
+
return preview + suffix
|
| 501 |
+
return _clip_text(compact, OUTPUT_LIMIT)
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
def _shell_runtime() -> tuple[str, str]:
|
| 505 |
+
"""Choose once before any task action; never retry side effects in another shell."""
|
| 506 |
+
bash = shutil.which("bash")
|
| 507 |
+
return (bash, "Bash") if bash else ("/bin/sh", "POSIX sh")
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
def _trim_history(messages: list[dict], budget: int | None = None) -> int:
|
| 511 |
+
"""丢最旧的成对消息,直到历史在 `budget`(默认 `CONTEXT_CHAR_BUDGET`)以内。返回丢掉的条数。
|
| 512 |
+
|
| 513 |
+
`messages[0]` 是 system,`messages[1]` 是题面,两者永不丢。之后严格成对
|
| 514 |
+
(assistant 动作、user 结果),所以一次删两条,而不是一条 —— 删一条会让"结果"成为
|
| 515 |
+
历史里的第一条,模型会读到一段没有对应动作的输出。
|
| 516 |
+
|
| 517 |
+
**为什么需要一个更小的 `budget` 参数。** 字符数不是 token 数,两者的比例随内容在
|
| 518 |
+
2:1 到 4:1 之间浮动:代码、git 对象、base64 每 token 只有一两个字符,英文散文有
|
| 519 |
+
四个。实测(2026-10-04,`local-screen-1`):60000 字符的历史在 `git-leak-recovery` 和
|
| 520 |
+
`regex-chess` 上被 vLLM 判为 "at least 32769 input tokens" —— 字符预算满足了,token
|
| 521 |
+
预算没有。所以唯一可靠的判据是**模型自己说的**那个错误:`_call_openai` 收到它就按
|
| 522 |
+
一半预算再削一次历史并重���,而不是让整道题死掉。
|
| 523 |
+
"""
|
| 524 |
+
limit = CONTEXT_CHAR_BUDGET if budget is None else budget
|
| 525 |
+
dropped = 0
|
| 526 |
+
while len(messages) > 4 and \
|
| 527 |
+
sum(len(m.get("content") or "") for m in messages) > limit:
|
| 528 |
+
del messages[2:4]
|
| 529 |
+
dropped += 2
|
| 530 |
+
return dropped
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
#: 模型拒绝一条 prompt 时的两种说法(vLLM/OpenAI 兼容端点各一种)。判据是模型自己的措辞,
|
| 534 |
+
#: 不是我们对 token 的估算 —— 估错了会削掉本该保留的历史,或者留下一个必然失败的长度。
|
| 535 |
+
_CONTEXT_ERROR_MARKERS = ("maximum context length", "context length is", "context_length_exceeded",
|
| 536 |
+
"reduce the length of the input prompt")
|
| 537 |
+
|
| 538 |
+
|
| 539 |
+
def run(task: dict, workdir: Path) -> str:
|
| 540 |
+
"""Execute one task. Returns the answer string.
|
| 541 |
+
|
| 542 |
+
The trace written to <workdir>/trace.jsonl is what the framework collects
|
| 543 |
+
and hands to the Trainer (INTERFACE.md §4.1).
|
| 544 |
+
"""
|
| 545 |
+
trace_path = workdir / "trace.jsonl"
|
| 546 |
+
shell, dialect = _shell_runtime()
|
| 547 |
+
messages = [
|
| 548 |
+
{"role": "system", "content": SYSTEM + (
|
| 549 |
+
f"\nShell runtime: {shell} -c ({dialect}). Each command starts a new shell.\n"
|
| 550 |
+
+ ("Bash arrays and PIPESTATUS are supported.\n" if dialect == "Bash" else
|
| 551 |
+
"Use POSIX syntax; Bash arrays, PIPESTATUS and [[ ]] are unavailable.\n"))},
|
| 552 |
+
{"role": "user", "content": json.dumps(task)},
|
| 553 |
+
]
|
| 554 |
+
|
| 555 |
+
answer = ""
|
| 556 |
+
submits = 0
|
| 557 |
+
parse_retries = 0
|
| 558 |
+
repeats = 0
|
| 559 |
+
last_cmd = ""
|
| 560 |
+
output_dir = None
|
| 561 |
+
# **行缓冲,不是默认的 8KB 块缓冲。** 实测(2026-10-04,本地模型跑 `bn-fit-modify`):
|
| 562 |
+
# harness 已经跑了 8 分钟、正在装 pandas,而 `/app/trace.jsonl` 是 0 字节、打开的 fd
|
| 563 |
+
# `pos: 0` —— 一行都还没落盘。代价有三条:
|
| 564 |
+
# * 实时的轨迹看不见,面板和调试都只能等它结束;
|
| 565 |
+
# * 被超时杀掉的题会丢掉缓冲区里的尾巴(≤8KB)。一般长跑无所谓(`adaptive-rejection-sampler`
|
| 566 |
+
# 那次写了 1MB,尾巴只占零头),但一道死在第一个命令里的题,尾巴就是**全部**;
|
| 567 |
+
# * `harness_failed` 的判据是"轨迹为空",于是"被杀"和"从没跑起来"在记录里同形。
|
| 568 |
+
# 行缓冲每写一行就落盘,这三条一起消失,代价是一次 write 系统调用。
|
| 569 |
+
with trace_path.open("w", buffering=1) as trace:
|
| 570 |
+
# **这份 harness 自己声明它的运行时预算。**
|
| 571 |
+
#
|
| 572 |
+
# 平台从外面只能看见 harness 目录的哈希。可哈希相同、行为不同的两份 harness 是
|
| 573 |
+
# 存在的:`HG_AGENT_MAX_STEPS=16` 和 `=32` 跑同一个文件,一条轨迹 16 步就停、
|
| 574 |
+
# 另一条能跑 32 步 —— 实测(2026-10-04,本地 9B 跑 `build-pmars`)32 步需要约
|
| 575 |
+
# 1100 秒,超过题目自带的 900 秒预算,于是它超时;16 步则跑得完。这两次测量的
|
| 576 |
+
# 曲线点上原来没有任何一个字段不同,读者无法分辨"同一外壳跑两次"和"两个预算
|
| 577 |
+
# 各跑一次"。
|
| 578 |
+
#
|
| 579 |
+
# 所以这里声明一次,由平台记到曲线点上(`harnessgrad/identity.py:harness_config`)。
|
| 580 |
+
# 同时声明 model/backend:这个 harness 读 `HG_AGENT_MODEL`,但只有它自己知道读到
|
| 581 |
+
# 了什么,平台的环境变量在别处会因改名而与实际不符(INTERFACE.md §3)。
|
| 582 |
+
identity = {"harness": "loop", "config": {
|
| 583 |
+
"max_steps": MAX_STEPS, "submit_retries": SUBMIT_RETRIES,
|
| 584 |
+
"parse_retries": PARSE_RETRIES, "finish_nudge_steps": FINISH_NUDGE_STEPS,
|
| 585 |
+
"repeat_nudge_limit": REPEAT_NUDGE_LIMIT, "output_limit": OUTPUT_LIMIT,
|
| 586 |
+
"context_chars": CONTEXT_CHAR_BUDGET,
|
| 587 |
+
"shell": shell, "shell_dialect": dialect,
|
| 588 |
+
"max_output_tokens": MAX_OUTPUT_TOKENS}}
|
| 589 |
+
for key, value in (("agent_model", os.environ.get("HG_AGENT_MODEL")),
|
| 590 |
+
("agent_backend", _backend())):
|
| 591 |
+
if value:
|
| 592 |
+
identity[key] = value
|
| 593 |
+
trace.write(json.dumps({"harness_identity": identity}) + "\n")
|
| 594 |
+
# **每一步的时间去哪了。** 实测(2026-10-04):本地 9B 跑 `build-pmars`,26 步撞上
|
| 595 |
+
# 题目自带的 900 秒预算被杀。可它是"模型慢"还是"命令慢",记录里看不出来 —— trace
|
| 596 |
+
# 只有步数,没有任何时间字段。这两件事的平台处置完全相反:模型慢要缩步数上限或
|
| 597 |
+
# 换模型,命令慢是这道题自己的成本(装依赖),换模型没用。
|
| 598 |
+
#
|
| 599 |
+
# 所以每步记两个毫秒数:等模型的时间、跑命令的时间。总和不等于墙钟时,差额就是
|
| 600 |
+
# harness 自己的开销,那也是要看得见的东西。
|
| 601 |
+
started = time.time()
|
| 602 |
+
model_s = command_s = 0.0
|
| 603 |
+
trims_before = USAGE["context_trims"]
|
| 604 |
+
for step in range(MAX_STEPS):
|
| 605 |
+
dropped = _trim_history(messages)
|
| 606 |
+
if dropped:
|
| 607 |
+
trace.write(json.dumps({"step": step, "history_dropped": dropped}) + "\n")
|
| 608 |
+
t0 = time.time()
|
| 609 |
+
reply = _complete(messages)
|
| 610 |
+
took = time.time() - t0
|
| 611 |
+
model_s += took
|
| 612 |
+
trace.write(json.dumps({"step": step, "reply": reply,
|
| 613 |
+
"model_ms": int(took * 1000)}) + "\n")
|
| 614 |
+
# 这一步的 prompt 被模型拒绝过,harness 因此削短了历史再问。模型这一步看到的
|
| 615 |
+
# 历史比上一步短 —— 不记下来的话,"它为什么换了做法"在 trace 里没有答案。
|
| 616 |
+
if USAGE["context_trims"] > trims_before:
|
| 617 |
+
trace.write(json.dumps({
|
| 618 |
+
"step": step, "context_trims": USAGE["context_trims"],
|
| 619 |
+
"history_kept": len(messages)}) + "\n")
|
| 620 |
+
trims_before = USAGE["context_trims"]
|
| 621 |
+
messages.append({"role": "assistant", "content": reply})
|
| 622 |
+
|
| 623 |
+
try:
|
| 624 |
+
action = _parse(reply)
|
| 625 |
+
except Exception as exc:
|
| 626 |
+
# 退回给模型,而不是结束整道题。trace 里记下第几次重试,因为平台看不到
|
| 627 |
+
# 容器内部:没有这条记录,一次"读不懂的回复"在记录里和一次"一步就交卷"
|
| 628 |
+
# 长得一样。次数用完仍然是 harness 失败(它确实读不出动作),但那时记录
|
| 629 |
+
# 里已经有 N 次尝试,而不是一次。
|
| 630 |
+
trace.write(json.dumps({"step": step, "parse_error": str(exc),
|
| 631 |
+
"parse_retry": parse_retries}) + "\n")
|
| 632 |
+
if parse_retries >= PARSE_RETRIES:
|
| 633 |
+
break
|
| 634 |
+
parse_retries += 1
|
| 635 |
+
# Keep the full failed reply in the trace, not as an example for
|
| 636 |
+
# the next completion to copy. In particular, token-cut commands
|
| 637 |
+
# should be shortened by the model, never completed by the parser.
|
| 638 |
+
messages[-1]["content"] = "[Unparseable reply omitted; see trace.jsonl.]"
|
| 639 |
+
messages.append({"role": "user", "content": (
|
| 640 |
+
f"Your reply could not be read as an action: {exc}\n"
|
| 641 |
+
"Nothing was executed. It may have been cut off by the output token limit.\n"
|
| 642 |
+
"Send one short command; use a loop/script instead of enumerating calls.\n"
|
| 643 |
+
f"You have {MAX_STEPS - step - 1} step(s) left.\n"
|
| 644 |
+
"Reply with EXACTLY ONE JSON object and nothing else, one of:\n"
|
| 645 |
+
' {"tool": "bash", "command": "<shell command>"}\n'
|
| 646 |
+
' {"answer": "<your final answer>"}\n'
|
| 647 |
+
'For structured predictions, put the complete JSON object in "answer"; '
|
| 648 |
+
'preserve the task\'s prediction schema.')})
|
| 649 |
+
continue
|
| 650 |
+
|
| 651 |
+
parse_retries = 0
|
| 652 |
+
# Prose or echoed data before a recovered action is not part of the
|
| 653 |
+
# executed command. Store only the parsed action in model history.
|
| 654 |
+
messages[-1]["content"] = json.dumps(action)
|
| 655 |
+
|
| 656 |
+
# **修过的地方要留痕。** 重复键的回复被解析成"第一个值放前面"之后,模型看到的
|
| 657 |
+
# 命令和它写的不完全一样(它写了两遍,harness 取了第一遍)。一次被静默改写的
|
| 658 |
+
# 动作和一次原样执行的动作不是同一件事,记录里必须分开。
|
| 659 |
+
repaired = getattr(action, "duplicates", ())
|
| 660 |
+
if repaired:
|
| 661 |
+
trace.write(json.dumps({"step": step,
|
| 662 |
+
"duplicate_keys": list(repaired)}) + "\n")
|
| 663 |
+
|
| 664 |
+
# **交卷闸门。** 顺序按"它想干什么"判断,而不是按哪个键先出现:
|
| 665 |
+
# 一条回复里同时带 command 和 answer 时,以前"先看 answer"会让那条命令
|
| 666 |
+
# 永远不执行(实测:`{"tool":"bash","command":"cat > /app/run.py …"}` 被当成
|
| 667 |
+
# 空答案,文件从未创建)。所以:有命令就先执行命令;只有**没有**命令时才算交卷。
|
| 668 |
+
cmd = action.get("command", "")
|
| 669 |
+
if not cmd and "answer" in action:
|
| 670 |
+
missing = _missing_deliverables(task, workdir)
|
| 671 |
+
if missing and submits < SUBMIT_RETRIES:
|
| 672 |
+
submits += 1
|
| 673 |
+
note = ("You answered but these paths the task asks for do not exist: "
|
| 674 |
+
+ ", ".join(missing)
|
| 675 |
+
+ ". Create them first, then answer again.")
|
| 676 |
+
trace.write(json.dumps({"step": step, "submit_rejected": missing}) + "\n")
|
| 677 |
+
messages.append({"role": "user", "content": note})
|
| 678 |
+
continue
|
| 679 |
+
trace.write(json.dumps({"step": step, "submitted": True,
|
| 680 |
+
"missing": missing}) + "\n")
|
| 681 |
+
answer = _answer_text(action["answer"])
|
| 682 |
+
break
|
| 683 |
+
t0 = time.time()
|
| 684 |
+
proc = subprocess.run(
|
| 685 |
+
# `errors="replace"`: a command may emit arbitrary bytes, and a strict decode
|
| 686 |
+
# raises UnicodeDecodeError inside the harness, which ends the episode and is
|
| 687 |
+
# recorded as a zero for a task nobody finished. Measured 2026-10-15.
|
| 688 |
+
[shell, "-c", cmd], cwd=workdir, capture_output=True, text=True,
|
| 689 |
+
errors="replace"
|
| 690 |
+
)
|
| 691 |
+
took = time.time() - t0
|
| 692 |
+
command_s += took
|
| 693 |
+
out = proc.stdout + proc.stderr
|
| 694 |
+
trace.write(json.dumps({"step": step, "command": cmd,
|
| 695 |
+
"exit": proc.returncode,
|
| 696 |
+
"shell": shell,
|
| 697 |
+
"command_ms": int(took * 1000), "output": out}) + "\n")
|
| 698 |
+
shown = _clip_output(out)
|
| 699 |
+
output_note = ""
|
| 700 |
+
if shown != out:
|
| 701 |
+
if output_dir is None:
|
| 702 |
+
import tempfile
|
| 703 |
+
output_dir = Path(tempfile.mkdtemp(prefix=".hg-output-", dir=workdir))
|
| 704 |
+
saved = output_dir / f"step-{step}.txt"
|
| 705 |
+
saved.write_text(out)
|
| 706 |
+
relative = saved.relative_to(workdir)
|
| 707 |
+
output_note = (f"\nFull output: {relative} (use shell tools to inspect/filter it).\n"
|
| 708 |
+
"The view below may omit records; omitted does not mean absent.\n")
|
| 709 |
+
trace.write(json.dumps({"step": step, "output_clipped": len(out),
|
| 710 |
+
"shown": len(shown), "output_file": str(relative),
|
| 711 |
+
"output_view": shown}) + "\n")
|
| 712 |
+
messages.append({"role": "user", "content":
|
| 713 |
+
f"exit={proc.returncode}{output_note}\n{shown}"})
|
| 714 |
+
|
| 715 |
+
# **两条提醒,都放在命令跑完之后**,因为它们改变的是"下一步做什么"。
|
| 716 |
+
#
|
| 717 |
+
# 先记进 trace 再发出去:平台看不到容器内部,没有这两条记录,"模型在原地打转"
|
| 718 |
+
# 在一次 32 步的运行里和"模型在认真工作"长得一模一样。
|
| 719 |
+
if cmd and cmd == last_cmd and repeats < REPEAT_NUDGE_LIMIT:
|
| 720 |
+
repeats += 1
|
| 721 |
+
trace.write(json.dumps({"step": step, "repeat_nudge": cmd[:120]}) + "\n")
|
| 722 |
+
messages[-1]["content"] += "\n" + (
|
| 723 |
+
"That is the same command as the previous step and its output has not "
|
| 724 |
+
"changed. Do something different, or finish now with "
|
| 725 |
+
'{"answer": "<your final answer>"} if the work is already done.')
|
| 726 |
+
last_cmd = cmd
|
| 727 |
+
|
| 728 |
+
left = MAX_STEPS - (step + 1)
|
| 729 |
+
# 只在进入收尾区和最后一步各说一次:每一步都重复同一句话不会更有用,
|
| 730 |
+
# 只会把最近几轮的命令输出挤远。
|
| 731 |
+
if left and (left == FINISH_NUDGE_STEPS or left == 1):
|
| 732 |
+
trace.write(json.dumps({"step": step, "finish_nudge": left}) + "\n")
|
| 733 |
+
messages[-1]["content"] += "\n" + (
|
| 734 |
+
f"You have {left} step(s) left. Stop exploring. Create every file the "
|
| 735 |
+
"task asks for now, then reply with exactly one JSON object: "
|
| 736 |
+
'{"answer": "<your final answer>"}')
|
| 737 |
+
|
| 738 |
+
# Where the wall clock went. Separate from `usage` (which counts tokens):
|
| 739 |
+
# a reader asking "was this killed for being slow, and slow at what" gets one
|
| 740 |
+
# line, and a harness that is slow on its own shows up as `total` exceeding
|
| 741 |
+
# model + commands.
|
| 742 |
+
trace.write(json.dumps({"wall_clock_s": {
|
| 743 |
+
"model": round(model_s, 1), "commands": round(command_s, 1),
|
| 744 |
+
"total": round(time.time() - started, 1)}}) + "\n")
|
| 745 |
+
|
| 746 |
+
# What the run cost. Kept because a harness that cannot say what it spent
|
| 747 |
+
# cannot be compared with a cheaper one at the same score -- and because
|
| 748 |
+
# `USAGE` is the only place the model calls are counted.
|
| 749 |
+
trace.write(json.dumps({"usage": dict(USAGE)}) + "\n")
|
| 750 |
+
|
| 751 |
+
(workdir / "answer.txt").write_text(answer)
|
| 752 |
+
return answer
|
| 753 |
+
|
| 754 |
+
|
| 755 |
+
def main() -> int:
|
| 756 |
+
ap = argparse.ArgumentParser()
|
| 757 |
+
ap.add_argument("--task", required=True)
|
| 758 |
+
ap.add_argument("--workdir", required=True)
|
| 759 |
+
args = ap.parse_args()
|
| 760 |
+
|
| 761 |
+
task = json.loads(Path(args.task).read_text())
|
| 762 |
+
run(task, Path(args.workdir))
|
| 763 |
+
return 0
|
| 764 |
+
|
| 765 |
+
|
| 766 |
+
if __name__ == "__main__":
|
| 767 |
+
sys.exit(main())
|
Base_Harness/loop/harness.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "loop",
|
| 3 |
+
"version": "0.2.0",
|
| 4 |
+
"path": ".",
|
| 5 |
+
"entrypoint": "agent.py",
|
| 6 |
+
"backend": "cli",
|
| 7 |
+
"install": "requirements.txt",
|
| 8 |
+
"env_kinds": [
|
| 9 |
+
"files",
|
| 10 |
+
"exec"
|
| 11 |
+
]
|
| 12 |
+
}
|
Base_Harness/loop/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
openai>=1.0
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/channel/round-0.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:510943b0224a4e5b90d405fae309441f1ecbdd7f401625c46f1d82784870b4f4
|
| 3 |
+
size 2074197
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/channel/round-1.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a8036c9ac66bd83f97fdb926dceec3ee17e137b6fdb0feb11bd6a64ec71d0ab1
|
| 3 |
+
size 2440606
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/channel/round-2.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:68c085416a861574eeea00bef4c397094bb1a3f461adc42c3872659167695172
|
| 3 |
+
size 2341676
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/cost.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "hg-method-cost.v1",
|
| 3 |
+
"run": "rsi10-20261017T123952Z-ahe-train",
|
| 4 |
+
"improver": {
|
| 5 |
+
"1": {
|
| 6 |
+
"calls": 174,
|
| 7 |
+
"input_tokens": 98392,
|
| 8 |
+
"output_tokens": 176861,
|
| 9 |
+
"cache_read_tokens": 29322752,
|
| 10 |
+
"cache_write_tokens": 0,
|
| 11 |
+
"transcripts": 2
|
| 12 |
+
},
|
| 13 |
+
"2": {
|
| 14 |
+
"calls": 148,
|
| 15 |
+
"input_tokens": 94988,
|
| 16 |
+
"output_tokens": 160502,
|
| 17 |
+
"cache_read_tokens": 24824448,
|
| 18 |
+
"cache_write_tokens": 0,
|
| 19 |
+
"transcripts": 2
|
| 20 |
+
}
|
| 21 |
+
},
|
| 22 |
+
"task_agent": {
|
| 23 |
+
"0": {
|
| 24 |
+
"tokens": 8530045,
|
| 25 |
+
"calls": 2005,
|
| 26 |
+
"trials": 100,
|
| 27 |
+
"wall_clock_s": 287.3
|
| 28 |
+
},
|
| 29 |
+
"1": {
|
| 30 |
+
"tokens": 17703625,
|
| 31 |
+
"calls": 2635,
|
| 32 |
+
"trials": 100,
|
| 33 |
+
"wall_clock_s": 3305.7
|
| 34 |
+
},
|
| 35 |
+
"2": {
|
| 36 |
+
"tokens": 3583972,
|
| 37 |
+
"calls": 1063,
|
| 38 |
+
"trials": 100,
|
| 39 |
+
"wall_clock_s": 3248.1
|
| 40 |
+
},
|
| 41 |
+
"3": {
|
| 42 |
+
"tokens": 3583972,
|
| 43 |
+
"calls": 1063,
|
| 44 |
+
"trials": 100,
|
| 45 |
+
"wall_clock_s": 1521.7
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"task_agent_traces": {
|
| 49 |
+
"1": {
|
| 50 |
+
"input": 17640592,
|
| 51 |
+
"output": 63033,
|
| 52 |
+
"tasks_reporting": 100,
|
| 53 |
+
"tasks": 100
|
| 54 |
+
},
|
| 55 |
+
"2": {
|
| 56 |
+
"input": 3558678,
|
| 57 |
+
"output": 25294,
|
| 58 |
+
"tasks_reporting": 100,
|
| 59 |
+
"tasks": 100
|
| 60 |
+
},
|
| 61 |
+
"3": {
|
| 62 |
+
"input": 3558678,
|
| 63 |
+
"output": 25294,
|
| 64 |
+
"tasks_reporting": 100,
|
| 65 |
+
"tasks": 100
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"source": {
|
| 69 |
+
"improver": "method_logs/round-*/ transcripts",
|
| 70 |
+
"task_agent": "curve.jsonl cost.harness_tokens",
|
| 71 |
+
"task_agent_traces": "round<N>_traces per-task usage blocks"
|
| 72 |
+
}
|
| 73 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/curve.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-1-valid_seen.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:54df243874d92e6427c27993bac9a880aeeb71771a90b28b94a03be57e4dc240
|
| 3 |
+
size 228751
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-1-valid_train.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1a02552ddd64c680a7f35d6e557e1e54cc22dff191202a2d9dcd6187cc1a0fa7
|
| 3 |
+
size 291790
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-1-valid_unseen.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:721ecf8d8e57e684c62c4adb92f1650fdc903f4f47a462533184f3ace95931e4
|
| 3 |
+
size 95143
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-2-valid_seen.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:957072ce80b4790027b2e45803ad61dcee5f0d7696364ea441ac8ffef3c07c4f
|
| 3 |
+
size 83004
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-2-valid_train.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ca3bc0bd33533c774f04f591ec31b8040b685a8beb170a8c6d9fe9439926ef6d
|
| 3 |
+
size 129171
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-2-valid_unseen.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b3549383013c08312cdcba0fe89ca91bd77843139c862134937f676270c1483e
|
| 3 |
+
size 67815
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-3-valid_seen.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3504a4046d8e47dbe7df4aedc50b5b3755eacf9502830a5b5b3e256fa1a9f381
|
| 3 |
+
size 83256
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-3-valid_train.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cf9a162854acadc3ca1d1321e88a7ea566f883cb471c6a48196a68092feb1a28
|
| 3 |
+
size 128751
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval-traces/round-3-valid_unseen.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3c6fc1e6c7f64ebe03931a48665e6048ddef73a979e2c8fc6db7ba596fa3f8ef
|
| 3 |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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "hg-eval-cell.v1",
|
| 3 |
+
"method": "ahe",
|
| 4 |
+
"round": 1,
|
| 5 |
+
"pool": "valid_seen",
|
| 6 |
+
"stamp": "20261017T123952Z",
|
| 7 |
+
"run_id": "rsi10-20261017T123952Z-ahe-ckpt-r1-valid_seen",
|
| 8 |
+
"score": 0.8928571428571429,
|
| 9 |
+
"n_scored": 140,
|
| 10 |
+
"n_invalid": 0,
|
| 11 |
+
"harness_sha": "f12a20d8bbf45c990c0da5b7a6fcdf244571e2a1",
|
| 12 |
+
"evaluated_from": {
|
| 13 |
+
"run_id": "rsi10-20261017T123952Z-ahe-train",
|
| 14 |
+
"round": 1,
|
| 15 |
+
"harness_sha": "f12a20d8bbf45c990c0da5b7a6fcdf244571e2a1",
|
| 16 |
+
"train_score": 0.92
|
| 17 |
+
},
|
| 18 |
+
"per_task": {
|
| 19 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-323__trial_T20190909_044715_250790": 1.0,
|
| 20 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-301__trial_T20190909_150719_492274": 1.0,
|
| 21 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-316__trial_T20190908_230702_962704": 1.0,
|
| 22 |
+
"look_at_obj_in_light-Box-None-DeskLamp-205__trial_T20190907_074425_330493": 1.0,
|
| 23 |
+
"look_at_obj_in_light-CD-None-DeskLamp-302__trial_T20190907_154618_526741": 1.0,
|
| 24 |
+
"look_at_obj_in_light-CD-None-DeskLamp-314__trial_T20190907_114323_767231": 1.0,
|
| 25 |
+
"look_at_obj_in_light-CD-None-DeskLamp-320__trial_T20190907_224451_655673": 0.0,
|
| 26 |
+
"look_at_obj_in_light-KeyChain-None-DeskLamp-327__trial_T20190906_202601_548273": 1.0,
|
| 27 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-328__trial_T20190908_201550_622420": 1.0,
|
| 28 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-302__trial_T20190909_150916_682139": 1.0,
|
| 29 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-323__trial_T20190908_053153_077977": 1.0,
|
| 30 |
+
"look_at_obj_in_light-Statue-None-DeskLamp-216__trial_T20190909_193045_208933": 1.0,
|
| 31 |
+
"look_at_obj_in_light-Vase-None-DeskLamp-303__trial_T20190907_150418_457594": 1.0,
|
| 32 |
+
"pick_and_place_simple-Book-None-SideTable-329__trial_T20190908_050633_745514": 1.0,
|
| 33 |
+
"pick_and_place_simple-Book-None-Sofa-229__trial_T20190907_042856_259139": 1.0,
|
| 34 |
+
"pick_and_place_simple-Bowl-None-CoffeeTable-201__trial_T20190907_171639_045329": 1.0,
|
| 35 |
+
"pick_and_place_simple-Box-None-Dresser-224__trial_T20190907_164104_229696": 1.0,
|
| 36 |
+
"pick_and_place_simple-Candle-None-Cart-401__trial_T20190909_081908_677973": 1.0,
|
| 37 |
+
"pick_and_place_simple-Candle-None-Toilet-407__trial_T20190909_055248_059513": 1.0,
|
| 38 |
+
"pick_and_place_simple-Candle-None-Toilet-429__trial_T20190908_052232_887934": 1.0,
|
| 39 |
+
"pick_and_place_simple-CellPhone-None-ArmChair-318__trial_T20190909_120047_968274": 1.0,
|
| 40 |
+
"pick_and_place_simple-CellPhone-None-Bed-324__trial_T20190907_233817_198528": 1.0,
|
| 41 |
+
"pick_and_place_simple-CreditCard-None-ArmChair-201__trial_T20190908_124340_258012": 1.0,
|
| 42 |
+
"pick_and_place_simple-CreditCard-None-Drawer-227__trial_T20190909_010644_297017": 1.0,
|
| 43 |
+
"pick_and_place_simple-Egg-None-Microwave-4__trial_T20190906_234406_356490": 1.0,
|
| 44 |
+
"pick_and_place_simple-Knife-None-SideTable-3__trial_T20190918_184236_557252": 1.0,
|
| 45 |
+
"pick_and_place_simple-Mug-None-Dresser-311__trial_T20190909_152837_739016": 1.0,
|
| 46 |
+
"pick_and_place_simple-Mug-None-SideTable-329__trial_T20190909_032318_169393": 1.0,
|
| 47 |
+
"pick_and_place_simple-Mug-None-SideTable-329__trial_T20190909_032340_274147": 1.0,
|
| 48 |
+
"pick_and_place_simple-Newspaper-None-Sofa-224__trial_T20190909_111324_949106": 1.0,
|
| 49 |
+
"pick_and_place_simple-Pencil-None-Desk-310__trial_T20190909_113054_894334": 1.0,
|
| 50 |
+
"pick_and_place_simple-Pencil-None-Dresser-330__trial_T20190909_071128_012892": 1.0,
|
| 51 |
+
"pick_and_place_simple-RemoteControl-None-ArmChair-230__trial_T20190909_021000_274398": 1.0,
|
| 52 |
+
"pick_and_place_simple-RemoteControl-None-Sofa-207__trial_T20190909_153609_373481": 1.0,
|
| 53 |
+
"pick_and_place_simple-SoapBar-None-Cart-401__trial_T20190907_054906_608944": 1.0,
|
| 54 |
+
"pick_and_place_simple-SoapBottle-None-Cabinet-414__trial_T20190908_110131_524518": 1.0,
|
| 55 |
+
"pick_and_place_simple-SoapBottle-None-CounterTop-417__trial_T20190910_112922_368384": 1.0,
|
| 56 |
+
"pick_and_place_simple-SprayBottle-None-Cabinet-413__trial_T20190907_114931_692464": 1.0,
|
| 57 |
+
"pick_and_place_simple-SprayBottle-None-GarbageCan-409__trial_T20190908_054742_818364": 1.0,
|
| 58 |
+
"pick_and_place_simple-SprayBottle-None-Toilet-415__trial_T20190909_075955_678702": 1.0,
|
| 59 |
+
"pick_and_place_simple-SprayBottle-None-Toilet-418__trial_T20190906_190942_706186": 1.0,
|
| 60 |
+
"pick_and_place_simple-TissueBox-None-Toilet-426__trial_T20190910_155319_795672": 1.0,
|
| 61 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-406__trial_T20190908_122858_883968": 1.0,
|
| 62 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-415__trial_T20190908_050518_595510": 1.0,
|
| 63 |
+
"pick_and_place_simple-Tomato-None-Microwave-13__trial_T20190908_124829_632660": 0.0,
|
| 64 |
+
"pick_and_place_simple-Vase-None-CoffeeTable-207__trial_T20190909_091246_807206": 1.0,
|
| 65 |
+
"pick_and_place_simple-Watch-None-SideTable-222__trial_T20190909_051813_197569": 1.0,
|
| 66 |
+
"pick_and_place_simple-WineBottle-None-Shelf-7__trial_T20190907_200154_378982": 1.0,
|
| 67 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-CounterTop-8__trial_T20190909_105559_983897": 1.0,
|
| 68 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-DiningTable-16__trial_T20190909_114508_617301": 0.0,
|
| 69 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-Drawer-2__trial_T20190908_121728_511866": 1.0,
|
| 70 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-Drawer-30__trial_T20190908_052007_212776": 1.0,
|
| 71 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-Drawer-8__trial_T20190909_124425_112757": 1.0,
|
| 72 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cabinet-405__trial_T20190907_080903_889497": 1.0,
|
| 73 |
+
"pick_clean_then_place_in_recep-Cloth-None-Drawer-423__trial_T20190908_140701_251653": 1.0,
|
| 74 |
+
"pick_clean_then_place_in_recep-DishSponge-None-Cart-401__trial_T20190907_024634_972453": 1.0,
|
| 75 |
+
"pick_clean_then_place_in_recep-DishSponge-None-CounterTop-403__trial_T20190908_144357_621068": 1.0,
|
| 76 |
+
"pick_clean_then_place_in_recep-Fork-None-CounterTop-23__trial_T20190908_233922_171295": 1.0,
|
| 77 |
+
"pick_clean_then_place_in_recep-Fork-None-Drawer-8__trial_T20190908_132152_999725": 1.0,
|
| 78 |
+
"pick_clean_then_place_in_recep-Ladle-None-CounterTop-14__trial_T20190909_113844_191747": 1.0,
|
| 79 |
+
"pick_clean_then_place_in_recep-Ladle-None-CounterTop-8__trial_T20190909_121908_219603": 1.0,
|
| 80 |
+
"pick_clean_then_place_in_recep-Ladle-None-DiningTable-16__trial_T20190909_183724_205399": 0.0,
|
| 81 |
+
"pick_clean_then_place_in_recep-Ladle-None-DiningTable-27__trial_T20190911_131350_027076": 1.0,
|
| 82 |
+
"pick_clean_then_place_in_recep-Ladle-None-DiningTable-4__trial_T20190909_164840_568811": 1.0,
|
| 83 |
+
"pick_clean_then_place_in_recep-Lettuce-None-CounterTop-16__trial_T20190909_051630_092360": 0.0,
|
| 84 |
+
"pick_clean_then_place_in_recep-Lettuce-None-Fridge-19__trial_T20190908_100138_446072": 1.0,
|
| 85 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-26__trial_T20190907_233056_022802": 1.0,
|
| 86 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-19__trial_T20190908_212725_836398": 1.0,
|
| 87 |
+
"pick_clean_then_place_in_recep-Plate-None-Fridge-5__trial_T20190909_112854_740612": 1.0,
|
| 88 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-402__trial_T20190908_055221_984342": 1.0,
|
| 89 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Drawer-423__trial_T20190906_202340_749336": 1.0,
|
| 90 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-410__trial_T20190906_201106_979461": 1.0,
|
| 91 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-428__trial_T20190907_041436_588106": 1.0,
|
| 92 |
+
"pick_clean_then_place_in_recep-Spatula-None-DiningTable-4__trial_T20190909_002804_564168": 1.0,
|
| 93 |
+
"pick_clean_then_place_in_recep-Tomato-None-CounterTop-25__trial_T20190909_012550_586494": 1.0,
|
| 94 |
+
"pick_cool_then_place_in_recep-Apple-None-CounterTop-14__trial_T20190909_044933_815840": 1.0,
|
| 95 |
+
"pick_cool_then_place_in_recep-Apple-None-GarbageCan-2__trial_T20190906_195943_081289": 1.0,
|
| 96 |
+
"pick_cool_then_place_in_recep-Apple-None-Microwave-19__trial_T20190906_210937_878489": 1.0,
|
| 97 |
+
"pick_cool_then_place_in_recep-Apple-None-Microwave-5__trial_T20190908_150807_823817": 1.0,
|
| 98 |
+
"pick_cool_then_place_in_recep-Bowl-None-Cabinet-20__trial_T20190909_112912_154874": 1.0,
|
| 99 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-7__trial_T20190909_045605_307949": 1.0,
|
| 100 |
+
"pick_cool_then_place_in_recep-Cup-None-Microwave-17__trial_T20190906_192817_654400": 1.0,
|
| 101 |
+
"pick_cool_then_place_in_recep-Cup-None-SideTable-21__trial_T20190906_192823_237997": 1.0,
|
| 102 |
+
"pick_cool_then_place_in_recep-Egg-None-Microwave-24__trial_T20190908_234112_645480": 0.0,
|
| 103 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-1__trial_T20190908_042713_075616": 1.0,
|
| 104 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-11__trial_T20190908_222555_651605": 1.0,
|
| 105 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-16__trial_T20190908_184242_348366": 0.0,
|
| 106 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-7__trial_T20190908_232648_241836": 0.0,
|
| 107 |
+
"pick_cool_then_place_in_recep-Pan-None-StoveBurner-18__trial_T20190906_181023_216915": 0.0,
|
| 108 |
+
"pick_cool_then_place_in_recep-Pan-None-StoveBurner-23__trial_T20190906_215856_374127": 1.0,
|
| 109 |
+
"pick_cool_then_place_in_recep-Plate-None-Cabinet-27__trial_T20190906_173120_350651": 1.0,
|
| 110 |
+
"pick_cool_then_place_in_recep-Plate-None-Cabinet-7__trial_T20190907_231206_512424": 1.0,
|
| 111 |
+
"pick_cool_then_place_in_recep-Plate-None-CounterTop-1__trial_T20190906_205324_559361": 1.0,
|
| 112 |
+
"pick_cool_then_place_in_recep-Pot-None-DiningTable-21__trial_T20190909_004531_429065": 1.0,
|
| 113 |
+
"pick_cool_then_place_in_recep-Tomato-None-CounterTop-12__trial_T20190909_063754_216554": 0.0,
|
| 114 |
+
"pick_cool_then_place_in_recep-Tomato-None-CounterTop-12__trial_T20190909_063844_274181": 1.0,
|
| 115 |
+
"pick_cool_then_place_in_recep-Tomato-None-GarbageCan-6__trial_T20190909_082934_483899": 1.0,
|
| 116 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-13__trial_T20190910_173916_331859": 0.0,
|
| 117 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-18__trial_T20190909_012524_159092": 1.0,
|
| 118 |
+
"pick_cool_then_place_in_recep-WineBottle-None-DiningTable-17__trial_T20190908_024426_412044": 1.0,
|
| 119 |
+
"pick_heat_then_place_in_recep-Apple-None-DiningTable-26__trial_T20190907_060234_011675": 1.0,
|
| 120 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-22__trial_T20190907_173251_960848": 1.0,
|
| 121 |
+
"pick_heat_then_place_in_recep-Egg-None-CounterTop-2__trial_T20190908_122951_021026": 1.0,
|
| 122 |
+
"pick_heat_then_place_in_recep-Egg-None-Fridge-14__trial_T20190909_091314_636733": 1.0,
|
| 123 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-26__trial_T20190909_062333_424779": 1.0,
|
| 124 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-3__trial_T20190909_014639_335717": 1.0,
|
| 125 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-1__trial_T20190907_222640_487432": 1.0,
|
| 126 |
+
"pick_heat_then_place_in_recep-Mug-None-SideTable-21__trial_T20190909_090729_088825": 1.0,
|
| 127 |
+
"pick_heat_then_place_in_recep-Plate-None-Cabinet-1__trial_T20190908_070946_578973": 1.0,
|
| 128 |
+
"pick_heat_then_place_in_recep-Plate-None-DiningTable-28__trial_T20190908_001247_096796": 1.0,
|
| 129 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-11__trial_T20190909_011341_436523": 1.0,
|
| 130 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-12__trial_T20190908_014451_271080": 1.0,
|
| 131 |
+
"pick_heat_then_place_in_recep-Tomato-None-DiningTable-16__trial_T20190907_201243_698086": 0.0,
|
| 132 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-15__trial_T20190909_020200_054379": 1.0,
|
| 133 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-23__trial_T20190909_082320_103350": 1.0,
|
| 134 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-24__trial_T20190908_033721_967359": 0.0,
|
| 135 |
+
"pick_two_obj_and_place-AlarmClock-None-Dresser-305__trial_T20190907_165826_194855": 1.0,
|
| 136 |
+
"pick_two_obj_and_place-Book-None-Desk-302__trial_T20190906_181233_363875": 1.0,
|
| 137 |
+
"pick_two_obj_and_place-Book-None-Desk-313__trial_T20190908_125930_920681": 1.0,
|
| 138 |
+
"pick_two_obj_and_place-Box-None-CoffeeTable-213__trial_T20190906_200927_069627": 1.0,
|
| 139 |
+
"pick_two_obj_and_place-CD-None-Drawer-304__trial_T20190907_230232_832893": 1.0,
|
| 140 |
+
"pick_two_obj_and_place-CreditCard-None-Dresser-311__trial_T20190907_201917_045715": 1.0,
|
| 141 |
+
"pick_two_obj_and_place-CreditCard-None-Safe-323__trial_T20190907_001129_214240": 1.0,
|
| 142 |
+
"pick_two_obj_and_place-Glassbottle-None-Shelf-1__trial_T20190907_122204_941737": 1.0,
|
| 143 |
+
"pick_two_obj_and_place-Knife-None-Drawer-18__trial_T20190907_065232_689984": 1.0,
|
| 144 |
+
"pick_two_obj_and_place-Newspaper-None-Drawer-224__trial_T20190911_101248_326533": 0.0,
|
| 145 |
+
"pick_two_obj_and_place-Pan-None-CounterTop-14__trial_T20190907_012519_974044": 1.0,
|
| 146 |
+
"pick_two_obj_and_place-RemoteControl-None-Ottoman-203__trial_T20190906_182952_858723": 1.0,
|
| 147 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-418__trial_T20190909_055538_380023": 1.0,
|
| 148 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-418__trial_T20190909_055649_717880": 1.0,
|
| 149 |
+
"pick_two_obj_and_place-Spatula-None-Drawer-13__trial_T20190908_183331_203888": 0.0,
|
| 150 |
+
"pick_two_obj_and_place-SprayBottle-None-Cabinet-407__trial_T20190907_144556_144188": 1.0,
|
| 151 |
+
"pick_two_obj_and_place-SprayBottle-None-GarbageCan-419__trial_T20190908_164236_518264": 1.0,
|
| 152 |
+
"pick_two_obj_and_place-SprayBottle-None-Toilet-402__trial_T20190910_222914_814642": 1.0,
|
| 153 |
+
"pick_two_obj_and_place-SprayBottle-None-Toilet-429__trial_T20190907_033843_707544": 1.0,
|
| 154 |
+
"pick_two_obj_and_place-TissueBox-None-Toilet-426__trial_T20190909_044602_338962": 1.0,
|
| 155 |
+
"pick_two_obj_and_place-ToiletPaper-None-Drawer-423__trial_T20190907_111251_461099": 1.0,
|
| 156 |
+
"pick_two_obj_and_place-ToiletPaper-None-Toilet-408__trial_T20190909_080302_174780": 1.0,
|
| 157 |
+
"pick_two_obj_and_place-Vase-None-Desk-204__trial_T20190906_181531_703961": 1.0,
|
| 158 |
+
"pick_two_obj_and_place-Watch-None-Dresser-205__trial_T20190907_182211_592010": 1.0
|
| 159 |
+
},
|
| 160 |
+
"traces": "eval-traces/round-1-valid_seen.tar.gz"
|
| 161 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-1-valid_train.json
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
"method": "ahe",
|
| 4 |
+
"round": 1,
|
| 5 |
+
"pool": "valid_train",
|
| 6 |
+
"stamp": "20261017T123952Z",
|
| 7 |
+
"run_id": "rsi10-20261017T123952Z-ahe-ckpt-r1-valid_train",
|
| 8 |
+
"score": 0.905,
|
| 9 |
+
"n_scored": 200,
|
| 10 |
+
"n_invalid": 0,
|
| 11 |
+
"harness_sha": "f12a20d8bbf45c990c0da5b7a6fcdf244571e2a1",
|
| 12 |
+
"evaluated_from": {
|
| 13 |
+
"run_id": "rsi10-20261017T123952Z-ahe-train",
|
| 14 |
+
"round": 1,
|
| 15 |
+
"harness_sha": "f12a20d8bbf45c990c0da5b7a6fcdf244571e2a1",
|
| 16 |
+
"train_score": 0.92
|
| 17 |
+
},
|
| 18 |
+
"per_task": {
|
| 19 |
+
"look_at_obj_in_light-Book-None-DeskLamp-302__trial_T20190909_085137_911990": 1.0,
|
| 20 |
+
"look_at_obj_in_light-Book-None-DeskLamp-317__trial_T20190909_201225_052100": 1.0,
|
| 21 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-304__trial_T20190907_232227_752681": 1.0,
|
| 22 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-305__trial_T20190909_000758_132057": 1.0,
|
| 23 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-316__trial_T20190908_230650_245482": 1.0,
|
| 24 |
+
"look_at_obj_in_light-CD-None-DeskLamp-307__trial_T20190906_200435_424001": 1.0,
|
| 25 |
+
"look_at_obj_in_light-CD-None-DeskLamp-323__trial_T20190908_051124_983144": 1.0,
|
| 26 |
+
"look_at_obj_in_light-CD-None-DeskLamp-327__trial_T20190909_032921_008718": 1.0,
|
| 27 |
+
"look_at_obj_in_light-CreditCard-None-DeskLamp-314__trial_T20190906_201548_667159": 1.0,
|
| 28 |
+
"look_at_obj_in_light-KeyChain-None-DeskLamp-327__trial_T20190906_202538_399742": 1.0,
|
| 29 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-309__trial_T20190907_185713_398582": 1.0,
|
| 30 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-319__trial_T20190908_182720_056041": 1.0,
|
| 31 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-324__trial_T20190908_071137_867346": 1.0,
|
| 32 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-323__trial_T20190907_041046_628363": 1.0,
|
| 33 |
+
"look_at_obj_in_light-Pen-None-DeskLamp-305__trial_T20190907_115824_746935": 1.0,
|
| 34 |
+
"look_at_obj_in_light-Pen-None-DeskLamp-316__trial_T20190908_061847_951064": 1.0,
|
| 35 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-309__trial_T20190908_113756_084511": 1.0,
|
| 36 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-323__trial_T20190908_053117_107031": 1.0,
|
| 37 |
+
"look_at_obj_in_light-TissueBox-None-DeskLamp-216__trial_T20190908_033138_836240": 1.0,
|
| 38 |
+
"pick_and_place_simple-AlarmClock-None-Desk-307__trial_T20190907_072317_014092": 1.0,
|
| 39 |
+
"pick_and_place_simple-AlarmClock-None-Dresser-319__trial_T20190910_195319_108102": 1.0,
|
| 40 |
+
"pick_and_place_simple-Book-None-Desk-313__trial_T20190909_140606_239445": 1.0,
|
| 41 |
+
"pick_and_place_simple-CD-None-Dresser-318__trial_T20190907_190246_917982": 1.0,
|
| 42 |
+
"pick_and_place_simple-CD-None-Shelf-319__trial_T20190908_061008_714389": 1.0,
|
| 43 |
+
"pick_and_place_simple-Candle-None-Cabinet-428__trial_T20190907_024255_988230": 1.0,
|
| 44 |
+
"pick_and_place_simple-Candle-None-Toilet-427__trial_T20190909_030427_604487": 1.0,
|
| 45 |
+
"pick_and_place_simple-CellPhone-None-Bed-321__trial_T20190908_231541_058766": 1.0,
|
| 46 |
+
"pick_and_place_simple-CellPhone-None-Desk-316__trial_T20190911_203517_902296": 1.0,
|
| 47 |
+
"pick_and_place_simple-Cloth-None-Toilet-417__trial_T20190908_163202_959027": 1.0,
|
| 48 |
+
"pick_and_place_simple-CreditCard-None-ArmChair-202__trial_T20190909_011606_013059": 1.0,
|
| 49 |
+
"pick_and_place_simple-CreditCard-None-Sofa-216__trial_T20190909_110455_224621": 1.0,
|
| 50 |
+
"pick_and_place_simple-Fork-None-Drawer-12__trial_T20190907_151050_079642": 1.0,
|
| 51 |
+
"pick_and_place_simple-Glassbottle-None-Cabinet-17__trial_T20190906_182221_722403": 1.0,
|
| 52 |
+
"pick_and_place_simple-HandTowel-None-Cabinet-412__trial_T20190906_200520_896836": 1.0,
|
| 53 |
+
"pick_and_place_simple-KeyChain-None-ArmChair-318__trial_T20190909_114631_650488": 1.0,
|
| 54 |
+
"pick_and_place_simple-KeyChain-None-CoffeeTable-227__trial_T20190907_161844_256041": 1.0,
|
| 55 |
+
"pick_and_place_simple-KeyChain-None-SideTable-309__trial_T20190908_215011_025401": 1.0,
|
| 56 |
+
"pick_and_place_simple-KeyChain-None-SideTable-322__trial_T20190909_091733_848923": 1.0,
|
| 57 |
+
"pick_and_place_simple-KeyChain-None-Sofa-225__trial_T20190908_131129_251514": 1.0,
|
| 58 |
+
"pick_and_place_simple-KeyChain-None-Sofa-229__trial_T20190908_123359_988104": 1.0,
|
| 59 |
+
"pick_and_place_simple-Pan-None-DiningTable-15__trial_T20190908_182413_239334": 1.0,
|
| 60 |
+
"pick_and_place_simple-Pen-None-SideTable-309__trial_T20190907_051900_451316": 1.0,
|
| 61 |
+
"pick_and_place_simple-PepperShaker-None-CounterTop-27__trial_T20190909_010859_836097": 1.0,
|
| 62 |
+
"pick_and_place_simple-Pillow-None-ArmChair-214__trial_T20190909_010338_250180": 1.0,
|
| 63 |
+
"pick_and_place_simple-Pillow-None-ArmChair-321__trial_T20190908_104900_888704": 1.0,
|
| 64 |
+
"pick_and_place_simple-RemoteControl-None-ArmChair-222__trial_T20190906_201505_001155": 1.0,
|
| 65 |
+
"pick_and_place_simple-RemoteControl-None-Ottoman-208__trial_T20190909_100851_710423": 1.0,
|
| 66 |
+
"pick_and_place_simple-SoapBottle-None-Cart-430__trial_T20190909_100609_714213": 1.0,
|
| 67 |
+
"pick_and_place_simple-SoapBottle-None-GarbageCan-11__trial_T20190908_175650_970050": 1.0,
|
| 68 |
+
"pick_and_place_simple-SprayBottle-None-CounterTop-417__trial_T20190909_091329_750799": 1.0,
|
| 69 |
+
"pick_and_place_simple-SprayBottle-None-GarbageCan-428__trial_T20190909_101522_923920": 1.0,
|
| 70 |
+
"pick_and_place_simple-SprayBottle-None-Toilet-405__trial_T20190908_021347_460567": 1.0,
|
| 71 |
+
"pick_and_place_simple-Statue-None-CoffeeTable-229__trial_T20190908_132941_479938": 1.0,
|
| 72 |
+
"pick_and_place_simple-ToiletPaper-None-GarbageCan-403__trial_T20190907_034648_807245": 1.0,
|
| 73 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-402__trial_T20190908_030828_744767": 1.0,
|
| 74 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-410__trial_T20190907_021559_670421": 1.0,
|
| 75 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-412__trial_T20190907_181227_790902": 1.0,
|
| 76 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-428__trial_T20190906_201316_921947": 1.0,
|
| 77 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-430__trial_T20190908_102055_678050": 1.0,
|
| 78 |
+
"pick_and_place_simple-Tomato-None-DiningTable-26__trial_T20190908_010933_200567": 1.0,
|
| 79 |
+
"pick_and_place_simple-Tomato-None-Microwave-13__trial_T20190908_125127_168939": 1.0,
|
| 80 |
+
"pick_and_place_simple-Tomato-None-Microwave-5__trial_T20190908_174014_984950": 1.0,
|
| 81 |
+
"pick_and_place_simple-Tomato-None-Microwave-8__trial_T20190907_205031_274716": 1.0,
|
| 82 |
+
"pick_and_place_simple-Vase-None-CoffeeTable-206__trial_T20190909_024648_216020": 1.0,
|
| 83 |
+
"pick_and_place_simple-Watch-None-CoffeeTable-213__trial_T20190909_010805_852491": 1.0,
|
| 84 |
+
"pick_clean_then_place_in_recep-Bowl-None-Shelf-7__trial_T20190908_152949_169018": 1.0,
|
| 85 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cart-401__trial_T20190907_045451_101032": 1.0,
|
| 86 |
+
"pick_clean_then_place_in_recep-Cloth-None-Drawer-416__trial_T20190908_040722_151303": 1.0,
|
| 87 |
+
"pick_clean_then_place_in_recep-Cloth-None-Drawer-423__trial_T20190908_140728_318318": 1.0,
|
| 88 |
+
"pick_clean_then_place_in_recep-Cloth-None-Toilet-406__trial_T20190908_102735_461565": 1.0,
|
| 89 |
+
"pick_clean_then_place_in_recep-DishSponge-None-Shelf-20__trial_T20190907_222456_204496": 1.0,
|
| 90 |
+
"pick_clean_then_place_in_recep-Egg-None-GarbageCan-11__trial_T20190906_181033_636334": 1.0,
|
| 91 |
+
"pick_clean_then_place_in_recep-Fork-None-CounterTop-24__trial_T20190907_032458_736277": 0.0,
|
| 92 |
+
"pick_clean_then_place_in_recep-Fork-None-DiningTable-24__trial_T20190906_205216_940941": 0.0,
|
| 93 |
+
"pick_clean_then_place_in_recep-Fork-None-SideTable-21__trial_T20190909_041401_796447": 1.0,
|
| 94 |
+
"pick_clean_then_place_in_recep-Kettle-None-Cabinet-2__trial_T20190909_042935_977031": 1.0,
|
| 95 |
+
"pick_clean_then_place_in_recep-Kettle-None-DiningTable-17__trial_T20190909_023518_602816": 1.0,
|
| 96 |
+
"pick_clean_then_place_in_recep-Kettle-None-Shelf-7__trial_T20190907_200421_808214": 0.0,
|
| 97 |
+
"pick_clean_then_place_in_recep-Kettle-None-StoveBurner-30__trial_T20190906_200053_697370": 1.0,
|
| 98 |
+
"pick_clean_then_place_in_recep-Knife-None-DiningTable-23__trial_T20190908_142126_854011": 1.0,
|
| 99 |
+
"pick_clean_then_place_in_recep-Ladle-None-CounterTop-14__trial_T20190909_113924_604801": 1.0,
|
| 100 |
+
"pick_clean_then_place_in_recep-Ladle-None-Drawer-30__trial_T20190908_005155_378803": 1.0,
|
| 101 |
+
"pick_clean_then_place_in_recep-Ladle-None-Drawer-4__trial_T20190909_161523_929674": 1.0,
|
| 102 |
+
"pick_clean_then_place_in_recep-Lettuce-None-CounterTop-15__trial_T20190907_070041_442493": 1.0,
|
| 103 |
+
"pick_clean_then_place_in_recep-Lettuce-None-Fridge-13__trial_T20190908_203156_157438": 0.0,
|
| 104 |
+
"pick_clean_then_place_in_recep-Lettuce-None-GarbageCan-17__trial_T20190907_163845_626537": 1.0,
|
| 105 |
+
"pick_clean_then_place_in_recep-Pan-None-Cabinet-1__trial_T20190908_130833_956410": 1.0,
|
| 106 |
+
"pick_clean_then_place_in_recep-Pan-None-Fridge-1__trial_T20190908_105549_705446": 1.0,
|
| 107 |
+
"pick_clean_then_place_in_recep-Pan-None-StoveBurner-20__trial_T20190908_113730_305436": 1.0,
|
| 108 |
+
"pick_clean_then_place_in_recep-Plate-None-Cabinet-13__trial_T20190909_123604_776156": 1.0,
|
| 109 |
+
"pick_clean_then_place_in_recep-Pot-None-DiningTable-26__trial_T20190906_210506_116438": 1.0,
|
| 110 |
+
"pick_clean_then_place_in_recep-Potato-None-CounterTop-5__trial_T20190909_123212_517019": 0.0,
|
| 111 |
+
"pick_clean_then_place_in_recep-Potato-None-Fridge-17__trial_T20190909_135834_661867": 1.0,
|
| 112 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-428__trial_T20190908_084117_719605": 1.0,
|
| 113 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-409__trial_T20190908_025402_020595": 1.0,
|
| 114 |
+
"pick_clean_then_place_in_recep-SoapBar-None-GarbageCan-416__trial_T20190907_024728_127108": 1.0,
|
| 115 |
+
"pick_clean_then_place_in_recep-SoapBar-None-GarbageCan-429__trial_T20190909_015556_293557": 1.0,
|
| 116 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-420__trial_T20190908_043134_210616": 1.0,
|
| 117 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-428__trial_T20190907_041322_837354": 1.0,
|
| 118 |
+
"pick_clean_then_place_in_recep-Spatula-None-CounterTop-13__trial_T20190909_023039_986825": 1.0,
|
| 119 |
+
"pick_clean_then_place_in_recep-Tomato-None-Fridge-20__trial_T20190909_091539_383661": 1.0,
|
| 120 |
+
"pick_clean_then_place_in_recep-Tomato-None-SideTable-21__trial_T20190907_164958_308793": 1.0,
|
| 121 |
+
"pick_cool_then_place_in_recep-Bowl-None-Cabinet-18__trial_T20190908_144624_086654": 1.0,
|
| 122 |
+
"pick_cool_then_place_in_recep-Bowl-None-Shelf-20__trial_T20190908_034339_870890": 1.0,
|
| 123 |
+
"pick_cool_then_place_in_recep-Cup-None-Cabinet-26__trial_T20190909_085908_816209": 1.0,
|
| 124 |
+
"pick_cool_then_place_in_recep-Cup-None-Cabinet-30__trial_T20190909_090746_864458": 1.0,
|
| 125 |
+
"pick_cool_then_place_in_recep-Egg-None-CounterTop-27__trial_T20190909_002015_890646": 1.0,
|
| 126 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-24__trial_T20190908_015109_682752": 0.0,
|
| 127 |
+
"pick_cool_then_place_in_recep-Lettuce-None-DiningTable-18__trial_T20190909_122629_020439": 1.0,
|
| 128 |
+
"pick_cool_then_place_in_recep-Lettuce-None-DiningTable-24__trial_T20190908_062436_694989": 0.0,
|
| 129 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-11__trial_T20190908_021957_189338": 1.0,
|
| 130 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-14__trial_T20190906_182932_157770": 1.0,
|
| 131 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-23__trial_T20190908_143209_571893": 1.0,
|
| 132 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-11__trial_T20190908_204414_053313": 1.0,
|
| 133 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-15__trial_T20190909_003904_518800": 1.0,
|
| 134 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-23__trial_T20190909_005833_061416": 1.0,
|
| 135 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-7__trial_T20190909_094708_361033": 0.0,
|
| 136 |
+
"pick_cool_then_place_in_recep-Pan-None-StoveBurner-23__trial_T20190906_215826_707811": 1.0,
|
| 137 |
+
"pick_cool_then_place_in_recep-Plate-None-DiningTable-23__trial_T20190910_025008_561989": 1.0,
|
| 138 |
+
"pick_cool_then_place_in_recep-Plate-None-Shelf-7__trial_T20190907_125004_299560": 0.0,
|
| 139 |
+
"pick_cool_then_place_in_recep-Pot-None-CounterTop-5__trial_T20190908_073249_042493": 0.0,
|
| 140 |
+
"pick_cool_then_place_in_recep-Pot-None-DiningTable-27__trial_T20190909_013328_302952": 1.0,
|
| 141 |
+
"pick_cool_then_place_in_recep-Potato-None-CounterTop-30__trial_T20190908_111757_114406": 1.0,
|
| 142 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-5__trial_T20190910_115040_425451": 1.0,
|
| 143 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-13__trial_T20190910_173429_847749": 0.0,
|
| 144 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-14__trial_T20190907_024221_811233": 1.0,
|
| 145 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-5__trial_T20190908_132124_203759": 1.0,
|
| 146 |
+
"pick_cool_then_place_in_recep-WineBottle-None-Cabinet-17__trial_T20190907_064115_485667": 1.0,
|
| 147 |
+
"pick_cool_then_place_in_recep-WineBottle-None-DiningTable-17__trial_T20190908_003313_375871": 1.0,
|
| 148 |
+
"pick_cool_then_place_in_recep-WineBottle-None-GarbageCan-16__trial_T20190907_014908_758565": 0.0,
|
| 149 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-6__trial_T20190908_153841_522662": 1.0,
|
| 150 |
+
"pick_heat_then_place_in_recep-Apple-None-SideTable-28__trial_T20190906_180828_374034": 1.0,
|
| 151 |
+
"pick_heat_then_place_in_recep-Cup-None-Shelf-1__trial_T20190906_230051_015449": 1.0,
|
| 152 |
+
"pick_heat_then_place_in_recep-Cup-None-SideTable-3__trial_T20190908_210847_591144": 1.0,
|
| 153 |
+
"pick_heat_then_place_in_recep-Egg-None-DiningTable-15__trial_T20190908_042212_100074": 1.0,
|
| 154 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-23__trial_T20190911_011457_072067": 1.0,
|
| 155 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-2__trial_T20190907_070838_688262": 1.0,
|
| 156 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-21__trial_T20190908_113549_665152": 1.0,
|
| 157 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-22__trial_T20190906_184650_216044": 1.0,
|
| 158 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-5__trial_T20190908_040351_384338": 0.0,
|
| 159 |
+
"pick_heat_then_place_in_recep-Mug-None-SideTable-21__trial_T20190909_090802_375850": 1.0,
|
| 160 |
+
"pick_heat_then_place_in_recep-Mug-None-SideTable-28__trial_T20190908_212801_623417": 1.0,
|
| 161 |
+
"pick_heat_then_place_in_recep-Plate-None-Cabinet-7__trial_T20190907_144322_406779": 1.0,
|
| 162 |
+
"pick_heat_then_place_in_recep-Plate-None-CounterTop-1__trial_T20190909_115700_060162": 1.0,
|
| 163 |
+
"pick_heat_then_place_in_recep-Potato-None-CounterTop-25__trial_T20190908_003752_653811": 1.0,
|
| 164 |
+
"pick_heat_then_place_in_recep-Potato-None-DiningTable-16__trial_T20190908_015009_437240": 0.0,
|
| 165 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-12__trial_T20190910_094522_460953": 0.0,
|
| 166 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-27__trial_T20190908_143711_459299": 1.0,
|
| 167 |
+
"pick_heat_then_place_in_recep-Tomato-None-CounterTop-2__trial_T20190908_171656_745023": 0.0,
|
| 168 |
+
"pick_heat_then_place_in_recep-Tomato-None-CounterTop-20__trial_T20190909_041153_700490": 1.0,
|
| 169 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-12__trial_T20190906_190527_670222": 0.0,
|
| 170 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-14__trial_T20190908_091828_220110": 1.0,
|
| 171 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-15__trial_T20190909_020126_376897": 1.0,
|
| 172 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-24__trial_T20190908_033524_642305": 0.0,
|
| 173 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-16__trial_T20190906_171827_526847": 0.0,
|
| 174 |
+
"pick_two_obj_and_place-Book-None-Desk-302__trial_T20190906_181314_259738": 1.0,
|
| 175 |
+
"pick_two_obj_and_place-Book-None-Desk-309__trial_T20190909_061156_951604": 1.0,
|
| 176 |
+
"pick_two_obj_and_place-Box-None-CoffeeTable-230__trial_T20190908_124255_946115": 1.0,
|
| 177 |
+
"pick_two_obj_and_place-CD-None-Drawer-306__trial_T20190907_025539_829173": 1.0,
|
| 178 |
+
"pick_two_obj_and_place-CD-None-Dresser-303__trial_T20190908_085826_396748": 1.0,
|
| 179 |
+
"pick_two_obj_and_place-Candle-None-CounterTop-406__trial_T20190908_045958_916084": 1.0,
|
| 180 |
+
"pick_two_obj_and_place-CellPhone-None-Desk-312__trial_T20190908_122230_946481": 1.0,
|
| 181 |
+
"pick_two_obj_and_place-CellPhone-None-Drawer-318__trial_T20190908_104535_936869": 1.0,
|
| 182 |
+
"pick_two_obj_and_place-CellPhone-None-Drawer-329__trial_T20190909_030028_020737": 1.0,
|
| 183 |
+
"pick_two_obj_and_place-CellPhone-None-Dresser-330__trial_T20190909_060924_095249": 1.0,
|
| 184 |
+
"pick_two_obj_and_place-CellPhone-None-Sofa-224__trial_T20190918_223409_525979": 1.0,
|
| 185 |
+
"pick_two_obj_and_place-Cloth-None-Drawer-411__trial_T20190908_190008_902235": 1.0,
|
| 186 |
+
"pick_two_obj_and_place-CreditCard-None-Desk-313__trial_T20190909_104504_038752": 1.0,
|
| 187 |
+
"pick_two_obj_and_place-CreditCard-None-DiningTable-329__trial_T20190918_154222_318527": 1.0,
|
| 188 |
+
"pick_two_obj_and_place-CreditCard-None-Safe-323__trial_T20190907_001424_961488": 1.0,
|
| 189 |
+
"pick_two_obj_and_place-CreditCard-None-Sofa-206__trial_T20190906_203615_424745": 1.0,
|
| 190 |
+
"pick_two_obj_and_place-Cup-None-Shelf-1__trial_T20190908_015402_128805": 1.0,
|
| 191 |
+
"pick_two_obj_and_place-KeyChain-None-Dresser-318__trial_T20190907_181205_590674": 1.0,
|
| 192 |
+
"pick_two_obj_and_place-KeyChain-None-Ottoman-208__trial_T20190907_232759_901444": 1.0,
|
| 193 |
+
"pick_two_obj_and_place-KeyChain-None-Sofa-225__trial_T20190907_143028_102387": 1.0,
|
| 194 |
+
"pick_two_obj_and_place-Newspaper-None-ArmChair-214__trial_T20190909_010843_771227": 1.0,
|
| 195 |
+
"pick_two_obj_and_place-Newspaper-None-Sofa-230__trial_T20190908_035335_001162": 1.0,
|
| 196 |
+
"pick_two_obj_and_place-Pencil-None-Drawer-327__trial_T20190908_103604_088470": 1.0,
|
| 197 |
+
"pick_two_obj_and_place-Pencil-None-SideTable-329__trial_T20190909_040132_412120": 1.0,
|
| 198 |
+
"pick_two_obj_and_place-Pillow-None-Ottoman-208__trial_T20190907_030106_770418": 1.0,
|
| 199 |
+
"pick_two_obj_and_place-RemoteControl-None-ArmChair-208__trial_T20190908_000903_032547": 1.0,
|
| 200 |
+
"pick_two_obj_and_place-RemoteControl-None-Ottoman-210__trial_T20190906_202114_729948": 1.0,
|
| 201 |
+
"pick_two_obj_and_place-RemoteControl-None-Sofa-207__trial_T20190908_111223_597180": 1.0,
|
| 202 |
+
"pick_two_obj_and_place-SoapBar-None-Cabinet-428__trial_T20190910_231209_039518": 1.0,
|
| 203 |
+
"pick_two_obj_and_place-SoapBar-None-Drawer-420__trial_T20190908_124733_053705": 1.0,
|
| 204 |
+
"pick_two_obj_and_place-SoapBottle-None-Cabinet-417__trial_T20190909_211711_664720": 1.0,
|
| 205 |
+
"pick_two_obj_and_place-SoapBottle-None-Cart-401__trial_T20190908_215242_345375": 1.0,
|
| 206 |
+
"pick_two_obj_and_place-SoapBottle-None-Toilet-426__trial_T20190907_184729_585161": 1.0,
|
| 207 |
+
"pick_two_obj_and_place-SprayBottle-None-CounterTop-409__trial_T20190908_131755_202053": 1.0,
|
| 208 |
+
"pick_two_obj_and_place-SprayBottle-None-GarbageCan-413__trial_T20190912_044451_035192": 1.0,
|
| 209 |
+
"pick_two_obj_and_place-SprayBottle-None-GarbageCan-420__trial_T20190907_174658_354066": 1.0,
|
| 210 |
+
"pick_two_obj_and_place-SprayBottle-None-Toilet-417__trial_T20190908_071820_505015": 1.0,
|
| 211 |
+
"pick_two_obj_and_place-Statue-None-Dresser-213__trial_T20190909_065309_623947": 1.0,
|
| 212 |
+
"pick_two_obj_and_place-TissueBox-None-CoffeeTable-220__trial_T20190909_145750_484036": 1.0,
|
| 213 |
+
"pick_two_obj_and_place-TissueBox-None-CoffeeTable-230__trial_T20190909_145658_750781": 1.0,
|
| 214 |
+
"pick_two_obj_and_place-TissueBox-None-DiningTable-230__trial_T20190909_145553_211575": 1.0,
|
| 215 |
+
"pick_two_obj_and_place-ToiletPaper-None-Cabinet-412__trial_T20190908_141555_713466": 1.0,
|
| 216 |
+
"pick_two_obj_and_place-ToiletPaper-None-Drawer-409__trial_T20190906_193417_937668": 1.0,
|
| 217 |
+
"pick_two_obj_and_place-ToiletPaper-None-Toilet-405__trial_T20190909_065947_451268": 1.0,
|
| 218 |
+
"pick_two_obj_and_place-Watch-None-CoffeeTable-209__trial_T20190909_020350_646515": 1.0
|
| 219 |
+
},
|
| 220 |
+
"traces": "eval-traces/round-1-valid_train.tar.gz"
|
| 221 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-de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",
|
| 3 |
+
"method": "ahe",
|
| 4 |
+
"round": 1,
|
| 5 |
+
"pool": "valid_unseen",
|
| 6 |
+
"stamp": "20261017T123952Z",
|
| 7 |
+
"run_id": "rsi10-20261017T123952Z-ahe-ckpt-r1-valid_unseen",
|
| 8 |
+
"score": 0.9925373134328358,
|
| 9 |
+
"n_scored": 134,
|
| 10 |
+
"n_invalid": 0,
|
| 11 |
+
"harness_sha": "f12a20d8bbf45c990c0da5b7a6fcdf244571e2a1",
|
| 12 |
+
"evaluated_from": {
|
| 13 |
+
"run_id": "rsi10-20261017T123952Z-ahe-train",
|
| 14 |
+
"round": 1,
|
| 15 |
+
"harness_sha": "f12a20d8bbf45c990c0da5b7a6fcdf244571e2a1",
|
| 16 |
+
"train_score": 0.92
|
| 17 |
+
},
|
| 18 |
+
"per_task": {
|
| 19 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-308__trial_T20190908_222917_366542": 1.0,
|
| 20 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-308__trial_T20190908_222933_607649": 1.0,
|
| 21 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-308__trial_T20190908_222951_616606": 1.0,
|
| 22 |
+
"look_at_obj_in_light-Book-None-DeskLamp-308__trial_T20190908_020029_636862": 1.0,
|
| 23 |
+
"look_at_obj_in_light-Book-None-DeskLamp-308__trial_T20190908_020048_814402": 1.0,
|
| 24 |
+
"look_at_obj_in_light-Book-None-DeskLamp-308__trial_T20190908_144951_587345": 1.0,
|
| 25 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-308__trial_T20190907_133919_856963": 1.0,
|
| 26 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-308__trial_T20190907_133935_066606": 1.0,
|
| 27 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-308__trial_T20190907_133953_562557": 1.0,
|
| 28 |
+
"look_at_obj_in_light-CD-None-DeskLamp-308__trial_T20190908_141942_810052": 1.0,
|
| 29 |
+
"look_at_obj_in_light-CD-None-DeskLamp-308__trial_T20190908_141958_463362": 1.0,
|
| 30 |
+
"look_at_obj_in_light-CD-None-DeskLamp-308__trial_T20190908_142046_281296": 1.0,
|
| 31 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-308__trial_T20190908_161733_213242": 1.0,
|
| 32 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-308__trial_T20190908_201421_021646": 1.0,
|
| 33 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-308__trial_T20190908_201444_037645": 1.0,
|
| 34 |
+
"look_at_obj_in_light-Pencil-None-DeskLamp-308__trial_T20190908_220545_153480": 1.0,
|
| 35 |
+
"look_at_obj_in_light-Pencil-None-DeskLamp-308__trial_T20190908_220604_010430": 1.0,
|
| 36 |
+
"look_at_obj_in_light-Pencil-None-DeskLamp-308__trial_T20190908_220656_510400": 1.0,
|
| 37 |
+
"pick_and_place_simple-Mug-None-Desk-308__trial_T20190908_125200_737896": 1.0,
|
| 38 |
+
"pick_and_place_simple-Mug-None-Desk-308__trial_T20190909_203041_433487": 1.0,
|
| 39 |
+
"pick_and_place_simple-Mug-None-Desk-308__trial_T20190909_210238_431966": 1.0,
|
| 40 |
+
"pick_and_place_simple-Pencil-None-Shelf-308__trial_T20190908_121952_610012": 1.0,
|
| 41 |
+
"pick_and_place_simple-Pencil-None-Shelf-308__trial_T20190908_122024_052056": 1.0,
|
| 42 |
+
"pick_and_place_simple-Pencil-None-Shelf-308__trial_T20190908_122154_042763": 1.0,
|
| 43 |
+
"pick_and_place_simple-PepperShaker-None-Drawer-10__trial_T20190906_184021_215264": 1.0,
|
| 44 |
+
"pick_and_place_simple-PepperShaker-None-Drawer-10__trial_T20190918_154326_823501": 1.0,
|
| 45 |
+
"pick_and_place_simple-PepperShaker-None-Drawer-10__trial_T20190918_154424_844749": 1.0,
|
| 46 |
+
"pick_and_place_simple-SaltShaker-None-Cabinet-10__trial_T20190906_191429_743650": 1.0,
|
| 47 |
+
"pick_and_place_simple-SaltShaker-None-Cabinet-10__trial_T20190906_191445_723170": 1.0,
|
| 48 |
+
"pick_and_place_simple-SaltShaker-None-Cabinet-10__trial_T20190906_191501_563086": 1.0,
|
| 49 |
+
"pick_and_place_simple-SaltShaker-None-Drawer-10__trial_T20190909_021613_077537": 1.0,
|
| 50 |
+
"pick_and_place_simple-SaltShaker-None-Drawer-10__trial_T20190909_021650_880235": 1.0,
|
| 51 |
+
"pick_and_place_simple-SaltShaker-None-Drawer-10__trial_T20190909_021728_339782": 1.0,
|
| 52 |
+
"pick_and_place_simple-SoapBottle-None-Toilet-424__trial_T20190907_004321_405868": 1.0,
|
| 53 |
+
"pick_and_place_simple-SoapBottle-None-Toilet-424__trial_T20190907_004351_281384": 1.0,
|
| 54 |
+
"pick_and_place_simple-SoapBottle-None-Toilet-424__trial_T20190907_004404_604165": 1.0,
|
| 55 |
+
"pick_and_place_simple-Vase-None-Safe-219__trial_T20190908_205204_244321": 1.0,
|
| 56 |
+
"pick_and_place_simple-Vase-None-Safe-219__trial_T20190908_205221_748352": 1.0,
|
| 57 |
+
"pick_and_place_simple-Vase-None-Safe-219__trial_T20190908_205246_776817": 1.0,
|
| 58 |
+
"pick_and_place_simple-Watch-None-Safe-219__trial_T20190907_074524_006355": 1.0,
|
| 59 |
+
"pick_and_place_simple-Watch-None-Safe-219__trial_T20190907_074556_124850": 1.0,
|
| 60 |
+
"pick_and_place_simple-Watch-None-Safe-219__trial_T20190907_074643_810052": 1.0,
|
| 61 |
+
"pick_clean_then_place_in_recep-Bowl-None-Cabinet-10__trial_T20190909_061130_844814": 1.0,
|
| 62 |
+
"pick_clean_then_place_in_recep-Bowl-None-Cabinet-10__trial_T20190909_061158_110530": 1.0,
|
| 63 |
+
"pick_clean_then_place_in_recep-Bowl-None-Cabinet-10__trial_T20190909_061232_368489": 1.0,
|
| 64 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cabinet-424__trial_T20190908_022321_380927": 1.0,
|
| 65 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cabinet-424__trial_T20190908_022436_073995": 1.0,
|
| 66 |
+
"pick_clean_then_place_in_recep-Cloth-None-CounterTop-424__trial_T20190908_100632_546757": 1.0,
|
| 67 |
+
"pick_clean_then_place_in_recep-Cloth-None-CounterTop-424__trial_T20190908_114340_674467": 1.0,
|
| 68 |
+
"pick_clean_then_place_in_recep-Egg-None-Microwave-10__trial_T20190909_120554_888709": 1.0,
|
| 69 |
+
"pick_clean_then_place_in_recep-Egg-None-Microwave-10__trial_T20190909_120632_691361": 1.0,
|
| 70 |
+
"pick_clean_then_place_in_recep-Egg-None-Microwave-10__trial_T20190909_120712_273910": 1.0,
|
| 71 |
+
"pick_clean_then_place_in_recep-Knife-None-CounterTop-10__trial_T20190909_110347_624008": 1.0,
|
| 72 |
+
"pick_clean_then_place_in_recep-Knife-None-CounterTop-10__trial_T20190909_110445_675754": 1.0,
|
| 73 |
+
"pick_clean_then_place_in_recep-Knife-None-CounterTop-10__trial_T20190909_110531_148235": 1.0,
|
| 74 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_221208_560499": 1.0,
|
| 75 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_221300_362511": 1.0,
|
| 76 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_221355_558505": 1.0,
|
| 77 |
+
"pick_clean_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_032434_013084": 1.0,
|
| 78 |
+
"pick_clean_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_032518_891433": 1.0,
|
| 79 |
+
"pick_clean_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_032543_712058": 1.0,
|
| 80 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-10__trial_T20190908_213356_017769": 1.0,
|
| 81 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-10__trial_T20190908_213420_728917": 1.0,
|
| 82 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-10__trial_T20190908_213533_897289": 1.0,
|
| 83 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-424__trial_T20190908_214926_337906": 1.0,
|
| 84 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-424__trial_T20190908_214946_567644": 1.0,
|
| 85 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-424__trial_T20190908_215019_162873": 1.0,
|
| 86 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-424__trial_T20190907_074045_109439": 1.0,
|
| 87 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-424__trial_T20190907_074106_050405": 1.0,
|
| 88 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-424__trial_T20190907_074124_966890": 1.0,
|
| 89 |
+
"pick_clean_then_place_in_recep-Spatula-None-Drawer-10__trial_T20190907_080730_211959": 1.0,
|
| 90 |
+
"pick_clean_then_place_in_recep-Spatula-None-Drawer-10__trial_T20190907_080800_275989": 1.0,
|
| 91 |
+
"pick_clean_then_place_in_recep-Spatula-None-Drawer-10__trial_T20190907_080825_222432": 1.0,
|
| 92 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-10__trial_T20190908_091747_866951": 1.0,
|
| 93 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-10__trial_T20190908_091811_414150": 1.0,
|
| 94 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-10__trial_T20190908_091835_825830": 1.0,
|
| 95 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-10__trial_T20190909_123133_763972": 1.0,
|
| 96 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-10__trial_T20190909_174807_646433": 1.0,
|
| 97 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-10__trial_T20190909_174840_771703": 1.0,
|
| 98 |
+
"pick_cool_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_121559_082363": 1.0,
|
| 99 |
+
"pick_cool_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_121635_622676": 1.0,
|
| 100 |
+
"pick_cool_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_121710_650938": 1.0,
|
| 101 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_183715_299073": 1.0,
|
| 102 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_183807_477267": 1.0,
|
| 103 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_183853_958104": 1.0,
|
| 104 |
+
"pick_cool_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_114545_244903": 1.0,
|
| 105 |
+
"pick_cool_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_114622_738670": 1.0,
|
| 106 |
+
"pick_cool_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_114656_768805": 1.0,
|
| 107 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-10__trial_T20190907_033157_424297": 1.0,
|
| 108 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-10__trial_T20190907_033228_194678": 1.0,
|
| 109 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-10__trial_T20190907_033306_962974": 1.0,
|
| 110 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-10__trial_T20190909_102608_318800": 1.0,
|
| 111 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-10__trial_T20190909_102644_926781": 1.0,
|
| 112 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-10__trial_T20190909_102710_795182": 1.0,
|
| 113 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-10__trial_T20190906_182259_116320": 1.0,
|
| 114 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-10__trial_T20190906_182353_418140": 1.0,
|
| 115 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-10__trial_T20190906_182435_622538": 1.0,
|
| 116 |
+
"pick_heat_then_place_in_recep-Apple-None-GarbageCan-10__trial_T20190908_145050_918567": 1.0,
|
| 117 |
+
"pick_heat_then_place_in_recep-Apple-None-GarbageCan-10__trial_T20190908_145143_820541": 1.0,
|
| 118 |
+
"pick_heat_then_place_in_recep-Apple-None-GarbageCan-10__trial_T20190908_145356_918528": 1.0,
|
| 119 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-10__trial_T20190907_083346_800823": 1.0,
|
| 120 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-10__trial_T20190907_083429_887065": 1.0,
|
| 121 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-10__trial_T20190907_083507_594820": 1.0,
|
| 122 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-10__trial_T20190908_113432_673307": 1.0,
|
| 123 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-10__trial_T20190908_113523_123938": 1.0,
|
| 124 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-10__trial_T20190908_113610_425142": 1.0,
|
| 125 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_021100_341887": 1.0,
|
| 126 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_021200_669381": 1.0,
|
| 127 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_021247_306737": 1.0,
|
| 128 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_171806_406231": 1.0,
|
| 129 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_171850_960211": 0.0,
|
| 130 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_171933_349922": 1.0,
|
| 131 |
+
"pick_heat_then_place_in_recep-Potato-None-GarbageCan-10__trial_T20190907_161745_664033": 1.0,
|
| 132 |
+
"pick_heat_then_place_in_recep-Potato-None-GarbageCan-10__trial_T20190907_161853_945788": 1.0,
|
| 133 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-10__trial_T20190908_225046_020282": 1.0,
|
| 134 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-10__trial_T20190908_225359_617900": 1.0,
|
| 135 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-10__trial_T20190908_225453_272533": 1.0,
|
| 136 |
+
"pick_two_obj_and_place-CD-None-Safe-308__trial_T20190907_050942_897916": 1.0,
|
| 137 |
+
"pick_two_obj_and_place-CD-None-Safe-308__trial_T20190907_051013_060265": 1.0,
|
| 138 |
+
"pick_two_obj_and_place-CD-None-Safe-308__trial_T20190907_051056_585414": 1.0,
|
| 139 |
+
"pick_two_obj_and_place-KeyChain-None-Safe-219__trial_T20190909_011803_423115": 1.0,
|
| 140 |
+
"pick_two_obj_and_place-KeyChain-None-Safe-219__trial_T20190909_012027_782483": 1.0,
|
| 141 |
+
"pick_two_obj_and_place-PepperShaker-None-Drawer-10__trial_T20190908_010306_215435": 1.0,
|
| 142 |
+
"pick_two_obj_and_place-PepperShaker-None-Drawer-10__trial_T20190912_221016_460197": 1.0,
|
| 143 |
+
"pick_two_obj_and_place-PepperShaker-None-Drawer-10__trial_T20190912_221141_608117": 1.0,
|
| 144 |
+
"pick_two_obj_and_place-Pillow-None-Sofa-219__trial_T20190907_163240_345855": 1.0,
|
| 145 |
+
"pick_two_obj_and_place-Pillow-None-Sofa-219__trial_T20190907_163327_486300": 1.0,
|
| 146 |
+
"pick_two_obj_and_place-Pillow-None-Sofa-219__trial_T20190907_163408_914117": 1.0,
|
| 147 |
+
"pick_two_obj_and_place-SoapBar-None-Cabinet-424__trial_T20190909_081720_491733": 1.0,
|
| 148 |
+
"pick_two_obj_and_place-SoapBar-None-Cabinet-424__trial_T20190909_081746_857594": 1.0,
|
| 149 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-424__trial_T20190909_064053_839817": 1.0,
|
| 150 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-424__trial_T20190909_064221_368939": 1.0,
|
| 151 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-424__trial_T20190909_064309_357168": 1.0,
|
| 152 |
+
"pick_two_obj_and_place-ToiletPaper-None-Cabinet-424__trial_T20190906_202926_527010": 1.0
|
| 153 |
+
},
|
| 154 |
+
"traces": "eval-traces/round-1-valid_unseen.tar.gz"
|
| 155 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-2-valid_seen.json
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "hg-eval-cell.v1",
|
| 3 |
+
"method": "ahe",
|
| 4 |
+
"round": 2,
|
| 5 |
+
"pool": "valid_seen",
|
| 6 |
+
"stamp": "20261017T123952Z",
|
| 7 |
+
"run_id": "rsi10-20261017T123952Z-ahe-ckpt-r2-valid_seen",
|
| 8 |
+
"score": 1.0,
|
| 9 |
+
"n_scored": 140,
|
| 10 |
+
"n_invalid": 0,
|
| 11 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 12 |
+
"evaluated_from": {
|
| 13 |
+
"run_id": "rsi10-20261017T123952Z-ahe-train",
|
| 14 |
+
"round": 2,
|
| 15 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 16 |
+
"train_score": 1.0
|
| 17 |
+
},
|
| 18 |
+
"per_task": {
|
| 19 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-323__trial_T20190909_044715_250790": 1.0,
|
| 20 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-301__trial_T20190909_150719_492274": 1.0,
|
| 21 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-316__trial_T20190908_230702_962704": 1.0,
|
| 22 |
+
"look_at_obj_in_light-Box-None-DeskLamp-205__trial_T20190907_074425_330493": 1.0,
|
| 23 |
+
"look_at_obj_in_light-CD-None-DeskLamp-302__trial_T20190907_154618_526741": 1.0,
|
| 24 |
+
"look_at_obj_in_light-CD-None-DeskLamp-314__trial_T20190907_114323_767231": 1.0,
|
| 25 |
+
"look_at_obj_in_light-CD-None-DeskLamp-320__trial_T20190907_224451_655673": 1.0,
|
| 26 |
+
"look_at_obj_in_light-KeyChain-None-DeskLamp-327__trial_T20190906_202601_548273": 1.0,
|
| 27 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-328__trial_T20190908_201550_622420": 1.0,
|
| 28 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-302__trial_T20190909_150916_682139": 1.0,
|
| 29 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-323__trial_T20190908_053153_077977": 1.0,
|
| 30 |
+
"look_at_obj_in_light-Statue-None-DeskLamp-216__trial_T20190909_193045_208933": 1.0,
|
| 31 |
+
"look_at_obj_in_light-Vase-None-DeskLamp-303__trial_T20190907_150418_457594": 1.0,
|
| 32 |
+
"pick_and_place_simple-Book-None-SideTable-329__trial_T20190908_050633_745514": 1.0,
|
| 33 |
+
"pick_and_place_simple-Book-None-Sofa-229__trial_T20190907_042856_259139": 1.0,
|
| 34 |
+
"pick_and_place_simple-Bowl-None-CoffeeTable-201__trial_T20190907_171639_045329": 1.0,
|
| 35 |
+
"pick_and_place_simple-Box-None-Dresser-224__trial_T20190907_164104_229696": 1.0,
|
| 36 |
+
"pick_and_place_simple-Candle-None-Cart-401__trial_T20190909_081908_677973": 1.0,
|
| 37 |
+
"pick_and_place_simple-Candle-None-Toilet-407__trial_T20190909_055248_059513": 1.0,
|
| 38 |
+
"pick_and_place_simple-Candle-None-Toilet-429__trial_T20190908_052232_887934": 1.0,
|
| 39 |
+
"pick_and_place_simple-CellPhone-None-ArmChair-318__trial_T20190909_120047_968274": 1.0,
|
| 40 |
+
"pick_and_place_simple-CellPhone-None-Bed-324__trial_T20190907_233817_198528": 1.0,
|
| 41 |
+
"pick_and_place_simple-CreditCard-None-ArmChair-201__trial_T20190908_124340_258012": 1.0,
|
| 42 |
+
"pick_and_place_simple-CreditCard-None-Drawer-227__trial_T20190909_010644_297017": 1.0,
|
| 43 |
+
"pick_and_place_simple-Egg-None-Microwave-4__trial_T20190906_234406_356490": 1.0,
|
| 44 |
+
"pick_and_place_simple-Knife-None-SideTable-3__trial_T20190918_184236_557252": 1.0,
|
| 45 |
+
"pick_and_place_simple-Mug-None-Dresser-311__trial_T20190909_152837_739016": 1.0,
|
| 46 |
+
"pick_and_place_simple-Mug-None-SideTable-329__trial_T20190909_032318_169393": 1.0,
|
| 47 |
+
"pick_and_place_simple-Mug-None-SideTable-329__trial_T20190909_032340_274147": 1.0,
|
| 48 |
+
"pick_and_place_simple-Newspaper-None-Sofa-224__trial_T20190909_111324_949106": 1.0,
|
| 49 |
+
"pick_and_place_simple-Pencil-None-Desk-310__trial_T20190909_113054_894334": 1.0,
|
| 50 |
+
"pick_and_place_simple-Pencil-None-Dresser-330__trial_T20190909_071128_012892": 1.0,
|
| 51 |
+
"pick_and_place_simple-RemoteControl-None-ArmChair-230__trial_T20190909_021000_274398": 1.0,
|
| 52 |
+
"pick_and_place_simple-RemoteControl-None-Sofa-207__trial_T20190909_153609_373481": 1.0,
|
| 53 |
+
"pick_and_place_simple-SoapBar-None-Cart-401__trial_T20190907_054906_608944": 1.0,
|
| 54 |
+
"pick_and_place_simple-SoapBottle-None-Cabinet-414__trial_T20190908_110131_524518": 1.0,
|
| 55 |
+
"pick_and_place_simple-SoapBottle-None-CounterTop-417__trial_T20190910_112922_368384": 1.0,
|
| 56 |
+
"pick_and_place_simple-SprayBottle-None-Cabinet-413__trial_T20190907_114931_692464": 1.0,
|
| 57 |
+
"pick_and_place_simple-SprayBottle-None-GarbageCan-409__trial_T20190908_054742_818364": 1.0,
|
| 58 |
+
"pick_and_place_simple-SprayBottle-None-Toilet-415__trial_T20190909_075955_678702": 1.0,
|
| 59 |
+
"pick_and_place_simple-SprayBottle-None-Toilet-418__trial_T20190906_190942_706186": 1.0,
|
| 60 |
+
"pick_and_place_simple-TissueBox-None-Toilet-426__trial_T20190910_155319_795672": 1.0,
|
| 61 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-406__trial_T20190908_122858_883968": 1.0,
|
| 62 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-415__trial_T20190908_050518_595510": 1.0,
|
| 63 |
+
"pick_and_place_simple-Tomato-None-Microwave-13__trial_T20190908_124829_632660": 1.0,
|
| 64 |
+
"pick_and_place_simple-Vase-None-CoffeeTable-207__trial_T20190909_091246_807206": 1.0,
|
| 65 |
+
"pick_and_place_simple-Watch-None-SideTable-222__trial_T20190909_051813_197569": 1.0,
|
| 66 |
+
"pick_and_place_simple-WineBottle-None-Shelf-7__trial_T20190907_200154_378982": 1.0,
|
| 67 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-CounterTop-8__trial_T20190909_105559_983897": 1.0,
|
| 68 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-DiningTable-16__trial_T20190909_114508_617301": 1.0,
|
| 69 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-Drawer-2__trial_T20190908_121728_511866": 1.0,
|
| 70 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-Drawer-30__trial_T20190908_052007_212776": 1.0,
|
| 71 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-Drawer-8__trial_T20190909_124425_112757": 1.0,
|
| 72 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cabinet-405__trial_T20190907_080903_889497": 1.0,
|
| 73 |
+
"pick_clean_then_place_in_recep-Cloth-None-Drawer-423__trial_T20190908_140701_251653": 1.0,
|
| 74 |
+
"pick_clean_then_place_in_recep-DishSponge-None-Cart-401__trial_T20190907_024634_972453": 1.0,
|
| 75 |
+
"pick_clean_then_place_in_recep-DishSponge-None-CounterTop-403__trial_T20190908_144357_621068": 1.0,
|
| 76 |
+
"pick_clean_then_place_in_recep-Fork-None-CounterTop-23__trial_T20190908_233922_171295": 1.0,
|
| 77 |
+
"pick_clean_then_place_in_recep-Fork-None-Drawer-8__trial_T20190908_132152_999725": 1.0,
|
| 78 |
+
"pick_clean_then_place_in_recep-Ladle-None-CounterTop-14__trial_T20190909_113844_191747": 1.0,
|
| 79 |
+
"pick_clean_then_place_in_recep-Ladle-None-CounterTop-8__trial_T20190909_121908_219603": 1.0,
|
| 80 |
+
"pick_clean_then_place_in_recep-Ladle-None-DiningTable-16__trial_T20190909_183724_205399": 1.0,
|
| 81 |
+
"pick_clean_then_place_in_recep-Ladle-None-DiningTable-27__trial_T20190911_131350_027076": 1.0,
|
| 82 |
+
"pick_clean_then_place_in_recep-Ladle-None-DiningTable-4__trial_T20190909_164840_568811": 1.0,
|
| 83 |
+
"pick_clean_then_place_in_recep-Lettuce-None-CounterTop-16__trial_T20190909_051630_092360": 1.0,
|
| 84 |
+
"pick_clean_then_place_in_recep-Lettuce-None-Fridge-19__trial_T20190908_100138_446072": 1.0,
|
| 85 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-26__trial_T20190907_233056_022802": 1.0,
|
| 86 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-19__trial_T20190908_212725_836398": 1.0,
|
| 87 |
+
"pick_clean_then_place_in_recep-Plate-None-Fridge-5__trial_T20190909_112854_740612": 1.0,
|
| 88 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-402__trial_T20190908_055221_984342": 1.0,
|
| 89 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Drawer-423__trial_T20190906_202340_749336": 1.0,
|
| 90 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-410__trial_T20190906_201106_979461": 1.0,
|
| 91 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-428__trial_T20190907_041436_588106": 1.0,
|
| 92 |
+
"pick_clean_then_place_in_recep-Spatula-None-DiningTable-4__trial_T20190909_002804_564168": 1.0,
|
| 93 |
+
"pick_clean_then_place_in_recep-Tomato-None-CounterTop-25__trial_T20190909_012550_586494": 1.0,
|
| 94 |
+
"pick_cool_then_place_in_recep-Apple-None-CounterTop-14__trial_T20190909_044933_815840": 1.0,
|
| 95 |
+
"pick_cool_then_place_in_recep-Apple-None-GarbageCan-2__trial_T20190906_195943_081289": 1.0,
|
| 96 |
+
"pick_cool_then_place_in_recep-Apple-None-Microwave-19__trial_T20190906_210937_878489": 1.0,
|
| 97 |
+
"pick_cool_then_place_in_recep-Apple-None-Microwave-5__trial_T20190908_150807_823817": 1.0,
|
| 98 |
+
"pick_cool_then_place_in_recep-Bowl-None-Cabinet-20__trial_T20190909_112912_154874": 1.0,
|
| 99 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-7__trial_T20190909_045605_307949": 1.0,
|
| 100 |
+
"pick_cool_then_place_in_recep-Cup-None-Microwave-17__trial_T20190906_192817_654400": 1.0,
|
| 101 |
+
"pick_cool_then_place_in_recep-Cup-None-SideTable-21__trial_T20190906_192823_237997": 1.0,
|
| 102 |
+
"pick_cool_then_place_in_recep-Egg-None-Microwave-24__trial_T20190908_234112_645480": 1.0,
|
| 103 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-1__trial_T20190908_042713_075616": 1.0,
|
| 104 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-11__trial_T20190908_222555_651605": 1.0,
|
| 105 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-16__trial_T20190908_184242_348366": 1.0,
|
| 106 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-7__trial_T20190908_232648_241836": 1.0,
|
| 107 |
+
"pick_cool_then_place_in_recep-Pan-None-StoveBurner-18__trial_T20190906_181023_216915": 1.0,
|
| 108 |
+
"pick_cool_then_place_in_recep-Pan-None-StoveBurner-23__trial_T20190906_215856_374127": 1.0,
|
| 109 |
+
"pick_cool_then_place_in_recep-Plate-None-Cabinet-27__trial_T20190906_173120_350651": 1.0,
|
| 110 |
+
"pick_cool_then_place_in_recep-Plate-None-Cabinet-7__trial_T20190907_231206_512424": 1.0,
|
| 111 |
+
"pick_cool_then_place_in_recep-Plate-None-CounterTop-1__trial_T20190906_205324_559361": 1.0,
|
| 112 |
+
"pick_cool_then_place_in_recep-Pot-None-DiningTable-21__trial_T20190909_004531_429065": 1.0,
|
| 113 |
+
"pick_cool_then_place_in_recep-Tomato-None-CounterTop-12__trial_T20190909_063754_216554": 1.0,
|
| 114 |
+
"pick_cool_then_place_in_recep-Tomato-None-CounterTop-12__trial_T20190909_063844_274181": 1.0,
|
| 115 |
+
"pick_cool_then_place_in_recep-Tomato-None-GarbageCan-6__trial_T20190909_082934_483899": 1.0,
|
| 116 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-13__trial_T20190910_173916_331859": 1.0,
|
| 117 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-18__trial_T20190909_012524_159092": 1.0,
|
| 118 |
+
"pick_cool_then_place_in_recep-WineBottle-None-DiningTable-17__trial_T20190908_024426_412044": 1.0,
|
| 119 |
+
"pick_heat_then_place_in_recep-Apple-None-DiningTable-26__trial_T20190907_060234_011675": 1.0,
|
| 120 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-22__trial_T20190907_173251_960848": 1.0,
|
| 121 |
+
"pick_heat_then_place_in_recep-Egg-None-CounterTop-2__trial_T20190908_122951_021026": 1.0,
|
| 122 |
+
"pick_heat_then_place_in_recep-Egg-None-Fridge-14__trial_T20190909_091314_636733": 1.0,
|
| 123 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-26__trial_T20190909_062333_424779": 1.0,
|
| 124 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-3__trial_T20190909_014639_335717": 1.0,
|
| 125 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-1__trial_T20190907_222640_487432": 1.0,
|
| 126 |
+
"pick_heat_then_place_in_recep-Mug-None-SideTable-21__trial_T20190909_090729_088825": 1.0,
|
| 127 |
+
"pick_heat_then_place_in_recep-Plate-None-Cabinet-1__trial_T20190908_070946_578973": 1.0,
|
| 128 |
+
"pick_heat_then_place_in_recep-Plate-None-DiningTable-28__trial_T20190908_001247_096796": 1.0,
|
| 129 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-11__trial_T20190909_011341_436523": 1.0,
|
| 130 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-12__trial_T20190908_014451_271080": 1.0,
|
| 131 |
+
"pick_heat_then_place_in_recep-Tomato-None-DiningTable-16__trial_T20190907_201243_698086": 1.0,
|
| 132 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-15__trial_T20190909_020200_054379": 1.0,
|
| 133 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-23__trial_T20190909_082320_103350": 1.0,
|
| 134 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-24__trial_T20190908_033721_967359": 1.0,
|
| 135 |
+
"pick_two_obj_and_place-AlarmClock-None-Dresser-305__trial_T20190907_165826_194855": 1.0,
|
| 136 |
+
"pick_two_obj_and_place-Book-None-Desk-302__trial_T20190906_181233_363875": 1.0,
|
| 137 |
+
"pick_two_obj_and_place-Book-None-Desk-313__trial_T20190908_125930_920681": 1.0,
|
| 138 |
+
"pick_two_obj_and_place-Box-None-CoffeeTable-213__trial_T20190906_200927_069627": 1.0,
|
| 139 |
+
"pick_two_obj_and_place-CD-None-Drawer-304__trial_T20190907_230232_832893": 1.0,
|
| 140 |
+
"pick_two_obj_and_place-CreditCard-None-Dresser-311__trial_T20190907_201917_045715": 1.0,
|
| 141 |
+
"pick_two_obj_and_place-CreditCard-None-Safe-323__trial_T20190907_001129_214240": 1.0,
|
| 142 |
+
"pick_two_obj_and_place-Glassbottle-None-Shelf-1__trial_T20190907_122204_941737": 1.0,
|
| 143 |
+
"pick_two_obj_and_place-Knife-None-Drawer-18__trial_T20190907_065232_689984": 1.0,
|
| 144 |
+
"pick_two_obj_and_place-Newspaper-None-Drawer-224__trial_T20190911_101248_326533": 1.0,
|
| 145 |
+
"pick_two_obj_and_place-Pan-None-CounterTop-14__trial_T20190907_012519_974044": 1.0,
|
| 146 |
+
"pick_two_obj_and_place-RemoteControl-None-Ottoman-203__trial_T20190906_182952_858723": 1.0,
|
| 147 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-418__trial_T20190909_055538_380023": 1.0,
|
| 148 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-418__trial_T20190909_055649_717880": 1.0,
|
| 149 |
+
"pick_two_obj_and_place-Spatula-None-Drawer-13__trial_T20190908_183331_203888": 1.0,
|
| 150 |
+
"pick_two_obj_and_place-SprayBottle-None-Cabinet-407__trial_T20190907_144556_144188": 1.0,
|
| 151 |
+
"pick_two_obj_and_place-SprayBottle-None-GarbageCan-419__trial_T20190908_164236_518264": 1.0,
|
| 152 |
+
"pick_two_obj_and_place-SprayBottle-None-Toilet-402__trial_T20190910_222914_814642": 1.0,
|
| 153 |
+
"pick_two_obj_and_place-SprayBottle-None-Toilet-429__trial_T20190907_033843_707544": 1.0,
|
| 154 |
+
"pick_two_obj_and_place-TissueBox-None-Toilet-426__trial_T20190909_044602_338962": 1.0,
|
| 155 |
+
"pick_two_obj_and_place-ToiletPaper-None-Drawer-423__trial_T20190907_111251_461099": 1.0,
|
| 156 |
+
"pick_two_obj_and_place-ToiletPaper-None-Toilet-408__trial_T20190909_080302_174780": 1.0,
|
| 157 |
+
"pick_two_obj_and_place-Vase-None-Desk-204__trial_T20190906_181531_703961": 1.0,
|
| 158 |
+
"pick_two_obj_and_place-Watch-None-Dresser-205__trial_T20190907_182211_592010": 1.0
|
| 159 |
+
},
|
| 160 |
+
"traces": "eval-traces/round-2-valid_seen.tar.gz"
|
| 161 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-2-valid_train.json
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "hg-eval-cell.v1",
|
| 3 |
+
"method": "ahe",
|
| 4 |
+
"round": 2,
|
| 5 |
+
"pool": "valid_train",
|
| 6 |
+
"stamp": "20261017T123952Z",
|
| 7 |
+
"run_id": "rsi10-20261017T123952Z-ahe-ckpt-r2-valid_train",
|
| 8 |
+
"score": 1.0,
|
| 9 |
+
"n_scored": 200,
|
| 10 |
+
"n_invalid": 0,
|
| 11 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 12 |
+
"evaluated_from": {
|
| 13 |
+
"run_id": "rsi10-20261017T123952Z-ahe-train",
|
| 14 |
+
"round": 2,
|
| 15 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 16 |
+
"train_score": 1.0
|
| 17 |
+
},
|
| 18 |
+
"per_task": {
|
| 19 |
+
"look_at_obj_in_light-Book-None-DeskLamp-302__trial_T20190909_085137_911990": 1.0,
|
| 20 |
+
"look_at_obj_in_light-Book-None-DeskLamp-317__trial_T20190909_201225_052100": 1.0,
|
| 21 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-304__trial_T20190907_232227_752681": 1.0,
|
| 22 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-305__trial_T20190909_000758_132057": 1.0,
|
| 23 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-316__trial_T20190908_230650_245482": 1.0,
|
| 24 |
+
"look_at_obj_in_light-CD-None-DeskLamp-307__trial_T20190906_200435_424001": 1.0,
|
| 25 |
+
"look_at_obj_in_light-CD-None-DeskLamp-323__trial_T20190908_051124_983144": 1.0,
|
| 26 |
+
"look_at_obj_in_light-CD-None-DeskLamp-327__trial_T20190909_032921_008718": 1.0,
|
| 27 |
+
"look_at_obj_in_light-CreditCard-None-DeskLamp-314__trial_T20190906_201548_667159": 1.0,
|
| 28 |
+
"look_at_obj_in_light-KeyChain-None-DeskLamp-327__trial_T20190906_202538_399742": 1.0,
|
| 29 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-309__trial_T20190907_185713_398582": 1.0,
|
| 30 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-319__trial_T20190908_182720_056041": 1.0,
|
| 31 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-324__trial_T20190908_071137_867346": 1.0,
|
| 32 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-323__trial_T20190907_041046_628363": 1.0,
|
| 33 |
+
"look_at_obj_in_light-Pen-None-DeskLamp-305__trial_T20190907_115824_746935": 1.0,
|
| 34 |
+
"look_at_obj_in_light-Pen-None-DeskLamp-316__trial_T20190908_061847_951064": 1.0,
|
| 35 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-309__trial_T20190908_113756_084511": 1.0,
|
| 36 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-323__trial_T20190908_053117_107031": 1.0,
|
| 37 |
+
"look_at_obj_in_light-TissueBox-None-DeskLamp-216__trial_T20190908_033138_836240": 1.0,
|
| 38 |
+
"pick_and_place_simple-AlarmClock-None-Desk-307__trial_T20190907_072317_014092": 1.0,
|
| 39 |
+
"pick_and_place_simple-AlarmClock-None-Dresser-319__trial_T20190910_195319_108102": 1.0,
|
| 40 |
+
"pick_and_place_simple-Book-None-Desk-313__trial_T20190909_140606_239445": 1.0,
|
| 41 |
+
"pick_and_place_simple-CD-None-Dresser-318__trial_T20190907_190246_917982": 1.0,
|
| 42 |
+
"pick_and_place_simple-CD-None-Shelf-319__trial_T20190908_061008_714389": 1.0,
|
| 43 |
+
"pick_and_place_simple-Candle-None-Cabinet-428__trial_T20190907_024255_988230": 1.0,
|
| 44 |
+
"pick_and_place_simple-Candle-None-Toilet-427__trial_T20190909_030427_604487": 1.0,
|
| 45 |
+
"pick_and_place_simple-CellPhone-None-Bed-321__trial_T20190908_231541_058766": 1.0,
|
| 46 |
+
"pick_and_place_simple-CellPhone-None-Desk-316__trial_T20190911_203517_902296": 1.0,
|
| 47 |
+
"pick_and_place_simple-Cloth-None-Toilet-417__trial_T20190908_163202_959027": 1.0,
|
| 48 |
+
"pick_and_place_simple-CreditCard-None-ArmChair-202__trial_T20190909_011606_013059": 1.0,
|
| 49 |
+
"pick_and_place_simple-CreditCard-None-Sofa-216__trial_T20190909_110455_224621": 1.0,
|
| 50 |
+
"pick_and_place_simple-Fork-None-Drawer-12__trial_T20190907_151050_079642": 1.0,
|
| 51 |
+
"pick_and_place_simple-Glassbottle-None-Cabinet-17__trial_T20190906_182221_722403": 1.0,
|
| 52 |
+
"pick_and_place_simple-HandTowel-None-Cabinet-412__trial_T20190906_200520_896836": 1.0,
|
| 53 |
+
"pick_and_place_simple-KeyChain-None-ArmChair-318__trial_T20190909_114631_650488": 1.0,
|
| 54 |
+
"pick_and_place_simple-KeyChain-None-CoffeeTable-227__trial_T20190907_161844_256041": 1.0,
|
| 55 |
+
"pick_and_place_simple-KeyChain-None-SideTable-309__trial_T20190908_215011_025401": 1.0,
|
| 56 |
+
"pick_and_place_simple-KeyChain-None-SideTable-322__trial_T20190909_091733_848923": 1.0,
|
| 57 |
+
"pick_and_place_simple-KeyChain-None-Sofa-225__trial_T20190908_131129_251514": 1.0,
|
| 58 |
+
"pick_and_place_simple-KeyChain-None-Sofa-229__trial_T20190908_123359_988104": 1.0,
|
| 59 |
+
"pick_and_place_simple-Pan-None-DiningTable-15__trial_T20190908_182413_239334": 1.0,
|
| 60 |
+
"pick_and_place_simple-Pen-None-SideTable-309__trial_T20190907_051900_451316": 1.0,
|
| 61 |
+
"pick_and_place_simple-PepperShaker-None-CounterTop-27__trial_T20190909_010859_836097": 1.0,
|
| 62 |
+
"pick_and_place_simple-Pillow-None-ArmChair-214__trial_T20190909_010338_250180": 1.0,
|
| 63 |
+
"pick_and_place_simple-Pillow-None-ArmChair-321__trial_T20190908_104900_888704": 1.0,
|
| 64 |
+
"pick_and_place_simple-RemoteControl-None-ArmChair-222__trial_T20190906_201505_001155": 1.0,
|
| 65 |
+
"pick_and_place_simple-RemoteControl-None-Ottoman-208__trial_T20190909_100851_710423": 1.0,
|
| 66 |
+
"pick_and_place_simple-SoapBottle-None-Cart-430__trial_T20190909_100609_714213": 1.0,
|
| 67 |
+
"pick_and_place_simple-SoapBottle-None-GarbageCan-11__trial_T20190908_175650_970050": 1.0,
|
| 68 |
+
"pick_and_place_simple-SprayBottle-None-CounterTop-417__trial_T20190909_091329_750799": 1.0,
|
| 69 |
+
"pick_and_place_simple-SprayBottle-None-GarbageCan-428__trial_T20190909_101522_923920": 1.0,
|
| 70 |
+
"pick_and_place_simple-SprayBottle-None-Toilet-405__trial_T20190908_021347_460567": 1.0,
|
| 71 |
+
"pick_and_place_simple-Statue-None-CoffeeTable-229__trial_T20190908_132941_479938": 1.0,
|
| 72 |
+
"pick_and_place_simple-ToiletPaper-None-GarbageCan-403__trial_T20190907_034648_807245": 1.0,
|
| 73 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-402__trial_T20190908_030828_744767": 1.0,
|
| 74 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-410__trial_T20190907_021559_670421": 1.0,
|
| 75 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-412__trial_T20190907_181227_790902": 1.0,
|
| 76 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-428__trial_T20190906_201316_921947": 1.0,
|
| 77 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-430__trial_T20190908_102055_678050": 1.0,
|
| 78 |
+
"pick_and_place_simple-Tomato-None-DiningTable-26__trial_T20190908_010933_200567": 1.0,
|
| 79 |
+
"pick_and_place_simple-Tomato-None-Microwave-13__trial_T20190908_125127_168939": 1.0,
|
| 80 |
+
"pick_and_place_simple-Tomato-None-Microwave-5__trial_T20190908_174014_984950": 1.0,
|
| 81 |
+
"pick_and_place_simple-Tomato-None-Microwave-8__trial_T20190907_205031_274716": 1.0,
|
| 82 |
+
"pick_and_place_simple-Vase-None-CoffeeTable-206__trial_T20190909_024648_216020": 1.0,
|
| 83 |
+
"pick_and_place_simple-Watch-None-CoffeeTable-213__trial_T20190909_010805_852491": 1.0,
|
| 84 |
+
"pick_clean_then_place_in_recep-Bowl-None-Shelf-7__trial_T20190908_152949_169018": 1.0,
|
| 85 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cart-401__trial_T20190907_045451_101032": 1.0,
|
| 86 |
+
"pick_clean_then_place_in_recep-Cloth-None-Drawer-416__trial_T20190908_040722_151303": 1.0,
|
| 87 |
+
"pick_clean_then_place_in_recep-Cloth-None-Drawer-423__trial_T20190908_140728_318318": 1.0,
|
| 88 |
+
"pick_clean_then_place_in_recep-Cloth-None-Toilet-406__trial_T20190908_102735_461565": 1.0,
|
| 89 |
+
"pick_clean_then_place_in_recep-DishSponge-None-Shelf-20__trial_T20190907_222456_204496": 1.0,
|
| 90 |
+
"pick_clean_then_place_in_recep-Egg-None-GarbageCan-11__trial_T20190906_181033_636334": 1.0,
|
| 91 |
+
"pick_clean_then_place_in_recep-Fork-None-CounterTop-24__trial_T20190907_032458_736277": 1.0,
|
| 92 |
+
"pick_clean_then_place_in_recep-Fork-None-DiningTable-24__trial_T20190906_205216_940941": 1.0,
|
| 93 |
+
"pick_clean_then_place_in_recep-Fork-None-SideTable-21__trial_T20190909_041401_796447": 1.0,
|
| 94 |
+
"pick_clean_then_place_in_recep-Kettle-None-Cabinet-2__trial_T20190909_042935_977031": 1.0,
|
| 95 |
+
"pick_clean_then_place_in_recep-Kettle-None-DiningTable-17__trial_T20190909_023518_602816": 1.0,
|
| 96 |
+
"pick_clean_then_place_in_recep-Kettle-None-Shelf-7__trial_T20190907_200421_808214": 1.0,
|
| 97 |
+
"pick_clean_then_place_in_recep-Kettle-None-StoveBurner-30__trial_T20190906_200053_697370": 1.0,
|
| 98 |
+
"pick_clean_then_place_in_recep-Knife-None-DiningTable-23__trial_T20190908_142126_854011": 1.0,
|
| 99 |
+
"pick_clean_then_place_in_recep-Ladle-None-CounterTop-14__trial_T20190909_113924_604801": 1.0,
|
| 100 |
+
"pick_clean_then_place_in_recep-Ladle-None-Drawer-30__trial_T20190908_005155_378803": 1.0,
|
| 101 |
+
"pick_clean_then_place_in_recep-Ladle-None-Drawer-4__trial_T20190909_161523_929674": 1.0,
|
| 102 |
+
"pick_clean_then_place_in_recep-Lettuce-None-CounterTop-15__trial_T20190907_070041_442493": 1.0,
|
| 103 |
+
"pick_clean_then_place_in_recep-Lettuce-None-Fridge-13__trial_T20190908_203156_157438": 1.0,
|
| 104 |
+
"pick_clean_then_place_in_recep-Lettuce-None-GarbageCan-17__trial_T20190907_163845_626537": 1.0,
|
| 105 |
+
"pick_clean_then_place_in_recep-Pan-None-Cabinet-1__trial_T20190908_130833_956410": 1.0,
|
| 106 |
+
"pick_clean_then_place_in_recep-Pan-None-Fridge-1__trial_T20190908_105549_705446": 1.0,
|
| 107 |
+
"pick_clean_then_place_in_recep-Pan-None-StoveBurner-20__trial_T20190908_113730_305436": 1.0,
|
| 108 |
+
"pick_clean_then_place_in_recep-Plate-None-Cabinet-13__trial_T20190909_123604_776156": 1.0,
|
| 109 |
+
"pick_clean_then_place_in_recep-Pot-None-DiningTable-26__trial_T20190906_210506_116438": 1.0,
|
| 110 |
+
"pick_clean_then_place_in_recep-Potato-None-CounterTop-5__trial_T20190909_123212_517019": 1.0,
|
| 111 |
+
"pick_clean_then_place_in_recep-Potato-None-Fridge-17__trial_T20190909_135834_661867": 1.0,
|
| 112 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-428__trial_T20190908_084117_719605": 1.0,
|
| 113 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-409__trial_T20190908_025402_020595": 1.0,
|
| 114 |
+
"pick_clean_then_place_in_recep-SoapBar-None-GarbageCan-416__trial_T20190907_024728_127108": 1.0,
|
| 115 |
+
"pick_clean_then_place_in_recep-SoapBar-None-GarbageCan-429__trial_T20190909_015556_293557": 1.0,
|
| 116 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-420__trial_T20190908_043134_210616": 1.0,
|
| 117 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-428__trial_T20190907_041322_837354": 1.0,
|
| 118 |
+
"pick_clean_then_place_in_recep-Spatula-None-CounterTop-13__trial_T20190909_023039_986825": 1.0,
|
| 119 |
+
"pick_clean_then_place_in_recep-Tomato-None-Fridge-20__trial_T20190909_091539_383661": 1.0,
|
| 120 |
+
"pick_clean_then_place_in_recep-Tomato-None-SideTable-21__trial_T20190907_164958_308793": 1.0,
|
| 121 |
+
"pick_cool_then_place_in_recep-Bowl-None-Cabinet-18__trial_T20190908_144624_086654": 1.0,
|
| 122 |
+
"pick_cool_then_place_in_recep-Bowl-None-Shelf-20__trial_T20190908_034339_870890": 1.0,
|
| 123 |
+
"pick_cool_then_place_in_recep-Cup-None-Cabinet-26__trial_T20190909_085908_816209": 1.0,
|
| 124 |
+
"pick_cool_then_place_in_recep-Cup-None-Cabinet-30__trial_T20190909_090746_864458": 1.0,
|
| 125 |
+
"pick_cool_then_place_in_recep-Egg-None-CounterTop-27__trial_T20190909_002015_890646": 1.0,
|
| 126 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-24__trial_T20190908_015109_682752": 1.0,
|
| 127 |
+
"pick_cool_then_place_in_recep-Lettuce-None-DiningTable-18__trial_T20190909_122629_020439": 1.0,
|
| 128 |
+
"pick_cool_then_place_in_recep-Lettuce-None-DiningTable-24__trial_T20190908_062436_694989": 1.0,
|
| 129 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-11__trial_T20190908_021957_189338": 1.0,
|
| 130 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-14__trial_T20190906_182932_157770": 1.0,
|
| 131 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-23__trial_T20190908_143209_571893": 1.0,
|
| 132 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-11__trial_T20190908_204414_053313": 1.0,
|
| 133 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-15__trial_T20190909_003904_518800": 1.0,
|
| 134 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-23__trial_T20190909_005833_061416": 1.0,
|
| 135 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-7__trial_T20190909_094708_361033": 1.0,
|
| 136 |
+
"pick_cool_then_place_in_recep-Pan-None-StoveBurner-23__trial_T20190906_215826_707811": 1.0,
|
| 137 |
+
"pick_cool_then_place_in_recep-Plate-None-DiningTable-23__trial_T20190910_025008_561989": 1.0,
|
| 138 |
+
"pick_cool_then_place_in_recep-Plate-None-Shelf-7__trial_T20190907_125004_299560": 1.0,
|
| 139 |
+
"pick_cool_then_place_in_recep-Pot-None-CounterTop-5__trial_T20190908_073249_042493": 1.0,
|
| 140 |
+
"pick_cool_then_place_in_recep-Pot-None-DiningTable-27__trial_T20190909_013328_302952": 1.0,
|
| 141 |
+
"pick_cool_then_place_in_recep-Potato-None-CounterTop-30__trial_T20190908_111757_114406": 1.0,
|
| 142 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-5__trial_T20190910_115040_425451": 1.0,
|
| 143 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-13__trial_T20190910_173429_847749": 1.0,
|
| 144 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-14__trial_T20190907_024221_811233": 1.0,
|
| 145 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-5__trial_T20190908_132124_203759": 1.0,
|
| 146 |
+
"pick_cool_then_place_in_recep-WineBottle-None-Cabinet-17__trial_T20190907_064115_485667": 1.0,
|
| 147 |
+
"pick_cool_then_place_in_recep-WineBottle-None-DiningTable-17__trial_T20190908_003313_375871": 1.0,
|
| 148 |
+
"pick_cool_then_place_in_recep-WineBottle-None-GarbageCan-16__trial_T20190907_014908_758565": 1.0,
|
| 149 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-6__trial_T20190908_153841_522662": 1.0,
|
| 150 |
+
"pick_heat_then_place_in_recep-Apple-None-SideTable-28__trial_T20190906_180828_374034": 1.0,
|
| 151 |
+
"pick_heat_then_place_in_recep-Cup-None-Shelf-1__trial_T20190906_230051_015449": 1.0,
|
| 152 |
+
"pick_heat_then_place_in_recep-Cup-None-SideTable-3__trial_T20190908_210847_591144": 1.0,
|
| 153 |
+
"pick_heat_then_place_in_recep-Egg-None-DiningTable-15__trial_T20190908_042212_100074": 1.0,
|
| 154 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-23__trial_T20190911_011457_072067": 1.0,
|
| 155 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-2__trial_T20190907_070838_688262": 1.0,
|
| 156 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-21__trial_T20190908_113549_665152": 1.0,
|
| 157 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-22__trial_T20190906_184650_216044": 1.0,
|
| 158 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-5__trial_T20190908_040351_384338": 1.0,
|
| 159 |
+
"pick_heat_then_place_in_recep-Mug-None-SideTable-21__trial_T20190909_090802_375850": 1.0,
|
| 160 |
+
"pick_heat_then_place_in_recep-Mug-None-SideTable-28__trial_T20190908_212801_623417": 1.0,
|
| 161 |
+
"pick_heat_then_place_in_recep-Plate-None-Cabinet-7__trial_T20190907_144322_406779": 1.0,
|
| 162 |
+
"pick_heat_then_place_in_recep-Plate-None-CounterTop-1__trial_T20190909_115700_060162": 1.0,
|
| 163 |
+
"pick_heat_then_place_in_recep-Potato-None-CounterTop-25__trial_T20190908_003752_653811": 1.0,
|
| 164 |
+
"pick_heat_then_place_in_recep-Potato-None-DiningTable-16__trial_T20190908_015009_437240": 1.0,
|
| 165 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-12__trial_T20190910_094522_460953": 1.0,
|
| 166 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-27__trial_T20190908_143711_459299": 1.0,
|
| 167 |
+
"pick_heat_then_place_in_recep-Tomato-None-CounterTop-2__trial_T20190908_171656_745023": 1.0,
|
| 168 |
+
"pick_heat_then_place_in_recep-Tomato-None-CounterTop-20__trial_T20190909_041153_700490": 1.0,
|
| 169 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-12__trial_T20190906_190527_670222": 1.0,
|
| 170 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-14__trial_T20190908_091828_220110": 1.0,
|
| 171 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-15__trial_T20190909_020126_376897": 1.0,
|
| 172 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-24__trial_T20190908_033524_642305": 1.0,
|
| 173 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-16__trial_T20190906_171827_526847": 1.0,
|
| 174 |
+
"pick_two_obj_and_place-Book-None-Desk-302__trial_T20190906_181314_259738": 1.0,
|
| 175 |
+
"pick_two_obj_and_place-Book-None-Desk-309__trial_T20190909_061156_951604": 1.0,
|
| 176 |
+
"pick_two_obj_and_place-Box-None-CoffeeTable-230__trial_T20190908_124255_946115": 1.0,
|
| 177 |
+
"pick_two_obj_and_place-CD-None-Drawer-306__trial_T20190907_025539_829173": 1.0,
|
| 178 |
+
"pick_two_obj_and_place-CD-None-Dresser-303__trial_T20190908_085826_396748": 1.0,
|
| 179 |
+
"pick_two_obj_and_place-Candle-None-CounterTop-406__trial_T20190908_045958_916084": 1.0,
|
| 180 |
+
"pick_two_obj_and_place-CellPhone-None-Desk-312__trial_T20190908_122230_946481": 1.0,
|
| 181 |
+
"pick_two_obj_and_place-CellPhone-None-Drawer-318__trial_T20190908_104535_936869": 1.0,
|
| 182 |
+
"pick_two_obj_and_place-CellPhone-None-Drawer-329__trial_T20190909_030028_020737": 1.0,
|
| 183 |
+
"pick_two_obj_and_place-CellPhone-None-Dresser-330__trial_T20190909_060924_095249": 1.0,
|
| 184 |
+
"pick_two_obj_and_place-CellPhone-None-Sofa-224__trial_T20190918_223409_525979": 1.0,
|
| 185 |
+
"pick_two_obj_and_place-Cloth-None-Drawer-411__trial_T20190908_190008_902235": 1.0,
|
| 186 |
+
"pick_two_obj_and_place-CreditCard-None-Desk-313__trial_T20190909_104504_038752": 1.0,
|
| 187 |
+
"pick_two_obj_and_place-CreditCard-None-DiningTable-329__trial_T20190918_154222_318527": 1.0,
|
| 188 |
+
"pick_two_obj_and_place-CreditCard-None-Safe-323__trial_T20190907_001424_961488": 1.0,
|
| 189 |
+
"pick_two_obj_and_place-CreditCard-None-Sofa-206__trial_T20190906_203615_424745": 1.0,
|
| 190 |
+
"pick_two_obj_and_place-Cup-None-Shelf-1__trial_T20190908_015402_128805": 1.0,
|
| 191 |
+
"pick_two_obj_and_place-KeyChain-None-Dresser-318__trial_T20190907_181205_590674": 1.0,
|
| 192 |
+
"pick_two_obj_and_place-KeyChain-None-Ottoman-208__trial_T20190907_232759_901444": 1.0,
|
| 193 |
+
"pick_two_obj_and_place-KeyChain-None-Sofa-225__trial_T20190907_143028_102387": 1.0,
|
| 194 |
+
"pick_two_obj_and_place-Newspaper-None-ArmChair-214__trial_T20190909_010843_771227": 1.0,
|
| 195 |
+
"pick_two_obj_and_place-Newspaper-None-Sofa-230__trial_T20190908_035335_001162": 1.0,
|
| 196 |
+
"pick_two_obj_and_place-Pencil-None-Drawer-327__trial_T20190908_103604_088470": 1.0,
|
| 197 |
+
"pick_two_obj_and_place-Pencil-None-SideTable-329__trial_T20190909_040132_412120": 1.0,
|
| 198 |
+
"pick_two_obj_and_place-Pillow-None-Ottoman-208__trial_T20190907_030106_770418": 1.0,
|
| 199 |
+
"pick_two_obj_and_place-RemoteControl-None-ArmChair-208__trial_T20190908_000903_032547": 1.0,
|
| 200 |
+
"pick_two_obj_and_place-RemoteControl-None-Ottoman-210__trial_T20190906_202114_729948": 1.0,
|
| 201 |
+
"pick_two_obj_and_place-RemoteControl-None-Sofa-207__trial_T20190908_111223_597180": 1.0,
|
| 202 |
+
"pick_two_obj_and_place-SoapBar-None-Cabinet-428__trial_T20190910_231209_039518": 1.0,
|
| 203 |
+
"pick_two_obj_and_place-SoapBar-None-Drawer-420__trial_T20190908_124733_053705": 1.0,
|
| 204 |
+
"pick_two_obj_and_place-SoapBottle-None-Cabinet-417__trial_T20190909_211711_664720": 1.0,
|
| 205 |
+
"pick_two_obj_and_place-SoapBottle-None-Cart-401__trial_T20190908_215242_345375": 1.0,
|
| 206 |
+
"pick_two_obj_and_place-SoapBottle-None-Toilet-426__trial_T20190907_184729_585161": 1.0,
|
| 207 |
+
"pick_two_obj_and_place-SprayBottle-None-CounterTop-409__trial_T20190908_131755_202053": 1.0,
|
| 208 |
+
"pick_two_obj_and_place-SprayBottle-None-GarbageCan-413__trial_T20190912_044451_035192": 1.0,
|
| 209 |
+
"pick_two_obj_and_place-SprayBottle-None-GarbageCan-420__trial_T20190907_174658_354066": 1.0,
|
| 210 |
+
"pick_two_obj_and_place-SprayBottle-None-Toilet-417__trial_T20190908_071820_505015": 1.0,
|
| 211 |
+
"pick_two_obj_and_place-Statue-None-Dresser-213__trial_T20190909_065309_623947": 1.0,
|
| 212 |
+
"pick_two_obj_and_place-TissueBox-None-CoffeeTable-220__trial_T20190909_145750_484036": 1.0,
|
| 213 |
+
"pick_two_obj_and_place-TissueBox-None-CoffeeTable-230__trial_T20190909_145658_750781": 1.0,
|
| 214 |
+
"pick_two_obj_and_place-TissueBox-None-DiningTable-230__trial_T20190909_145553_211575": 1.0,
|
| 215 |
+
"pick_two_obj_and_place-ToiletPaper-None-Cabinet-412__trial_T20190908_141555_713466": 1.0,
|
| 216 |
+
"pick_two_obj_and_place-ToiletPaper-None-Drawer-409__trial_T20190906_193417_937668": 1.0,
|
| 217 |
+
"pick_two_obj_and_place-ToiletPaper-None-Toilet-405__trial_T20190909_065947_451268": 1.0,
|
| 218 |
+
"pick_two_obj_and_place-Watch-None-CoffeeTable-209__trial_T20190909_020350_646515": 1.0
|
| 219 |
+
},
|
| 220 |
+
"traces": "eval-traces/round-2-valid_train.tar.gz"
|
| 221 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-2-valid_unseen.json
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "hg-eval-cell.v1",
|
| 3 |
+
"method": "ahe",
|
| 4 |
+
"round": 2,
|
| 5 |
+
"pool": "valid_unseen",
|
| 6 |
+
"stamp": "20261017T123952Z",
|
| 7 |
+
"run_id": "rsi10-20261017T123952Z-ahe-ckpt-r2-valid_unseen",
|
| 8 |
+
"score": 1.0,
|
| 9 |
+
"n_scored": 134,
|
| 10 |
+
"n_invalid": 0,
|
| 11 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 12 |
+
"evaluated_from": {
|
| 13 |
+
"run_id": "rsi10-20261017T123952Z-ahe-train",
|
| 14 |
+
"round": 2,
|
| 15 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 16 |
+
"train_score": 1.0
|
| 17 |
+
},
|
| 18 |
+
"per_task": {
|
| 19 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-308__trial_T20190908_222917_366542": 1.0,
|
| 20 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-308__trial_T20190908_222933_607649": 1.0,
|
| 21 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-308__trial_T20190908_222951_616606": 1.0,
|
| 22 |
+
"look_at_obj_in_light-Book-None-DeskLamp-308__trial_T20190908_020029_636862": 1.0,
|
| 23 |
+
"look_at_obj_in_light-Book-None-DeskLamp-308__trial_T20190908_020048_814402": 1.0,
|
| 24 |
+
"look_at_obj_in_light-Book-None-DeskLamp-308__trial_T20190908_144951_587345": 1.0,
|
| 25 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-308__trial_T20190907_133919_856963": 1.0,
|
| 26 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-308__trial_T20190907_133935_066606": 1.0,
|
| 27 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-308__trial_T20190907_133953_562557": 1.0,
|
| 28 |
+
"look_at_obj_in_light-CD-None-DeskLamp-308__trial_T20190908_141942_810052": 1.0,
|
| 29 |
+
"look_at_obj_in_light-CD-None-DeskLamp-308__trial_T20190908_141958_463362": 1.0,
|
| 30 |
+
"look_at_obj_in_light-CD-None-DeskLamp-308__trial_T20190908_142046_281296": 1.0,
|
| 31 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-308__trial_T20190908_161733_213242": 1.0,
|
| 32 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-308__trial_T20190908_201421_021646": 1.0,
|
| 33 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-308__trial_T20190908_201444_037645": 1.0,
|
| 34 |
+
"look_at_obj_in_light-Pencil-None-DeskLamp-308__trial_T20190908_220545_153480": 1.0,
|
| 35 |
+
"look_at_obj_in_light-Pencil-None-DeskLamp-308__trial_T20190908_220604_010430": 1.0,
|
| 36 |
+
"look_at_obj_in_light-Pencil-None-DeskLamp-308__trial_T20190908_220656_510400": 1.0,
|
| 37 |
+
"pick_and_place_simple-Mug-None-Desk-308__trial_T20190908_125200_737896": 1.0,
|
| 38 |
+
"pick_and_place_simple-Mug-None-Desk-308__trial_T20190909_203041_433487": 1.0,
|
| 39 |
+
"pick_and_place_simple-Mug-None-Desk-308__trial_T20190909_210238_431966": 1.0,
|
| 40 |
+
"pick_and_place_simple-Pencil-None-Shelf-308__trial_T20190908_121952_610012": 1.0,
|
| 41 |
+
"pick_and_place_simple-Pencil-None-Shelf-308__trial_T20190908_122024_052056": 1.0,
|
| 42 |
+
"pick_and_place_simple-Pencil-None-Shelf-308__trial_T20190908_122154_042763": 1.0,
|
| 43 |
+
"pick_and_place_simple-PepperShaker-None-Drawer-10__trial_T20190906_184021_215264": 1.0,
|
| 44 |
+
"pick_and_place_simple-PepperShaker-None-Drawer-10__trial_T20190918_154326_823501": 1.0,
|
| 45 |
+
"pick_and_place_simple-PepperShaker-None-Drawer-10__trial_T20190918_154424_844749": 1.0,
|
| 46 |
+
"pick_and_place_simple-SaltShaker-None-Cabinet-10__trial_T20190906_191429_743650": 1.0,
|
| 47 |
+
"pick_and_place_simple-SaltShaker-None-Cabinet-10__trial_T20190906_191445_723170": 1.0,
|
| 48 |
+
"pick_and_place_simple-SaltShaker-None-Cabinet-10__trial_T20190906_191501_563086": 1.0,
|
| 49 |
+
"pick_and_place_simple-SaltShaker-None-Drawer-10__trial_T20190909_021613_077537": 1.0,
|
| 50 |
+
"pick_and_place_simple-SaltShaker-None-Drawer-10__trial_T20190909_021650_880235": 1.0,
|
| 51 |
+
"pick_and_place_simple-SaltShaker-None-Drawer-10__trial_T20190909_021728_339782": 1.0,
|
| 52 |
+
"pick_and_place_simple-SoapBottle-None-Toilet-424__trial_T20190907_004321_405868": 1.0,
|
| 53 |
+
"pick_and_place_simple-SoapBottle-None-Toilet-424__trial_T20190907_004351_281384": 1.0,
|
| 54 |
+
"pick_and_place_simple-SoapBottle-None-Toilet-424__trial_T20190907_004404_604165": 1.0,
|
| 55 |
+
"pick_and_place_simple-Vase-None-Safe-219__trial_T20190908_205204_244321": 1.0,
|
| 56 |
+
"pick_and_place_simple-Vase-None-Safe-219__trial_T20190908_205221_748352": 1.0,
|
| 57 |
+
"pick_and_place_simple-Vase-None-Safe-219__trial_T20190908_205246_776817": 1.0,
|
| 58 |
+
"pick_and_place_simple-Watch-None-Safe-219__trial_T20190907_074524_006355": 1.0,
|
| 59 |
+
"pick_and_place_simple-Watch-None-Safe-219__trial_T20190907_074556_124850": 1.0,
|
| 60 |
+
"pick_and_place_simple-Watch-None-Safe-219__trial_T20190907_074643_810052": 1.0,
|
| 61 |
+
"pick_clean_then_place_in_recep-Bowl-None-Cabinet-10__trial_T20190909_061130_844814": 1.0,
|
| 62 |
+
"pick_clean_then_place_in_recep-Bowl-None-Cabinet-10__trial_T20190909_061158_110530": 1.0,
|
| 63 |
+
"pick_clean_then_place_in_recep-Bowl-None-Cabinet-10__trial_T20190909_061232_368489": 1.0,
|
| 64 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cabinet-424__trial_T20190908_022321_380927": 1.0,
|
| 65 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cabinet-424__trial_T20190908_022436_073995": 1.0,
|
| 66 |
+
"pick_clean_then_place_in_recep-Cloth-None-CounterTop-424__trial_T20190908_100632_546757": 1.0,
|
| 67 |
+
"pick_clean_then_place_in_recep-Cloth-None-CounterTop-424__trial_T20190908_114340_674467": 1.0,
|
| 68 |
+
"pick_clean_then_place_in_recep-Egg-None-Microwave-10__trial_T20190909_120554_888709": 1.0,
|
| 69 |
+
"pick_clean_then_place_in_recep-Egg-None-Microwave-10__trial_T20190909_120632_691361": 1.0,
|
| 70 |
+
"pick_clean_then_place_in_recep-Egg-None-Microwave-10__trial_T20190909_120712_273910": 1.0,
|
| 71 |
+
"pick_clean_then_place_in_recep-Knife-None-CounterTop-10__trial_T20190909_110347_624008": 1.0,
|
| 72 |
+
"pick_clean_then_place_in_recep-Knife-None-CounterTop-10__trial_T20190909_110445_675754": 1.0,
|
| 73 |
+
"pick_clean_then_place_in_recep-Knife-None-CounterTop-10__trial_T20190909_110531_148235": 1.0,
|
| 74 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_221208_560499": 1.0,
|
| 75 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_221300_362511": 1.0,
|
| 76 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_221355_558505": 1.0,
|
| 77 |
+
"pick_clean_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_032434_013084": 1.0,
|
| 78 |
+
"pick_clean_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_032518_891433": 1.0,
|
| 79 |
+
"pick_clean_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_032543_712058": 1.0,
|
| 80 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-10__trial_T20190908_213356_017769": 1.0,
|
| 81 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-10__trial_T20190908_213420_728917": 1.0,
|
| 82 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-10__trial_T20190908_213533_897289": 1.0,
|
| 83 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-424__trial_T20190908_214926_337906": 1.0,
|
| 84 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-424__trial_T20190908_214946_567644": 1.0,
|
| 85 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-424__trial_T20190908_215019_162873": 1.0,
|
| 86 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-424__trial_T20190907_074045_109439": 1.0,
|
| 87 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-424__trial_T20190907_074106_050405": 1.0,
|
| 88 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-424__trial_T20190907_074124_966890": 1.0,
|
| 89 |
+
"pick_clean_then_place_in_recep-Spatula-None-Drawer-10__trial_T20190907_080730_211959": 1.0,
|
| 90 |
+
"pick_clean_then_place_in_recep-Spatula-None-Drawer-10__trial_T20190907_080800_275989": 1.0,
|
| 91 |
+
"pick_clean_then_place_in_recep-Spatula-None-Drawer-10__trial_T20190907_080825_222432": 1.0,
|
| 92 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-10__trial_T20190908_091747_866951": 1.0,
|
| 93 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-10__trial_T20190908_091811_414150": 1.0,
|
| 94 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-10__trial_T20190908_091835_825830": 1.0,
|
| 95 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-10__trial_T20190909_123133_763972": 1.0,
|
| 96 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-10__trial_T20190909_174807_646433": 1.0,
|
| 97 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-10__trial_T20190909_174840_771703": 1.0,
|
| 98 |
+
"pick_cool_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_121559_082363": 1.0,
|
| 99 |
+
"pick_cool_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_121635_622676": 1.0,
|
| 100 |
+
"pick_cool_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_121710_650938": 1.0,
|
| 101 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_183715_299073": 1.0,
|
| 102 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_183807_477267": 1.0,
|
| 103 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_183853_958104": 1.0,
|
| 104 |
+
"pick_cool_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_114545_244903": 1.0,
|
| 105 |
+
"pick_cool_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_114622_738670": 1.0,
|
| 106 |
+
"pick_cool_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_114656_768805": 1.0,
|
| 107 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-10__trial_T20190907_033157_424297": 1.0,
|
| 108 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-10__trial_T20190907_033228_194678": 1.0,
|
| 109 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-10__trial_T20190907_033306_962974": 1.0,
|
| 110 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-10__trial_T20190909_102608_318800": 1.0,
|
| 111 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-10__trial_T20190909_102644_926781": 1.0,
|
| 112 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-10__trial_T20190909_102710_795182": 1.0,
|
| 113 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-10__trial_T20190906_182259_116320": 1.0,
|
| 114 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-10__trial_T20190906_182353_418140": 1.0,
|
| 115 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-10__trial_T20190906_182435_622538": 1.0,
|
| 116 |
+
"pick_heat_then_place_in_recep-Apple-None-GarbageCan-10__trial_T20190908_145050_918567": 1.0,
|
| 117 |
+
"pick_heat_then_place_in_recep-Apple-None-GarbageCan-10__trial_T20190908_145143_820541": 1.0,
|
| 118 |
+
"pick_heat_then_place_in_recep-Apple-None-GarbageCan-10__trial_T20190908_145356_918528": 1.0,
|
| 119 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-10__trial_T20190907_083346_800823": 1.0,
|
| 120 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-10__trial_T20190907_083429_887065": 1.0,
|
| 121 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-10__trial_T20190907_083507_594820": 1.0,
|
| 122 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-10__trial_T20190908_113432_673307": 1.0,
|
| 123 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-10__trial_T20190908_113523_123938": 1.0,
|
| 124 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-10__trial_T20190908_113610_425142": 1.0,
|
| 125 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_021100_341887": 1.0,
|
| 126 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_021200_669381": 1.0,
|
| 127 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_021247_306737": 1.0,
|
| 128 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_171806_406231": 1.0,
|
| 129 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_171850_960211": 1.0,
|
| 130 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_171933_349922": 1.0,
|
| 131 |
+
"pick_heat_then_place_in_recep-Potato-None-GarbageCan-10__trial_T20190907_161745_664033": 1.0,
|
| 132 |
+
"pick_heat_then_place_in_recep-Potato-None-GarbageCan-10__trial_T20190907_161853_945788": 1.0,
|
| 133 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-10__trial_T20190908_225046_020282": 1.0,
|
| 134 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-10__trial_T20190908_225359_617900": 1.0,
|
| 135 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-10__trial_T20190908_225453_272533": 1.0,
|
| 136 |
+
"pick_two_obj_and_place-CD-None-Safe-308__trial_T20190907_050942_897916": 1.0,
|
| 137 |
+
"pick_two_obj_and_place-CD-None-Safe-308__trial_T20190907_051013_060265": 1.0,
|
| 138 |
+
"pick_two_obj_and_place-CD-None-Safe-308__trial_T20190907_051056_585414": 1.0,
|
| 139 |
+
"pick_two_obj_and_place-KeyChain-None-Safe-219__trial_T20190909_011803_423115": 1.0,
|
| 140 |
+
"pick_two_obj_and_place-KeyChain-None-Safe-219__trial_T20190909_012027_782483": 1.0,
|
| 141 |
+
"pick_two_obj_and_place-PepperShaker-None-Drawer-10__trial_T20190908_010306_215435": 1.0,
|
| 142 |
+
"pick_two_obj_and_place-PepperShaker-None-Drawer-10__trial_T20190912_221016_460197": 1.0,
|
| 143 |
+
"pick_two_obj_and_place-PepperShaker-None-Drawer-10__trial_T20190912_221141_608117": 1.0,
|
| 144 |
+
"pick_two_obj_and_place-Pillow-None-Sofa-219__trial_T20190907_163240_345855": 1.0,
|
| 145 |
+
"pick_two_obj_and_place-Pillow-None-Sofa-219__trial_T20190907_163327_486300": 1.0,
|
| 146 |
+
"pick_two_obj_and_place-Pillow-None-Sofa-219__trial_T20190907_163408_914117": 1.0,
|
| 147 |
+
"pick_two_obj_and_place-SoapBar-None-Cabinet-424__trial_T20190909_081720_491733": 1.0,
|
| 148 |
+
"pick_two_obj_and_place-SoapBar-None-Cabinet-424__trial_T20190909_081746_857594": 1.0,
|
| 149 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-424__trial_T20190909_064053_839817": 1.0,
|
| 150 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-424__trial_T20190909_064221_368939": 1.0,
|
| 151 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-424__trial_T20190909_064309_357168": 1.0,
|
| 152 |
+
"pick_two_obj_and_place-ToiletPaper-None-Cabinet-424__trial_T20190906_202926_527010": 1.0
|
| 153 |
+
},
|
| 154 |
+
"traces": "eval-traces/round-2-valid_unseen.tar.gz"
|
| 155 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-3-valid_seen.json
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "hg-eval-cell.v1",
|
| 3 |
+
"method": "ahe",
|
| 4 |
+
"round": 3,
|
| 5 |
+
"pool": "valid_seen",
|
| 6 |
+
"stamp": "20261017T123952Z",
|
| 7 |
+
"run_id": "rsi10-20261017T123952Z-ahe-exam-valid_seen",
|
| 8 |
+
"score": 1.0,
|
| 9 |
+
"n_scored": 140,
|
| 10 |
+
"n_invalid": 0,
|
| 11 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 12 |
+
"evaluated_from": {
|
| 13 |
+
"run_id": "rsi10-20261017T123952Z-ahe-train",
|
| 14 |
+
"round": 3,
|
| 15 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 16 |
+
"train_score": 1.0
|
| 17 |
+
},
|
| 18 |
+
"per_task": {
|
| 19 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-323__trial_T20190909_044715_250790": 1.0,
|
| 20 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-301__trial_T20190909_150719_492274": 1.0,
|
| 21 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-316__trial_T20190908_230702_962704": 1.0,
|
| 22 |
+
"look_at_obj_in_light-Box-None-DeskLamp-205__trial_T20190907_074425_330493": 1.0,
|
| 23 |
+
"look_at_obj_in_light-CD-None-DeskLamp-302__trial_T20190907_154618_526741": 1.0,
|
| 24 |
+
"look_at_obj_in_light-CD-None-DeskLamp-314__trial_T20190907_114323_767231": 1.0,
|
| 25 |
+
"look_at_obj_in_light-CD-None-DeskLamp-320__trial_T20190907_224451_655673": 1.0,
|
| 26 |
+
"look_at_obj_in_light-KeyChain-None-DeskLamp-327__trial_T20190906_202601_548273": 1.0,
|
| 27 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-328__trial_T20190908_201550_622420": 1.0,
|
| 28 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-302__trial_T20190909_150916_682139": 1.0,
|
| 29 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-323__trial_T20190908_053153_077977": 1.0,
|
| 30 |
+
"look_at_obj_in_light-Statue-None-DeskLamp-216__trial_T20190909_193045_208933": 1.0,
|
| 31 |
+
"look_at_obj_in_light-Vase-None-DeskLamp-303__trial_T20190907_150418_457594": 1.0,
|
| 32 |
+
"pick_and_place_simple-Book-None-SideTable-329__trial_T20190908_050633_745514": 1.0,
|
| 33 |
+
"pick_and_place_simple-Book-None-Sofa-229__trial_T20190907_042856_259139": 1.0,
|
| 34 |
+
"pick_and_place_simple-Bowl-None-CoffeeTable-201__trial_T20190907_171639_045329": 1.0,
|
| 35 |
+
"pick_and_place_simple-Box-None-Dresser-224__trial_T20190907_164104_229696": 1.0,
|
| 36 |
+
"pick_and_place_simple-Candle-None-Cart-401__trial_T20190909_081908_677973": 1.0,
|
| 37 |
+
"pick_and_place_simple-Candle-None-Toilet-407__trial_T20190909_055248_059513": 1.0,
|
| 38 |
+
"pick_and_place_simple-Candle-None-Toilet-429__trial_T20190908_052232_887934": 1.0,
|
| 39 |
+
"pick_and_place_simple-CellPhone-None-ArmChair-318__trial_T20190909_120047_968274": 1.0,
|
| 40 |
+
"pick_and_place_simple-CellPhone-None-Bed-324__trial_T20190907_233817_198528": 1.0,
|
| 41 |
+
"pick_and_place_simple-CreditCard-None-ArmChair-201__trial_T20190908_124340_258012": 1.0,
|
| 42 |
+
"pick_and_place_simple-CreditCard-None-Drawer-227__trial_T20190909_010644_297017": 1.0,
|
| 43 |
+
"pick_and_place_simple-Egg-None-Microwave-4__trial_T20190906_234406_356490": 1.0,
|
| 44 |
+
"pick_and_place_simple-Knife-None-SideTable-3__trial_T20190918_184236_557252": 1.0,
|
| 45 |
+
"pick_and_place_simple-Mug-None-Dresser-311__trial_T20190909_152837_739016": 1.0,
|
| 46 |
+
"pick_and_place_simple-Mug-None-SideTable-329__trial_T20190909_032318_169393": 1.0,
|
| 47 |
+
"pick_and_place_simple-Mug-None-SideTable-329__trial_T20190909_032340_274147": 1.0,
|
| 48 |
+
"pick_and_place_simple-Newspaper-None-Sofa-224__trial_T20190909_111324_949106": 1.0,
|
| 49 |
+
"pick_and_place_simple-Pencil-None-Desk-310__trial_T20190909_113054_894334": 1.0,
|
| 50 |
+
"pick_and_place_simple-Pencil-None-Dresser-330__trial_T20190909_071128_012892": 1.0,
|
| 51 |
+
"pick_and_place_simple-RemoteControl-None-ArmChair-230__trial_T20190909_021000_274398": 1.0,
|
| 52 |
+
"pick_and_place_simple-RemoteControl-None-Sofa-207__trial_T20190909_153609_373481": 1.0,
|
| 53 |
+
"pick_and_place_simple-SoapBar-None-Cart-401__trial_T20190907_054906_608944": 1.0,
|
| 54 |
+
"pick_and_place_simple-SoapBottle-None-Cabinet-414__trial_T20190908_110131_524518": 1.0,
|
| 55 |
+
"pick_and_place_simple-SoapBottle-None-CounterTop-417__trial_T20190910_112922_368384": 1.0,
|
| 56 |
+
"pick_and_place_simple-SprayBottle-None-Cabinet-413__trial_T20190907_114931_692464": 1.0,
|
| 57 |
+
"pick_and_place_simple-SprayBottle-None-GarbageCan-409__trial_T20190908_054742_818364": 1.0,
|
| 58 |
+
"pick_and_place_simple-SprayBottle-None-Toilet-415__trial_T20190909_075955_678702": 1.0,
|
| 59 |
+
"pick_and_place_simple-SprayBottle-None-Toilet-418__trial_T20190906_190942_706186": 1.0,
|
| 60 |
+
"pick_and_place_simple-TissueBox-None-Toilet-426__trial_T20190910_155319_795672": 1.0,
|
| 61 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-406__trial_T20190908_122858_883968": 1.0,
|
| 62 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-415__trial_T20190908_050518_595510": 1.0,
|
| 63 |
+
"pick_and_place_simple-Tomato-None-Microwave-13__trial_T20190908_124829_632660": 1.0,
|
| 64 |
+
"pick_and_place_simple-Vase-None-CoffeeTable-207__trial_T20190909_091246_807206": 1.0,
|
| 65 |
+
"pick_and_place_simple-Watch-None-SideTable-222__trial_T20190909_051813_197569": 1.0,
|
| 66 |
+
"pick_and_place_simple-WineBottle-None-Shelf-7__trial_T20190907_200154_378982": 1.0,
|
| 67 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-CounterTop-8__trial_T20190909_105559_983897": 1.0,
|
| 68 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-DiningTable-16__trial_T20190909_114508_617301": 1.0,
|
| 69 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-Drawer-2__trial_T20190908_121728_511866": 1.0,
|
| 70 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-Drawer-30__trial_T20190908_052007_212776": 1.0,
|
| 71 |
+
"pick_clean_then_place_in_recep-ButterKnife-None-Drawer-8__trial_T20190909_124425_112757": 1.0,
|
| 72 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cabinet-405__trial_T20190907_080903_889497": 1.0,
|
| 73 |
+
"pick_clean_then_place_in_recep-Cloth-None-Drawer-423__trial_T20190908_140701_251653": 1.0,
|
| 74 |
+
"pick_clean_then_place_in_recep-DishSponge-None-Cart-401__trial_T20190907_024634_972453": 1.0,
|
| 75 |
+
"pick_clean_then_place_in_recep-DishSponge-None-CounterTop-403__trial_T20190908_144357_621068": 1.0,
|
| 76 |
+
"pick_clean_then_place_in_recep-Fork-None-CounterTop-23__trial_T20190908_233922_171295": 1.0,
|
| 77 |
+
"pick_clean_then_place_in_recep-Fork-None-Drawer-8__trial_T20190908_132152_999725": 1.0,
|
| 78 |
+
"pick_clean_then_place_in_recep-Ladle-None-CounterTop-14__trial_T20190909_113844_191747": 1.0,
|
| 79 |
+
"pick_clean_then_place_in_recep-Ladle-None-CounterTop-8__trial_T20190909_121908_219603": 1.0,
|
| 80 |
+
"pick_clean_then_place_in_recep-Ladle-None-DiningTable-16__trial_T20190909_183724_205399": 1.0,
|
| 81 |
+
"pick_clean_then_place_in_recep-Ladle-None-DiningTable-27__trial_T20190911_131350_027076": 1.0,
|
| 82 |
+
"pick_clean_then_place_in_recep-Ladle-None-DiningTable-4__trial_T20190909_164840_568811": 1.0,
|
| 83 |
+
"pick_clean_then_place_in_recep-Lettuce-None-CounterTop-16__trial_T20190909_051630_092360": 1.0,
|
| 84 |
+
"pick_clean_then_place_in_recep-Lettuce-None-Fridge-19__trial_T20190908_100138_446072": 1.0,
|
| 85 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-26__trial_T20190907_233056_022802": 1.0,
|
| 86 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-19__trial_T20190908_212725_836398": 1.0,
|
| 87 |
+
"pick_clean_then_place_in_recep-Plate-None-Fridge-5__trial_T20190909_112854_740612": 1.0,
|
| 88 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-402__trial_T20190908_055221_984342": 1.0,
|
| 89 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Drawer-423__trial_T20190906_202340_749336": 1.0,
|
| 90 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-410__trial_T20190906_201106_979461": 1.0,
|
| 91 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-428__trial_T20190907_041436_588106": 1.0,
|
| 92 |
+
"pick_clean_then_place_in_recep-Spatula-None-DiningTable-4__trial_T20190909_002804_564168": 1.0,
|
| 93 |
+
"pick_clean_then_place_in_recep-Tomato-None-CounterTop-25__trial_T20190909_012550_586494": 1.0,
|
| 94 |
+
"pick_cool_then_place_in_recep-Apple-None-CounterTop-14__trial_T20190909_044933_815840": 1.0,
|
| 95 |
+
"pick_cool_then_place_in_recep-Apple-None-GarbageCan-2__trial_T20190906_195943_081289": 1.0,
|
| 96 |
+
"pick_cool_then_place_in_recep-Apple-None-Microwave-19__trial_T20190906_210937_878489": 1.0,
|
| 97 |
+
"pick_cool_then_place_in_recep-Apple-None-Microwave-5__trial_T20190908_150807_823817": 1.0,
|
| 98 |
+
"pick_cool_then_place_in_recep-Bowl-None-Cabinet-20__trial_T20190909_112912_154874": 1.0,
|
| 99 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-7__trial_T20190909_045605_307949": 1.0,
|
| 100 |
+
"pick_cool_then_place_in_recep-Cup-None-Microwave-17__trial_T20190906_192817_654400": 1.0,
|
| 101 |
+
"pick_cool_then_place_in_recep-Cup-None-SideTable-21__trial_T20190906_192823_237997": 1.0,
|
| 102 |
+
"pick_cool_then_place_in_recep-Egg-None-Microwave-24__trial_T20190908_234112_645480": 1.0,
|
| 103 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-1__trial_T20190908_042713_075616": 1.0,
|
| 104 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-11__trial_T20190908_222555_651605": 1.0,
|
| 105 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-16__trial_T20190908_184242_348366": 1.0,
|
| 106 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-7__trial_T20190908_232648_241836": 1.0,
|
| 107 |
+
"pick_cool_then_place_in_recep-Pan-None-StoveBurner-18__trial_T20190906_181023_216915": 1.0,
|
| 108 |
+
"pick_cool_then_place_in_recep-Pan-None-StoveBurner-23__trial_T20190906_215856_374127": 1.0,
|
| 109 |
+
"pick_cool_then_place_in_recep-Plate-None-Cabinet-27__trial_T20190906_173120_350651": 1.0,
|
| 110 |
+
"pick_cool_then_place_in_recep-Plate-None-Cabinet-7__trial_T20190907_231206_512424": 1.0,
|
| 111 |
+
"pick_cool_then_place_in_recep-Plate-None-CounterTop-1__trial_T20190906_205324_559361": 1.0,
|
| 112 |
+
"pick_cool_then_place_in_recep-Pot-None-DiningTable-21__trial_T20190909_004531_429065": 1.0,
|
| 113 |
+
"pick_cool_then_place_in_recep-Tomato-None-CounterTop-12__trial_T20190909_063754_216554": 1.0,
|
| 114 |
+
"pick_cool_then_place_in_recep-Tomato-None-CounterTop-12__trial_T20190909_063844_274181": 1.0,
|
| 115 |
+
"pick_cool_then_place_in_recep-Tomato-None-GarbageCan-6__trial_T20190909_082934_483899": 1.0,
|
| 116 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-13__trial_T20190910_173916_331859": 1.0,
|
| 117 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-18__trial_T20190909_012524_159092": 1.0,
|
| 118 |
+
"pick_cool_then_place_in_recep-WineBottle-None-DiningTable-17__trial_T20190908_024426_412044": 1.0,
|
| 119 |
+
"pick_heat_then_place_in_recep-Apple-None-DiningTable-26__trial_T20190907_060234_011675": 1.0,
|
| 120 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-22__trial_T20190907_173251_960848": 1.0,
|
| 121 |
+
"pick_heat_then_place_in_recep-Egg-None-CounterTop-2__trial_T20190908_122951_021026": 1.0,
|
| 122 |
+
"pick_heat_then_place_in_recep-Egg-None-Fridge-14__trial_T20190909_091314_636733": 1.0,
|
| 123 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-26__trial_T20190909_062333_424779": 1.0,
|
| 124 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-3__trial_T20190909_014639_335717": 1.0,
|
| 125 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-1__trial_T20190907_222640_487432": 1.0,
|
| 126 |
+
"pick_heat_then_place_in_recep-Mug-None-SideTable-21__trial_T20190909_090729_088825": 1.0,
|
| 127 |
+
"pick_heat_then_place_in_recep-Plate-None-Cabinet-1__trial_T20190908_070946_578973": 1.0,
|
| 128 |
+
"pick_heat_then_place_in_recep-Plate-None-DiningTable-28__trial_T20190908_001247_096796": 1.0,
|
| 129 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-11__trial_T20190909_011341_436523": 1.0,
|
| 130 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-12__trial_T20190908_014451_271080": 1.0,
|
| 131 |
+
"pick_heat_then_place_in_recep-Tomato-None-DiningTable-16__trial_T20190907_201243_698086": 1.0,
|
| 132 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-15__trial_T20190909_020200_054379": 1.0,
|
| 133 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-23__trial_T20190909_082320_103350": 1.0,
|
| 134 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-24__trial_T20190908_033721_967359": 1.0,
|
| 135 |
+
"pick_two_obj_and_place-AlarmClock-None-Dresser-305__trial_T20190907_165826_194855": 1.0,
|
| 136 |
+
"pick_two_obj_and_place-Book-None-Desk-302__trial_T20190906_181233_363875": 1.0,
|
| 137 |
+
"pick_two_obj_and_place-Book-None-Desk-313__trial_T20190908_125930_920681": 1.0,
|
| 138 |
+
"pick_two_obj_and_place-Box-None-CoffeeTable-213__trial_T20190906_200927_069627": 1.0,
|
| 139 |
+
"pick_two_obj_and_place-CD-None-Drawer-304__trial_T20190907_230232_832893": 1.0,
|
| 140 |
+
"pick_two_obj_and_place-CreditCard-None-Dresser-311__trial_T20190907_201917_045715": 1.0,
|
| 141 |
+
"pick_two_obj_and_place-CreditCard-None-Safe-323__trial_T20190907_001129_214240": 1.0,
|
| 142 |
+
"pick_two_obj_and_place-Glassbottle-None-Shelf-1__trial_T20190907_122204_941737": 1.0,
|
| 143 |
+
"pick_two_obj_and_place-Knife-None-Drawer-18__trial_T20190907_065232_689984": 1.0,
|
| 144 |
+
"pick_two_obj_and_place-Newspaper-None-Drawer-224__trial_T20190911_101248_326533": 1.0,
|
| 145 |
+
"pick_two_obj_and_place-Pan-None-CounterTop-14__trial_T20190907_012519_974044": 1.0,
|
| 146 |
+
"pick_two_obj_and_place-RemoteControl-None-Ottoman-203__trial_T20190906_182952_858723": 1.0,
|
| 147 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-418__trial_T20190909_055538_380023": 1.0,
|
| 148 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-418__trial_T20190909_055649_717880": 1.0,
|
| 149 |
+
"pick_two_obj_and_place-Spatula-None-Drawer-13__trial_T20190908_183331_203888": 1.0,
|
| 150 |
+
"pick_two_obj_and_place-SprayBottle-None-Cabinet-407__trial_T20190907_144556_144188": 1.0,
|
| 151 |
+
"pick_two_obj_and_place-SprayBottle-None-GarbageCan-419__trial_T20190908_164236_518264": 1.0,
|
| 152 |
+
"pick_two_obj_and_place-SprayBottle-None-Toilet-402__trial_T20190910_222914_814642": 1.0,
|
| 153 |
+
"pick_two_obj_and_place-SprayBottle-None-Toilet-429__trial_T20190907_033843_707544": 1.0,
|
| 154 |
+
"pick_two_obj_and_place-TissueBox-None-Toilet-426__trial_T20190909_044602_338962": 1.0,
|
| 155 |
+
"pick_two_obj_and_place-ToiletPaper-None-Drawer-423__trial_T20190907_111251_461099": 1.0,
|
| 156 |
+
"pick_two_obj_and_place-ToiletPaper-None-Toilet-408__trial_T20190909_080302_174780": 1.0,
|
| 157 |
+
"pick_two_obj_and_place-Vase-None-Desk-204__trial_T20190906_181531_703961": 1.0,
|
| 158 |
+
"pick_two_obj_and_place-Watch-None-Dresser-205__trial_T20190907_182211_592010": 1.0
|
| 159 |
+
},
|
| 160 |
+
"traces": "eval-traces/round-3-valid_seen.tar.gz"
|
| 161 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-3-valid_train.json
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "hg-eval-cell.v1",
|
| 3 |
+
"method": "ahe",
|
| 4 |
+
"round": 3,
|
| 5 |
+
"pool": "valid_train",
|
| 6 |
+
"stamp": "20261017T123952Z",
|
| 7 |
+
"run_id": "rsi10-20261017T123952Z-ahe-ckpt-r3-valid_train",
|
| 8 |
+
"score": 1.0,
|
| 9 |
+
"n_scored": 200,
|
| 10 |
+
"n_invalid": 0,
|
| 11 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 12 |
+
"evaluated_from": {
|
| 13 |
+
"run_id": "rsi10-20261017T123952Z-ahe-train",
|
| 14 |
+
"round": 3,
|
| 15 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 16 |
+
"train_score": 1.0
|
| 17 |
+
},
|
| 18 |
+
"per_task": {
|
| 19 |
+
"look_at_obj_in_light-Book-None-DeskLamp-302__trial_T20190909_085137_911990": 1.0,
|
| 20 |
+
"look_at_obj_in_light-Book-None-DeskLamp-317__trial_T20190909_201225_052100": 1.0,
|
| 21 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-304__trial_T20190907_232227_752681": 1.0,
|
| 22 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-305__trial_T20190909_000758_132057": 1.0,
|
| 23 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-316__trial_T20190908_230650_245482": 1.0,
|
| 24 |
+
"look_at_obj_in_light-CD-None-DeskLamp-307__trial_T20190906_200435_424001": 1.0,
|
| 25 |
+
"look_at_obj_in_light-CD-None-DeskLamp-323__trial_T20190908_051124_983144": 1.0,
|
| 26 |
+
"look_at_obj_in_light-CD-None-DeskLamp-327__trial_T20190909_032921_008718": 1.0,
|
| 27 |
+
"look_at_obj_in_light-CreditCard-None-DeskLamp-314__trial_T20190906_201548_667159": 1.0,
|
| 28 |
+
"look_at_obj_in_light-KeyChain-None-DeskLamp-327__trial_T20190906_202538_399742": 1.0,
|
| 29 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-309__trial_T20190907_185713_398582": 1.0,
|
| 30 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-319__trial_T20190908_182720_056041": 1.0,
|
| 31 |
+
"look_at_obj_in_light-Laptop-None-DeskLamp-324__trial_T20190908_071137_867346": 1.0,
|
| 32 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-323__trial_T20190907_041046_628363": 1.0,
|
| 33 |
+
"look_at_obj_in_light-Pen-None-DeskLamp-305__trial_T20190907_115824_746935": 1.0,
|
| 34 |
+
"look_at_obj_in_light-Pen-None-DeskLamp-316__trial_T20190908_061847_951064": 1.0,
|
| 35 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-309__trial_T20190908_113756_084511": 1.0,
|
| 36 |
+
"look_at_obj_in_light-Pillow-None-DeskLamp-323__trial_T20190908_053117_107031": 1.0,
|
| 37 |
+
"look_at_obj_in_light-TissueBox-None-DeskLamp-216__trial_T20190908_033138_836240": 1.0,
|
| 38 |
+
"pick_and_place_simple-AlarmClock-None-Desk-307__trial_T20190907_072317_014092": 1.0,
|
| 39 |
+
"pick_and_place_simple-AlarmClock-None-Dresser-319__trial_T20190910_195319_108102": 1.0,
|
| 40 |
+
"pick_and_place_simple-Book-None-Desk-313__trial_T20190909_140606_239445": 1.0,
|
| 41 |
+
"pick_and_place_simple-CD-None-Dresser-318__trial_T20190907_190246_917982": 1.0,
|
| 42 |
+
"pick_and_place_simple-CD-None-Shelf-319__trial_T20190908_061008_714389": 1.0,
|
| 43 |
+
"pick_and_place_simple-Candle-None-Cabinet-428__trial_T20190907_024255_988230": 1.0,
|
| 44 |
+
"pick_and_place_simple-Candle-None-Toilet-427__trial_T20190909_030427_604487": 1.0,
|
| 45 |
+
"pick_and_place_simple-CellPhone-None-Bed-321__trial_T20190908_231541_058766": 1.0,
|
| 46 |
+
"pick_and_place_simple-CellPhone-None-Desk-316__trial_T20190911_203517_902296": 1.0,
|
| 47 |
+
"pick_and_place_simple-Cloth-None-Toilet-417__trial_T20190908_163202_959027": 1.0,
|
| 48 |
+
"pick_and_place_simple-CreditCard-None-ArmChair-202__trial_T20190909_011606_013059": 1.0,
|
| 49 |
+
"pick_and_place_simple-CreditCard-None-Sofa-216__trial_T20190909_110455_224621": 1.0,
|
| 50 |
+
"pick_and_place_simple-Fork-None-Drawer-12__trial_T20190907_151050_079642": 1.0,
|
| 51 |
+
"pick_and_place_simple-Glassbottle-None-Cabinet-17__trial_T20190906_182221_722403": 1.0,
|
| 52 |
+
"pick_and_place_simple-HandTowel-None-Cabinet-412__trial_T20190906_200520_896836": 1.0,
|
| 53 |
+
"pick_and_place_simple-KeyChain-None-ArmChair-318__trial_T20190909_114631_650488": 1.0,
|
| 54 |
+
"pick_and_place_simple-KeyChain-None-CoffeeTable-227__trial_T20190907_161844_256041": 1.0,
|
| 55 |
+
"pick_and_place_simple-KeyChain-None-SideTable-309__trial_T20190908_215011_025401": 1.0,
|
| 56 |
+
"pick_and_place_simple-KeyChain-None-SideTable-322__trial_T20190909_091733_848923": 1.0,
|
| 57 |
+
"pick_and_place_simple-KeyChain-None-Sofa-225__trial_T20190908_131129_251514": 1.0,
|
| 58 |
+
"pick_and_place_simple-KeyChain-None-Sofa-229__trial_T20190908_123359_988104": 1.0,
|
| 59 |
+
"pick_and_place_simple-Pan-None-DiningTable-15__trial_T20190908_182413_239334": 1.0,
|
| 60 |
+
"pick_and_place_simple-Pen-None-SideTable-309__trial_T20190907_051900_451316": 1.0,
|
| 61 |
+
"pick_and_place_simple-PepperShaker-None-CounterTop-27__trial_T20190909_010859_836097": 1.0,
|
| 62 |
+
"pick_and_place_simple-Pillow-None-ArmChair-214__trial_T20190909_010338_250180": 1.0,
|
| 63 |
+
"pick_and_place_simple-Pillow-None-ArmChair-321__trial_T20190908_104900_888704": 1.0,
|
| 64 |
+
"pick_and_place_simple-RemoteControl-None-ArmChair-222__trial_T20190906_201505_001155": 1.0,
|
| 65 |
+
"pick_and_place_simple-RemoteControl-None-Ottoman-208__trial_T20190909_100851_710423": 1.0,
|
| 66 |
+
"pick_and_place_simple-SoapBottle-None-Cart-430__trial_T20190909_100609_714213": 1.0,
|
| 67 |
+
"pick_and_place_simple-SoapBottle-None-GarbageCan-11__trial_T20190908_175650_970050": 1.0,
|
| 68 |
+
"pick_and_place_simple-SprayBottle-None-CounterTop-417__trial_T20190909_091329_750799": 1.0,
|
| 69 |
+
"pick_and_place_simple-SprayBottle-None-GarbageCan-428__trial_T20190909_101522_923920": 1.0,
|
| 70 |
+
"pick_and_place_simple-SprayBottle-None-Toilet-405__trial_T20190908_021347_460567": 1.0,
|
| 71 |
+
"pick_and_place_simple-Statue-None-CoffeeTable-229__trial_T20190908_132941_479938": 1.0,
|
| 72 |
+
"pick_and_place_simple-ToiletPaper-None-GarbageCan-403__trial_T20190907_034648_807245": 1.0,
|
| 73 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-402__trial_T20190908_030828_744767": 1.0,
|
| 74 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-410__trial_T20190907_021559_670421": 1.0,
|
| 75 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-412__trial_T20190907_181227_790902": 1.0,
|
| 76 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-428__trial_T20190906_201316_921947": 1.0,
|
| 77 |
+
"pick_and_place_simple-ToiletPaper-None-ToiletPaperHanger-430__trial_T20190908_102055_678050": 1.0,
|
| 78 |
+
"pick_and_place_simple-Tomato-None-DiningTable-26__trial_T20190908_010933_200567": 1.0,
|
| 79 |
+
"pick_and_place_simple-Tomato-None-Microwave-13__trial_T20190908_125127_168939": 1.0,
|
| 80 |
+
"pick_and_place_simple-Tomato-None-Microwave-5__trial_T20190908_174014_984950": 1.0,
|
| 81 |
+
"pick_and_place_simple-Tomato-None-Microwave-8__trial_T20190907_205031_274716": 1.0,
|
| 82 |
+
"pick_and_place_simple-Vase-None-CoffeeTable-206__trial_T20190909_024648_216020": 1.0,
|
| 83 |
+
"pick_and_place_simple-Watch-None-CoffeeTable-213__trial_T20190909_010805_852491": 1.0,
|
| 84 |
+
"pick_clean_then_place_in_recep-Bowl-None-Shelf-7__trial_T20190908_152949_169018": 1.0,
|
| 85 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cart-401__trial_T20190907_045451_101032": 1.0,
|
| 86 |
+
"pick_clean_then_place_in_recep-Cloth-None-Drawer-416__trial_T20190908_040722_151303": 1.0,
|
| 87 |
+
"pick_clean_then_place_in_recep-Cloth-None-Drawer-423__trial_T20190908_140728_318318": 1.0,
|
| 88 |
+
"pick_clean_then_place_in_recep-Cloth-None-Toilet-406__trial_T20190908_102735_461565": 1.0,
|
| 89 |
+
"pick_clean_then_place_in_recep-DishSponge-None-Shelf-20__trial_T20190907_222456_204496": 1.0,
|
| 90 |
+
"pick_clean_then_place_in_recep-Egg-None-GarbageCan-11__trial_T20190906_181033_636334": 1.0,
|
| 91 |
+
"pick_clean_then_place_in_recep-Fork-None-CounterTop-24__trial_T20190907_032458_736277": 1.0,
|
| 92 |
+
"pick_clean_then_place_in_recep-Fork-None-DiningTable-24__trial_T20190906_205216_940941": 1.0,
|
| 93 |
+
"pick_clean_then_place_in_recep-Fork-None-SideTable-21__trial_T20190909_041401_796447": 1.0,
|
| 94 |
+
"pick_clean_then_place_in_recep-Kettle-None-Cabinet-2__trial_T20190909_042935_977031": 1.0,
|
| 95 |
+
"pick_clean_then_place_in_recep-Kettle-None-DiningTable-17__trial_T20190909_023518_602816": 1.0,
|
| 96 |
+
"pick_clean_then_place_in_recep-Kettle-None-Shelf-7__trial_T20190907_200421_808214": 1.0,
|
| 97 |
+
"pick_clean_then_place_in_recep-Kettle-None-StoveBurner-30__trial_T20190906_200053_697370": 1.0,
|
| 98 |
+
"pick_clean_then_place_in_recep-Knife-None-DiningTable-23__trial_T20190908_142126_854011": 1.0,
|
| 99 |
+
"pick_clean_then_place_in_recep-Ladle-None-CounterTop-14__trial_T20190909_113924_604801": 1.0,
|
| 100 |
+
"pick_clean_then_place_in_recep-Ladle-None-Drawer-30__trial_T20190908_005155_378803": 1.0,
|
| 101 |
+
"pick_clean_then_place_in_recep-Ladle-None-Drawer-4__trial_T20190909_161523_929674": 1.0,
|
| 102 |
+
"pick_clean_then_place_in_recep-Lettuce-None-CounterTop-15__trial_T20190907_070041_442493": 1.0,
|
| 103 |
+
"pick_clean_then_place_in_recep-Lettuce-None-Fridge-13__trial_T20190908_203156_157438": 1.0,
|
| 104 |
+
"pick_clean_then_place_in_recep-Lettuce-None-GarbageCan-17__trial_T20190907_163845_626537": 1.0,
|
| 105 |
+
"pick_clean_then_place_in_recep-Pan-None-Cabinet-1__trial_T20190908_130833_956410": 1.0,
|
| 106 |
+
"pick_clean_then_place_in_recep-Pan-None-Fridge-1__trial_T20190908_105549_705446": 1.0,
|
| 107 |
+
"pick_clean_then_place_in_recep-Pan-None-StoveBurner-20__trial_T20190908_113730_305436": 1.0,
|
| 108 |
+
"pick_clean_then_place_in_recep-Plate-None-Cabinet-13__trial_T20190909_123604_776156": 1.0,
|
| 109 |
+
"pick_clean_then_place_in_recep-Pot-None-DiningTable-26__trial_T20190906_210506_116438": 1.0,
|
| 110 |
+
"pick_clean_then_place_in_recep-Potato-None-CounterTop-5__trial_T20190909_123212_517019": 1.0,
|
| 111 |
+
"pick_clean_then_place_in_recep-Potato-None-Fridge-17__trial_T20190909_135834_661867": 1.0,
|
| 112 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-428__trial_T20190908_084117_719605": 1.0,
|
| 113 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-409__trial_T20190908_025402_020595": 1.0,
|
| 114 |
+
"pick_clean_then_place_in_recep-SoapBar-None-GarbageCan-416__trial_T20190907_024728_127108": 1.0,
|
| 115 |
+
"pick_clean_then_place_in_recep-SoapBar-None-GarbageCan-429__trial_T20190909_015556_293557": 1.0,
|
| 116 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-420__trial_T20190908_043134_210616": 1.0,
|
| 117 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Toilet-428__trial_T20190907_041322_837354": 1.0,
|
| 118 |
+
"pick_clean_then_place_in_recep-Spatula-None-CounterTop-13__trial_T20190909_023039_986825": 1.0,
|
| 119 |
+
"pick_clean_then_place_in_recep-Tomato-None-Fridge-20__trial_T20190909_091539_383661": 1.0,
|
| 120 |
+
"pick_clean_then_place_in_recep-Tomato-None-SideTable-21__trial_T20190907_164958_308793": 1.0,
|
| 121 |
+
"pick_cool_then_place_in_recep-Bowl-None-Cabinet-18__trial_T20190908_144624_086654": 1.0,
|
| 122 |
+
"pick_cool_then_place_in_recep-Bowl-None-Shelf-20__trial_T20190908_034339_870890": 1.0,
|
| 123 |
+
"pick_cool_then_place_in_recep-Cup-None-Cabinet-26__trial_T20190909_085908_816209": 1.0,
|
| 124 |
+
"pick_cool_then_place_in_recep-Cup-None-Cabinet-30__trial_T20190909_090746_864458": 1.0,
|
| 125 |
+
"pick_cool_then_place_in_recep-Egg-None-CounterTop-27__trial_T20190909_002015_890646": 1.0,
|
| 126 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-24__trial_T20190908_015109_682752": 1.0,
|
| 127 |
+
"pick_cool_then_place_in_recep-Lettuce-None-DiningTable-18__trial_T20190909_122629_020439": 1.0,
|
| 128 |
+
"pick_cool_then_place_in_recep-Lettuce-None-DiningTable-24__trial_T20190908_062436_694989": 1.0,
|
| 129 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-11__trial_T20190908_021957_189338": 1.0,
|
| 130 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-14__trial_T20190906_182932_157770": 1.0,
|
| 131 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-23__trial_T20190908_143209_571893": 1.0,
|
| 132 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-11__trial_T20190908_204414_053313": 1.0,
|
| 133 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-15__trial_T20190909_003904_518800": 1.0,
|
| 134 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-23__trial_T20190909_005833_061416": 1.0,
|
| 135 |
+
"pick_cool_then_place_in_recep-Pan-None-DiningTable-7__trial_T20190909_094708_361033": 1.0,
|
| 136 |
+
"pick_cool_then_place_in_recep-Pan-None-StoveBurner-23__trial_T20190906_215826_707811": 1.0,
|
| 137 |
+
"pick_cool_then_place_in_recep-Plate-None-DiningTable-23__trial_T20190910_025008_561989": 1.0,
|
| 138 |
+
"pick_cool_then_place_in_recep-Plate-None-Shelf-7__trial_T20190907_125004_299560": 1.0,
|
| 139 |
+
"pick_cool_then_place_in_recep-Pot-None-CounterTop-5__trial_T20190908_073249_042493": 1.0,
|
| 140 |
+
"pick_cool_then_place_in_recep-Pot-None-DiningTable-27__trial_T20190909_013328_302952": 1.0,
|
| 141 |
+
"pick_cool_then_place_in_recep-Potato-None-CounterTop-30__trial_T20190908_111757_114406": 1.0,
|
| 142 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-5__trial_T20190910_115040_425451": 1.0,
|
| 143 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-13__trial_T20190910_173429_847749": 1.0,
|
| 144 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-14__trial_T20190907_024221_811233": 1.0,
|
| 145 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-5__trial_T20190908_132124_203759": 1.0,
|
| 146 |
+
"pick_cool_then_place_in_recep-WineBottle-None-Cabinet-17__trial_T20190907_064115_485667": 1.0,
|
| 147 |
+
"pick_cool_then_place_in_recep-WineBottle-None-DiningTable-17__trial_T20190908_003313_375871": 1.0,
|
| 148 |
+
"pick_cool_then_place_in_recep-WineBottle-None-GarbageCan-16__trial_T20190907_014908_758565": 1.0,
|
| 149 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-6__trial_T20190908_153841_522662": 1.0,
|
| 150 |
+
"pick_heat_then_place_in_recep-Apple-None-SideTable-28__trial_T20190906_180828_374034": 1.0,
|
| 151 |
+
"pick_heat_then_place_in_recep-Cup-None-Shelf-1__trial_T20190906_230051_015449": 1.0,
|
| 152 |
+
"pick_heat_then_place_in_recep-Cup-None-SideTable-3__trial_T20190908_210847_591144": 1.0,
|
| 153 |
+
"pick_heat_then_place_in_recep-Egg-None-DiningTable-15__trial_T20190908_042212_100074": 1.0,
|
| 154 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-23__trial_T20190911_011457_072067": 1.0,
|
| 155 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-2__trial_T20190907_070838_688262": 1.0,
|
| 156 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-21__trial_T20190908_113549_665152": 1.0,
|
| 157 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-22__trial_T20190906_184650_216044": 1.0,
|
| 158 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-5__trial_T20190908_040351_384338": 1.0,
|
| 159 |
+
"pick_heat_then_place_in_recep-Mug-None-SideTable-21__trial_T20190909_090802_375850": 1.0,
|
| 160 |
+
"pick_heat_then_place_in_recep-Mug-None-SideTable-28__trial_T20190908_212801_623417": 1.0,
|
| 161 |
+
"pick_heat_then_place_in_recep-Plate-None-Cabinet-7__trial_T20190907_144322_406779": 1.0,
|
| 162 |
+
"pick_heat_then_place_in_recep-Plate-None-CounterTop-1__trial_T20190909_115700_060162": 1.0,
|
| 163 |
+
"pick_heat_then_place_in_recep-Potato-None-CounterTop-25__trial_T20190908_003752_653811": 1.0,
|
| 164 |
+
"pick_heat_then_place_in_recep-Potato-None-DiningTable-16__trial_T20190908_015009_437240": 1.0,
|
| 165 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-12__trial_T20190910_094522_460953": 1.0,
|
| 166 |
+
"pick_heat_then_place_in_recep-Potato-None-Fridge-27__trial_T20190908_143711_459299": 1.0,
|
| 167 |
+
"pick_heat_then_place_in_recep-Tomato-None-CounterTop-2__trial_T20190908_171656_745023": 1.0,
|
| 168 |
+
"pick_heat_then_place_in_recep-Tomato-None-CounterTop-20__trial_T20190909_041153_700490": 1.0,
|
| 169 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-12__trial_T20190906_190527_670222": 1.0,
|
| 170 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-14__trial_T20190908_091828_220110": 1.0,
|
| 171 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-15__trial_T20190909_020126_376897": 1.0,
|
| 172 |
+
"pick_heat_then_place_in_recep-Tomato-None-Fridge-24__trial_T20190908_033524_642305": 1.0,
|
| 173 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-16__trial_T20190906_171827_526847": 1.0,
|
| 174 |
+
"pick_two_obj_and_place-Book-None-Desk-302__trial_T20190906_181314_259738": 1.0,
|
| 175 |
+
"pick_two_obj_and_place-Book-None-Desk-309__trial_T20190909_061156_951604": 1.0,
|
| 176 |
+
"pick_two_obj_and_place-Box-None-CoffeeTable-230__trial_T20190908_124255_946115": 1.0,
|
| 177 |
+
"pick_two_obj_and_place-CD-None-Drawer-306__trial_T20190907_025539_829173": 1.0,
|
| 178 |
+
"pick_two_obj_and_place-CD-None-Dresser-303__trial_T20190908_085826_396748": 1.0,
|
| 179 |
+
"pick_two_obj_and_place-Candle-None-CounterTop-406__trial_T20190908_045958_916084": 1.0,
|
| 180 |
+
"pick_two_obj_and_place-CellPhone-None-Desk-312__trial_T20190908_122230_946481": 1.0,
|
| 181 |
+
"pick_two_obj_and_place-CellPhone-None-Drawer-318__trial_T20190908_104535_936869": 1.0,
|
| 182 |
+
"pick_two_obj_and_place-CellPhone-None-Drawer-329__trial_T20190909_030028_020737": 1.0,
|
| 183 |
+
"pick_two_obj_and_place-CellPhone-None-Dresser-330__trial_T20190909_060924_095249": 1.0,
|
| 184 |
+
"pick_two_obj_and_place-CellPhone-None-Sofa-224__trial_T20190918_223409_525979": 1.0,
|
| 185 |
+
"pick_two_obj_and_place-Cloth-None-Drawer-411__trial_T20190908_190008_902235": 1.0,
|
| 186 |
+
"pick_two_obj_and_place-CreditCard-None-Desk-313__trial_T20190909_104504_038752": 1.0,
|
| 187 |
+
"pick_two_obj_and_place-CreditCard-None-DiningTable-329__trial_T20190918_154222_318527": 1.0,
|
| 188 |
+
"pick_two_obj_and_place-CreditCard-None-Safe-323__trial_T20190907_001424_961488": 1.0,
|
| 189 |
+
"pick_two_obj_and_place-CreditCard-None-Sofa-206__trial_T20190906_203615_424745": 1.0,
|
| 190 |
+
"pick_two_obj_and_place-Cup-None-Shelf-1__trial_T20190908_015402_128805": 1.0,
|
| 191 |
+
"pick_two_obj_and_place-KeyChain-None-Dresser-318__trial_T20190907_181205_590674": 1.0,
|
| 192 |
+
"pick_two_obj_and_place-KeyChain-None-Ottoman-208__trial_T20190907_232759_901444": 1.0,
|
| 193 |
+
"pick_two_obj_and_place-KeyChain-None-Sofa-225__trial_T20190907_143028_102387": 1.0,
|
| 194 |
+
"pick_two_obj_and_place-Newspaper-None-ArmChair-214__trial_T20190909_010843_771227": 1.0,
|
| 195 |
+
"pick_two_obj_and_place-Newspaper-None-Sofa-230__trial_T20190908_035335_001162": 1.0,
|
| 196 |
+
"pick_two_obj_and_place-Pencil-None-Drawer-327__trial_T20190908_103604_088470": 1.0,
|
| 197 |
+
"pick_two_obj_and_place-Pencil-None-SideTable-329__trial_T20190909_040132_412120": 1.0,
|
| 198 |
+
"pick_two_obj_and_place-Pillow-None-Ottoman-208__trial_T20190907_030106_770418": 1.0,
|
| 199 |
+
"pick_two_obj_and_place-RemoteControl-None-ArmChair-208__trial_T20190908_000903_032547": 1.0,
|
| 200 |
+
"pick_two_obj_and_place-RemoteControl-None-Ottoman-210__trial_T20190906_202114_729948": 1.0,
|
| 201 |
+
"pick_two_obj_and_place-RemoteControl-None-Sofa-207__trial_T20190908_111223_597180": 1.0,
|
| 202 |
+
"pick_two_obj_and_place-SoapBar-None-Cabinet-428__trial_T20190910_231209_039518": 1.0,
|
| 203 |
+
"pick_two_obj_and_place-SoapBar-None-Drawer-420__trial_T20190908_124733_053705": 1.0,
|
| 204 |
+
"pick_two_obj_and_place-SoapBottle-None-Cabinet-417__trial_T20190909_211711_664720": 1.0,
|
| 205 |
+
"pick_two_obj_and_place-SoapBottle-None-Cart-401__trial_T20190908_215242_345375": 1.0,
|
| 206 |
+
"pick_two_obj_and_place-SoapBottle-None-Toilet-426__trial_T20190907_184729_585161": 1.0,
|
| 207 |
+
"pick_two_obj_and_place-SprayBottle-None-CounterTop-409__trial_T20190908_131755_202053": 1.0,
|
| 208 |
+
"pick_two_obj_and_place-SprayBottle-None-GarbageCan-413__trial_T20190912_044451_035192": 1.0,
|
| 209 |
+
"pick_two_obj_and_place-SprayBottle-None-GarbageCan-420__trial_T20190907_174658_354066": 1.0,
|
| 210 |
+
"pick_two_obj_and_place-SprayBottle-None-Toilet-417__trial_T20190908_071820_505015": 1.0,
|
| 211 |
+
"pick_two_obj_and_place-Statue-None-Dresser-213__trial_T20190909_065309_623947": 1.0,
|
| 212 |
+
"pick_two_obj_and_place-TissueBox-None-CoffeeTable-220__trial_T20190909_145750_484036": 1.0,
|
| 213 |
+
"pick_two_obj_and_place-TissueBox-None-CoffeeTable-230__trial_T20190909_145658_750781": 1.0,
|
| 214 |
+
"pick_two_obj_and_place-TissueBox-None-DiningTable-230__trial_T20190909_145553_211575": 1.0,
|
| 215 |
+
"pick_two_obj_and_place-ToiletPaper-None-Cabinet-412__trial_T20190908_141555_713466": 1.0,
|
| 216 |
+
"pick_two_obj_and_place-ToiletPaper-None-Drawer-409__trial_T20190906_193417_937668": 1.0,
|
| 217 |
+
"pick_two_obj_and_place-ToiletPaper-None-Toilet-405__trial_T20190909_065947_451268": 1.0,
|
| 218 |
+
"pick_two_obj_and_place-Watch-None-CoffeeTable-209__trial_T20190909_020350_646515": 1.0
|
| 219 |
+
},
|
| 220 |
+
"traces": "eval-traces/round-3-valid_train.tar.gz"
|
| 221 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/eval/round-3-valid_unseen.json
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "hg-eval-cell.v1",
|
| 3 |
+
"method": "ahe",
|
| 4 |
+
"round": 3,
|
| 5 |
+
"pool": "valid_unseen",
|
| 6 |
+
"stamp": "20261017T123952Z",
|
| 7 |
+
"run_id": "rsi10-20261017T123952Z-ahe-exam-valid_unseen",
|
| 8 |
+
"score": 1.0,
|
| 9 |
+
"n_scored": 134,
|
| 10 |
+
"n_invalid": 0,
|
| 11 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 12 |
+
"evaluated_from": {
|
| 13 |
+
"run_id": "rsi10-20261017T123952Z-ahe-train",
|
| 14 |
+
"round": 3,
|
| 15 |
+
"harness_sha": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 16 |
+
"train_score": 1.0
|
| 17 |
+
},
|
| 18 |
+
"per_task": {
|
| 19 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-308__trial_T20190908_222917_366542": 1.0,
|
| 20 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-308__trial_T20190908_222933_607649": 1.0,
|
| 21 |
+
"look_at_obj_in_light-AlarmClock-None-DeskLamp-308__trial_T20190908_222951_616606": 1.0,
|
| 22 |
+
"look_at_obj_in_light-Book-None-DeskLamp-308__trial_T20190908_020029_636862": 1.0,
|
| 23 |
+
"look_at_obj_in_light-Book-None-DeskLamp-308__trial_T20190908_020048_814402": 1.0,
|
| 24 |
+
"look_at_obj_in_light-Book-None-DeskLamp-308__trial_T20190908_144951_587345": 1.0,
|
| 25 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-308__trial_T20190907_133919_856963": 1.0,
|
| 26 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-308__trial_T20190907_133935_066606": 1.0,
|
| 27 |
+
"look_at_obj_in_light-Bowl-None-DeskLamp-308__trial_T20190907_133953_562557": 1.0,
|
| 28 |
+
"look_at_obj_in_light-CD-None-DeskLamp-308__trial_T20190908_141942_810052": 1.0,
|
| 29 |
+
"look_at_obj_in_light-CD-None-DeskLamp-308__trial_T20190908_141958_463362": 1.0,
|
| 30 |
+
"look_at_obj_in_light-CD-None-DeskLamp-308__trial_T20190908_142046_281296": 1.0,
|
| 31 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-308__trial_T20190908_161733_213242": 1.0,
|
| 32 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-308__trial_T20190908_201421_021646": 1.0,
|
| 33 |
+
"look_at_obj_in_light-Mug-None-DeskLamp-308__trial_T20190908_201444_037645": 1.0,
|
| 34 |
+
"look_at_obj_in_light-Pencil-None-DeskLamp-308__trial_T20190908_220545_153480": 1.0,
|
| 35 |
+
"look_at_obj_in_light-Pencil-None-DeskLamp-308__trial_T20190908_220604_010430": 1.0,
|
| 36 |
+
"look_at_obj_in_light-Pencil-None-DeskLamp-308__trial_T20190908_220656_510400": 1.0,
|
| 37 |
+
"pick_and_place_simple-Mug-None-Desk-308__trial_T20190908_125200_737896": 1.0,
|
| 38 |
+
"pick_and_place_simple-Mug-None-Desk-308__trial_T20190909_203041_433487": 1.0,
|
| 39 |
+
"pick_and_place_simple-Mug-None-Desk-308__trial_T20190909_210238_431966": 1.0,
|
| 40 |
+
"pick_and_place_simple-Pencil-None-Shelf-308__trial_T20190908_121952_610012": 1.0,
|
| 41 |
+
"pick_and_place_simple-Pencil-None-Shelf-308__trial_T20190908_122024_052056": 1.0,
|
| 42 |
+
"pick_and_place_simple-Pencil-None-Shelf-308__trial_T20190908_122154_042763": 1.0,
|
| 43 |
+
"pick_and_place_simple-PepperShaker-None-Drawer-10__trial_T20190906_184021_215264": 1.0,
|
| 44 |
+
"pick_and_place_simple-PepperShaker-None-Drawer-10__trial_T20190918_154326_823501": 1.0,
|
| 45 |
+
"pick_and_place_simple-PepperShaker-None-Drawer-10__trial_T20190918_154424_844749": 1.0,
|
| 46 |
+
"pick_and_place_simple-SaltShaker-None-Cabinet-10__trial_T20190906_191429_743650": 1.0,
|
| 47 |
+
"pick_and_place_simple-SaltShaker-None-Cabinet-10__trial_T20190906_191445_723170": 1.0,
|
| 48 |
+
"pick_and_place_simple-SaltShaker-None-Cabinet-10__trial_T20190906_191501_563086": 1.0,
|
| 49 |
+
"pick_and_place_simple-SaltShaker-None-Drawer-10__trial_T20190909_021613_077537": 1.0,
|
| 50 |
+
"pick_and_place_simple-SaltShaker-None-Drawer-10__trial_T20190909_021650_880235": 1.0,
|
| 51 |
+
"pick_and_place_simple-SaltShaker-None-Drawer-10__trial_T20190909_021728_339782": 1.0,
|
| 52 |
+
"pick_and_place_simple-SoapBottle-None-Toilet-424__trial_T20190907_004321_405868": 1.0,
|
| 53 |
+
"pick_and_place_simple-SoapBottle-None-Toilet-424__trial_T20190907_004351_281384": 1.0,
|
| 54 |
+
"pick_and_place_simple-SoapBottle-None-Toilet-424__trial_T20190907_004404_604165": 1.0,
|
| 55 |
+
"pick_and_place_simple-Vase-None-Safe-219__trial_T20190908_205204_244321": 1.0,
|
| 56 |
+
"pick_and_place_simple-Vase-None-Safe-219__trial_T20190908_205221_748352": 1.0,
|
| 57 |
+
"pick_and_place_simple-Vase-None-Safe-219__trial_T20190908_205246_776817": 1.0,
|
| 58 |
+
"pick_and_place_simple-Watch-None-Safe-219__trial_T20190907_074524_006355": 1.0,
|
| 59 |
+
"pick_and_place_simple-Watch-None-Safe-219__trial_T20190907_074556_124850": 1.0,
|
| 60 |
+
"pick_and_place_simple-Watch-None-Safe-219__trial_T20190907_074643_810052": 1.0,
|
| 61 |
+
"pick_clean_then_place_in_recep-Bowl-None-Cabinet-10__trial_T20190909_061130_844814": 1.0,
|
| 62 |
+
"pick_clean_then_place_in_recep-Bowl-None-Cabinet-10__trial_T20190909_061158_110530": 1.0,
|
| 63 |
+
"pick_clean_then_place_in_recep-Bowl-None-Cabinet-10__trial_T20190909_061232_368489": 1.0,
|
| 64 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cabinet-424__trial_T20190908_022321_380927": 1.0,
|
| 65 |
+
"pick_clean_then_place_in_recep-Cloth-None-Cabinet-424__trial_T20190908_022436_073995": 1.0,
|
| 66 |
+
"pick_clean_then_place_in_recep-Cloth-None-CounterTop-424__trial_T20190908_100632_546757": 1.0,
|
| 67 |
+
"pick_clean_then_place_in_recep-Cloth-None-CounterTop-424__trial_T20190908_114340_674467": 1.0,
|
| 68 |
+
"pick_clean_then_place_in_recep-Egg-None-Microwave-10__trial_T20190909_120554_888709": 1.0,
|
| 69 |
+
"pick_clean_then_place_in_recep-Egg-None-Microwave-10__trial_T20190909_120632_691361": 1.0,
|
| 70 |
+
"pick_clean_then_place_in_recep-Egg-None-Microwave-10__trial_T20190909_120712_273910": 1.0,
|
| 71 |
+
"pick_clean_then_place_in_recep-Knife-None-CounterTop-10__trial_T20190909_110347_624008": 1.0,
|
| 72 |
+
"pick_clean_then_place_in_recep-Knife-None-CounterTop-10__trial_T20190909_110445_675754": 1.0,
|
| 73 |
+
"pick_clean_then_place_in_recep-Knife-None-CounterTop-10__trial_T20190909_110531_148235": 1.0,
|
| 74 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_221208_560499": 1.0,
|
| 75 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_221300_362511": 1.0,
|
| 76 |
+
"pick_clean_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_221355_558505": 1.0,
|
| 77 |
+
"pick_clean_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_032434_013084": 1.0,
|
| 78 |
+
"pick_clean_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_032518_891433": 1.0,
|
| 79 |
+
"pick_clean_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_032543_712058": 1.0,
|
| 80 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-10__trial_T20190908_213356_017769": 1.0,
|
| 81 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-10__trial_T20190908_213420_728917": 1.0,
|
| 82 |
+
"pick_clean_then_place_in_recep-Plate-None-CounterTop-10__trial_T20190908_213533_897289": 1.0,
|
| 83 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-424__trial_T20190908_214926_337906": 1.0,
|
| 84 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-424__trial_T20190908_214946_567644": 1.0,
|
| 85 |
+
"pick_clean_then_place_in_recep-SoapBar-None-Cabinet-424__trial_T20190908_215019_162873": 1.0,
|
| 86 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-424__trial_T20190907_074045_109439": 1.0,
|
| 87 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-424__trial_T20190907_074106_050405": 1.0,
|
| 88 |
+
"pick_clean_then_place_in_recep-SoapBar-None-CounterTop-424__trial_T20190907_074124_966890": 1.0,
|
| 89 |
+
"pick_clean_then_place_in_recep-Spatula-None-Drawer-10__trial_T20190907_080730_211959": 1.0,
|
| 90 |
+
"pick_clean_then_place_in_recep-Spatula-None-Drawer-10__trial_T20190907_080800_275989": 1.0,
|
| 91 |
+
"pick_clean_then_place_in_recep-Spatula-None-Drawer-10__trial_T20190907_080825_222432": 1.0,
|
| 92 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-10__trial_T20190908_091747_866951": 1.0,
|
| 93 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-10__trial_T20190908_091811_414150": 1.0,
|
| 94 |
+
"pick_cool_then_place_in_recep-Bread-None-CounterTop-10__trial_T20190908_091835_825830": 1.0,
|
| 95 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-10__trial_T20190909_123133_763972": 1.0,
|
| 96 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-10__trial_T20190909_174807_646433": 1.0,
|
| 97 |
+
"pick_cool_then_place_in_recep-Lettuce-None-CounterTop-10__trial_T20190909_174840_771703": 1.0,
|
| 98 |
+
"pick_cool_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_121559_082363": 1.0,
|
| 99 |
+
"pick_cool_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_121635_622676": 1.0,
|
| 100 |
+
"pick_cool_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_121710_650938": 1.0,
|
| 101 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_183715_299073": 1.0,
|
| 102 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_183807_477267": 1.0,
|
| 103 |
+
"pick_cool_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_183853_958104": 1.0,
|
| 104 |
+
"pick_cool_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_114545_244903": 1.0,
|
| 105 |
+
"pick_cool_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_114622_738670": 1.0,
|
| 106 |
+
"pick_cool_then_place_in_recep-Pan-None-CounterTop-10__trial_T20190908_114656_768805": 1.0,
|
| 107 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-10__trial_T20190907_033157_424297": 1.0,
|
| 108 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-10__trial_T20190907_033228_194678": 1.0,
|
| 109 |
+
"pick_cool_then_place_in_recep-Potato-None-Microwave-10__trial_T20190907_033306_962974": 1.0,
|
| 110 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-10__trial_T20190909_102608_318800": 1.0,
|
| 111 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-10__trial_T20190909_102644_926781": 1.0,
|
| 112 |
+
"pick_cool_then_place_in_recep-Tomato-None-Microwave-10__trial_T20190909_102710_795182": 1.0,
|
| 113 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-10__trial_T20190906_182259_116320": 1.0,
|
| 114 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-10__trial_T20190906_182353_418140": 1.0,
|
| 115 |
+
"pick_heat_then_place_in_recep-Apple-None-Fridge-10__trial_T20190906_182435_622538": 1.0,
|
| 116 |
+
"pick_heat_then_place_in_recep-Apple-None-GarbageCan-10__trial_T20190908_145050_918567": 1.0,
|
| 117 |
+
"pick_heat_then_place_in_recep-Apple-None-GarbageCan-10__trial_T20190908_145143_820541": 1.0,
|
| 118 |
+
"pick_heat_then_place_in_recep-Apple-None-GarbageCan-10__trial_T20190908_145356_918528": 1.0,
|
| 119 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-10__trial_T20190907_083346_800823": 1.0,
|
| 120 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-10__trial_T20190907_083429_887065": 1.0,
|
| 121 |
+
"pick_heat_then_place_in_recep-Cup-None-Cabinet-10__trial_T20190907_083507_594820": 1.0,
|
| 122 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-10__trial_T20190908_113432_673307": 1.0,
|
| 123 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-10__trial_T20190908_113523_123938": 1.0,
|
| 124 |
+
"pick_heat_then_place_in_recep-Egg-None-GarbageCan-10__trial_T20190908_113610_425142": 1.0,
|
| 125 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_021100_341887": 1.0,
|
| 126 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_021200_669381": 1.0,
|
| 127 |
+
"pick_heat_then_place_in_recep-Mug-None-Cabinet-10__trial_T20190909_021247_306737": 1.0,
|
| 128 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_171806_406231": 1.0,
|
| 129 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_171850_960211": 1.0,
|
| 130 |
+
"pick_heat_then_place_in_recep-Mug-None-CoffeeMachine-10__trial_T20190907_171933_349922": 1.0,
|
| 131 |
+
"pick_heat_then_place_in_recep-Potato-None-GarbageCan-10__trial_T20190907_161745_664033": 1.0,
|
| 132 |
+
"pick_heat_then_place_in_recep-Potato-None-GarbageCan-10__trial_T20190907_161853_945788": 1.0,
|
| 133 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-10__trial_T20190908_225046_020282": 1.0,
|
| 134 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-10__trial_T20190908_225359_617900": 1.0,
|
| 135 |
+
"pick_heat_then_place_in_recep-Tomato-None-GarbageCan-10__trial_T20190908_225453_272533": 1.0,
|
| 136 |
+
"pick_two_obj_and_place-CD-None-Safe-308__trial_T20190907_050942_897916": 1.0,
|
| 137 |
+
"pick_two_obj_and_place-CD-None-Safe-308__trial_T20190907_051013_060265": 1.0,
|
| 138 |
+
"pick_two_obj_and_place-CD-None-Safe-308__trial_T20190907_051056_585414": 1.0,
|
| 139 |
+
"pick_two_obj_and_place-KeyChain-None-Safe-219__trial_T20190909_011803_423115": 1.0,
|
| 140 |
+
"pick_two_obj_and_place-KeyChain-None-Safe-219__trial_T20190909_012027_782483": 1.0,
|
| 141 |
+
"pick_two_obj_and_place-PepperShaker-None-Drawer-10__trial_T20190908_010306_215435": 1.0,
|
| 142 |
+
"pick_two_obj_and_place-PepperShaker-None-Drawer-10__trial_T20190912_221016_460197": 1.0,
|
| 143 |
+
"pick_two_obj_and_place-PepperShaker-None-Drawer-10__trial_T20190912_221141_608117": 1.0,
|
| 144 |
+
"pick_two_obj_and_place-Pillow-None-Sofa-219__trial_T20190907_163240_345855": 1.0,
|
| 145 |
+
"pick_two_obj_and_place-Pillow-None-Sofa-219__trial_T20190907_163327_486300": 1.0,
|
| 146 |
+
"pick_two_obj_and_place-Pillow-None-Sofa-219__trial_T20190907_163408_914117": 1.0,
|
| 147 |
+
"pick_two_obj_and_place-SoapBar-None-Cabinet-424__trial_T20190909_081720_491733": 1.0,
|
| 148 |
+
"pick_two_obj_and_place-SoapBar-None-Cabinet-424__trial_T20190909_081746_857594": 1.0,
|
| 149 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-424__trial_T20190909_064053_839817": 1.0,
|
| 150 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-424__trial_T20190909_064221_368939": 1.0,
|
| 151 |
+
"pick_two_obj_and_place-SoapBar-None-GarbageCan-424__trial_T20190909_064309_357168": 1.0,
|
| 152 |
+
"pick_two_obj_and_place-ToiletPaper-None-Cabinet-424__trial_T20190906_202926_527010": 1.0
|
| 153 |
+
},
|
| 154 |
+
"traces": "eval-traces/round-3-valid_unseen.tar.gz"
|
| 155 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-0/.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
_harnessgrad/
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.pyc
|
| 5 |
+
.state/
|
| 6 |
+
*.bak
|
| 7 |
+
*.orig
|
| 8 |
+
*.rej
|
| 9 |
+
*~
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-0/agent.py
ADDED
|
@@ -0,0 +1,767 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""The reference base harness: a minimal ReAct loop.
|
| 3 |
+
|
| 4 |
+
Deliberately the simplest thing that satisfies the contract in
|
| 5 |
+
`docs/writing_a_harness.md`. Its job is not to be strong -- it is to be:
|
| 6 |
+
|
| 7 |
+
1. a valid starting point that a method can improve, and
|
| 8 |
+
2. the proof that the contract is implementable at all.
|
| 9 |
+
|
| 10 |
+
A method may replace every file here. That is the point.
|
| 11 |
+
|
| 12 |
+
**What it ships, and why that changed.** This harness used to be a bare loop: no
|
| 13 |
+
context policy, no output bounding, no retries. That is still the design -- but
|
| 14 |
+
these mechanisms are now in it, and each is here because a measurement said the
|
| 15 |
+
bare loop could not be measured at all, not because a mechanism is nice to have:
|
| 16 |
+
|
| 17 |
+
* `PARSE_RETRIES`, `SUBMIT_RETRIES`, `FINISH_NUDGE_STEPS`, `REPEAT_NUDGE_LIMIT`
|
| 18 |
+
-- one unreadable reply, or one premature "I am done", used to end the whole
|
| 19 |
+
task. Measured: 73 of 266 runs reached the step cap with nothing submitted,
|
| 20 |
+
and one task died after exactly one model call.
|
| 21 |
+
* `OUTPUT_LIMIT`, `CONTEXT_CHAR_BUDGET` -- a command that printed a large file
|
| 22 |
+
left the next call over the model's context limit, which killed the task.
|
| 23 |
+
* line-buffered trace writes -- a block buffer meant a killed task lost its tail,
|
| 24 |
+
so "killed at step 30" and "never started" were the same record.
|
| 25 |
+
|
| 26 |
+
All of them are still named switches with an `HG_AGENT_*` override, so a method
|
| 27 |
+
may change or remove any of them; what a method adds *on top* is the measurement.
|
| 28 |
+
The values actually in force go into the trace (`harness_identity.config`, below)
|
| 29 |
+
and land on the curve point, because two runs of this same file at two different
|
| 30 |
+
step caps are two different harnesses and the file hash cannot tell them apart.
|
| 31 |
+
"""
|
| 32 |
+
from __future__ import annotations
|
| 33 |
+
|
| 34 |
+
import argparse
|
| 35 |
+
import json
|
| 36 |
+
import os
|
| 37 |
+
import shutil
|
| 38 |
+
import subprocess
|
| 39 |
+
import sys
|
| 40 |
+
import time
|
| 41 |
+
from pathlib import Path
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
#: How many model calls one task gets. **A floor on capability, not a tuning knob.**
|
| 45 |
+
#:
|
| 46 |
+
#: Measured at 8, on Terminal-Bench, 4 rounds x 5 tasks: four of the five tasks used all
|
| 47 |
+
#: eight and produced no graded artifact at all -- `build-pmars` was still installing
|
| 48 |
+
#: packages, `bn-fit-modify` had just finished installing pandas/numpy/sklearn and
|
| 49 |
+
#: printed one correlation matrix, `chess-best-move` had opened the PNG and never wrote
|
| 50 |
+
#: `/app/move.txt`. The score was 0.0 on every task in every round, which is not a weak
|
| 51 |
+
#: harness being measured: it is a floor effect, and a floor makes every method look
|
| 52 |
+
#: identical because there is no gradient for one to move.
|
| 53 |
+
#:
|
| 54 |
+
#: Raising this does not make the harness cleverer -- `legacy/adapters/harnessgrad_domain/`
|
| 55 |
+
#: already names this lever as the trap ("helps only if the model is already using the
|
| 56 |
+
#: steps it has"). Here the trace shows it *was* using them, which is exactly when the
|
| 57 |
+
#: lever is legitimate. What it costs is bounded by the task, not by this number: the
|
| 58 |
+
#: wall clock is capped by the environment's `agent_timeout_s` (900 s for most
|
| 59 |
+
#: Terminal-Bench tasks, 3600 s for `bn-fit-modify`). A step is fast (~0.2 s model round
|
| 60 |
+
#: trip through the local gateway), so the extra ceiling mostly buys back the steps that
|
| 61 |
+
#: environment setup eats. The loop still stops the moment the model answers -- the cap
|
| 62 |
+
#: is a ceiling, not a quota.
|
| 63 |
+
MAX_STEPS = int(os.environ.get("HG_AGENT_MAX_STEPS", "32"))
|
| 64 |
+
MAX_OUTPUT_TOKENS = int(os.environ.get("HG_AGENT_MAX_OUTPUT_TOKENS", "2048"))
|
| 65 |
+
if MAX_OUTPUT_TOKENS < 1:
|
| 66 |
+
raise ValueError("HG_AGENT_MAX_OUTPUT_TOKENS must be positive")
|
| 67 |
+
|
| 68 |
+
#: 模型说"我做完了"之后,允许它再被退回几次。
|
| 69 |
+
#:
|
| 70 |
+
#: 为什么需要这个:harness 以前**从不检查交付物**。模型回一句 {"answer": ...} 就被当成
|
| 71 |
+
#: 任务结束、退出循环。实测(2026-10-02,terminal_bench round 0):五道题的 agent 阶段是
|
| 72 |
+
#: 101s / 31s / 183s / **4.5s** / 105s —— 而步数上限是 32。4.5 秒等于一次模型调用就
|
| 73 |
+
#: "交卷"了,产物根本不存在;`cancel-async-tasks` 的判分因此是
|
| 74 |
+
#: `File /app/run.py does not exist`。
|
| 75 |
+
#:
|
| 76 |
+
#: 所以 0 分的机制不是"步数不够",而是"**harness 把模型说的完成当成了完成**"。
|
| 77 |
+
#: 一个会自己检查交付物、并把"文件不存在"退回给模型重试的 harness,才是这一步该有的样子。
|
| 78 |
+
SUBMIT_RETRIES = int(os.environ.get("HG_AGENT_SUBMIT_RETRIES", "2"))
|
| 79 |
+
|
| 80 |
+
#: 模型吐出一段**读不出动作**的回复之后,允许它再试几次。
|
| 81 |
+
#:
|
| 82 |
+
#: 和上面那条同源,方向相反:一条是"模型说做完了,但产物不在",一条是"模型说的话读不出
|
| 83 |
+
#: 动作"。两条以前都会让**整道题**结束。
|
| 84 |
+
#:
|
| 85 |
+
#: 为什么它必须由起点 harness 负责,而不是留给方法去发现 —— 这是数出来的,不是想出来的。
|
| 86 |
+
#: 统计所有跑道里"方法自己写了理由"的 35 个轮次:**16 个在修解析或格式容错**,而且几乎
|
| 87 |
+
#: 每条跑道的第一轮都在修它:
|
| 88 |
+
#:
|
| 89 |
+
#: `loop-terminal_bench-26452c` 五道题各只调了一次模型就死在
|
| 90 |
+
#: `parse_error: Extra data`(`calls: 1`),此后每一轮都从同一个不能用的 harness 出发;
|
| 91 |
+
#: `flash-three-1/2`、`deepseek-eigen-2`、`strong-model-1` 的第一/第二轮全都写成
|
| 92 |
+
#: "让一次读不懂的回复不再结束整道题"。
|
| 93 |
+
#:
|
| 94 |
+
#: 代价不只是浪费一轮。方法之间开始比"谁先想到修 parser":RRSI 的 leakage critic 两次把
|
| 95 |
+
#: 改 `_parse` 的候选判成 TASK-SPECIALIZATION / LEAKAGE 而拒绝,那一轮于是什么都没改。
|
| 96 |
+
#: 一个起点 harness 必须在被测量之前就活过一次跑题的回复,否则第一轮比较的不是解题能力,
|
| 97 |
+
#: 是管线运气。
|
| 98 |
+
PARSE_RETRIES = int(os.environ.get("HG_AGENT_PARSE_RETRIES", "2"))
|
| 99 |
+
|
| 100 |
+
#: 步数还剩这么多时,明确要求模型收尾。
|
| 101 |
+
#:
|
| 102 |
+
#: 数出来的,不是猜的:266 条历史轨迹里 **73 条(27%)跑满 32 步、一次都没交卷**,而那些
|
| 103 |
+
#: 轨迹的最后两步常常是同一条命令重复(抽样:`python /app/test_outputs.py 2>&1` 两次、
|
| 104 |
+
#: 同一条 `echo ... >` 两次、同一个 `cat > /app/run.py << 'EOF'` 两次)。那些任务不是
|
| 105 |
+
#: "做错了",是**没停下来交卷**:步数用完,`answer` 是空字符串,平台只能拿检查的判决当分数。
|
| 106 |
+
#: `improvers/skill.md` 早就把这条记成已知失败模式("预算用满、什么都没交"),但起点 harness
|
| 107 |
+
#: 一直没有对应动作。一个被测量的 harness 应该在预算耗尽前把话说完。
|
| 108 |
+
FINISH_NUDGE_STEPS = int(os.environ.get("HG_AGENT_FINISH_NUDGE_STEPS", "4"))
|
| 109 |
+
|
| 110 |
+
#: 同一条命令连续重复时提醒几次(每条跑道限量,免得把上下文塞满)。
|
| 111 |
+
REPEAT_NUDGE_LIMIT = int(os.environ.get("HG_AGENT_REPEAT_NUDGE_LIMIT", "2"))
|
| 112 |
+
|
| 113 |
+
#: 单条命令的输出进入消息历史时的字符上限。先压紧 JSON,再保留完整记录预览;
|
| 114 |
+
#: 纯文本留头尾。完整输出留在工作目录,模型可按需读取。
|
| 115 |
+
#:
|
| 116 |
+
#: 实测(2026-10-04,本地 9B,5 道题):**3 道题死于
|
| 117 |
+
#: `This model's maximum context length is 32768 tokens ... your prompt contains at least
|
| 118 |
+
#: 32769 input tokens`(BadRequestError 400)**。起点 harness 以前把每条命令的**完整**输出
|
| 119 |
+
#: 一直往历史里追加,永不截断:一道题里单条输出就有 11773 字符,装一次包、cat 一个大文件
|
| 120 |
+
#: 就够撞上 32k 的窗口。那不是模型的问题,是 harness 没有上下文管理。
|
| 121 |
+
OUTPUT_LIMIT = int(os.environ.get("HG_AGENT_OUTPUT_LIMIT", "4000"))
|
| 122 |
+
|
| 123 |
+
#: 消息历史(不含 system 与题面)的字符预算。按 4 字符 ≈ 1 token 粗估,60k 字符约 15k token,
|
| 124 |
+
#: 给 32k 窗口的模型留出输出空间。超了就丢**最旧的成对消息**,并在轨迹里记下丢了几条 ——
|
| 125 |
+
#: 一个悄悄改变模型所见历史的 harness,和一个被测量的 harness,不是同一件事。
|
| 126 |
+
CONTEXT_CHAR_BUDGET = int(os.environ.get("HG_AGENT_CONTEXT_CHARS", "60000"))
|
| 127 |
+
|
| 128 |
+
SYSTEM = """You are an agent solving a task in a working directory.
|
| 129 |
+
|
| 130 |
+
You have one tool: run a shell command.
|
| 131 |
+
|
| 132 |
+
Reply with EXACTLY one of:
|
| 133 |
+
{"tool": "bash", "command": "<shell command>"}
|
| 134 |
+
{"answer": "<your final answer>"}
|
| 135 |
+
|
| 136 |
+
For a structured final answer, "answer" may be a JSON object containing the task's
|
| 137 |
+
prediction fields.
|
| 138 |
+
|
| 139 |
+
Rules:
|
| 140 |
+
- One action per reply. No prose outside the JSON.
|
| 141 |
+
- Keep commands concise. Use a loop or a script instead of enumerating many calls.
|
| 142 |
+
- To inspect files use shell commands (ls, cat, grep, ...).
|
| 143 |
+
- Give the final answer only when you are confident.
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
# ---------------------------------------------------------------- backends ---
|
| 148 |
+
|
| 149 |
+
def _backend() -> str:
|
| 150 |
+
"""Which completion backend to use.
|
| 151 |
+
|
| 152 |
+
`mock` exists so the framework can be exercised end-to-end with zero network
|
| 153 |
+
and zero cost. Any real curve must declare its backend and model on the curve
|
| 154 |
+
point (INTERFACE.md §3, `identity.agent_model`).
|
| 155 |
+
"""
|
| 156 |
+
return os.environ.get("HG_AGENT_BACKEND", "mock")
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def _call_mock(messages: list[dict]) -> str:
|
| 160 |
+
"""Deterministic stand-in: read answer.txt if present, else list the dir."""
|
| 161 |
+
task_text = messages[1]["content"] if len(messages) > 1 else ""
|
| 162 |
+
if "answer.txt exists" in task_text or "already" in task_text:
|
| 163 |
+
return json.dumps({"answer": "READ_FROM_FILE"})
|
| 164 |
+
return json.dumps({"tool": "bash", "command": "ls -a"})
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
# --------------------------------------------------------------- usage ---
|
| 168 |
+
|
| 169 |
+
#: Token usage accumulated over the run, filled by whichever backend is active.
|
| 170 |
+
#: Read into the trace at the end. Recorded because a mechanism that spends model
|
| 171 |
+
#: calls (history_summary does) is only comparable against a free one if the
|
| 172 |
+
#: spend is visible -- and because a harness whose cost is unknown cannot be
|
| 173 |
+
#: ranked against a cheaper one that scores the same.
|
| 174 |
+
#: `context_trims` 单独计数:它是"模型拒绝了这条 prompt,于是我们削短了历史"的次数。
|
| 175 |
+
#: 和 `retries`(网络/限流)不同 —— 那一种重试发的是同一条 prompt,这一种发的是**更短的**
|
| 176 |
+
#: 一条,模型看到的历史因此和上一步不同。要能分开,才能解释"那一步为什么换了做法"。
|
| 177 |
+
USAGE = {"calls": 0, "input_tokens": 0, "output_tokens": 0, "retries": 0,
|
| 178 |
+
"context_trims": 0}
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def _record_usage(usage) -> None:
|
| 182 |
+
"""Fold provider token counts into the run's total.
|
| 183 |
+
|
| 184 |
+
The call count is NOT incremented here: it is incremented by `_complete`,
|
| 185 |
+
which is the one place every model call goes through. Counting calls at the
|
| 186 |
+
provider boundary would miss the mock backend entirely -- and a mechanism that
|
| 187 |
+
spends model calls on a mock run would then report zero cost, which is exactly
|
| 188 |
+
the invisible-spend the usage block exists to prevent.
|
| 189 |
+
"""
|
| 190 |
+
if usage is None:
|
| 191 |
+
return
|
| 192 |
+
# Provider fields that are absent stay absent rather than becoming zero: a
|
| 193 |
+
# zero that means "not reported" is indistinguishable from a real zero.
|
| 194 |
+
for attr, key in (("prompt_tokens", "input_tokens"),
|
| 195 |
+
("completion_tokens", "output_tokens")):
|
| 196 |
+
v = getattr(usage, attr, None)
|
| 197 |
+
if isinstance(v, int):
|
| 198 |
+
USAGE[key] += v
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def _call_openai(messages: list[dict]) -> str:
|
| 202 |
+
"""One completion, with a deadline and bounded retries.
|
| 203 |
+
|
| 204 |
+
A harness that dies on a transient provider error loses a whole task run, and
|
| 205 |
+
an unbounded retry loop turns a provider outage into a hung experiment. Both
|
| 206 |
+
failures are silent in a batch unless the harness is defensive here.
|
| 207 |
+
"""
|
| 208 |
+
from openai import OpenAI
|
| 209 |
+
|
| 210 |
+
# **每次请求用一条新连接,不复用。** 不是性能取舍,是正确性:
|
| 211 |
+
#
|
| 212 |
+
# 实测(2026-10-02,容器内复现):vLLM 的 uvicorn 默认 5 秒关掉空闲 keep-alive,而
|
| 213 |
+
# 容器到模型之间还有平台发布的一层字节转发网关,它在上游 EOF 时会把 EOF 半关到
|
| 214 |
+
# 客户端。于是"跑一条几十秒的命令、再发起下一次模型调用"就必然复用一条死连接 ——
|
| 215 |
+
# `RemoteDisconnected` → openai 报 `APIConnectionError: Connection error`。
|
| 216 |
+
# 实测那一次,两道题(跑 pandas 的、跑 PIL 的)就是这样死的,而平台把它们记成了 0 分。
|
| 217 |
+
#
|
| 218 |
+
# keep-alive 本身是 HTTP 客户端的正常行为,所以这是网关的缺陷(见 eval/modelgate.py);
|
| 219 |
+
# 但一个 harness 不该把自己的测量押在"中间那一层是否正确处理空闲连接"上。一次本地
|
| 220 |
+
# TCP 握手的代价可以忽略。
|
| 221 |
+
#
|
| 222 |
+
# **用 `default_headers`,不要 import httpx。** 第一版写的是
|
| 223 |
+
# `http_client=httpx.Client(...)`,结果是每次调用都 `ModuleNotFoundError: No module
|
| 224 |
+
# named 'httpx'` —— 这个平台的 harness 依赖由覆盖层提供,而这里 `openai` 3.22.1 依赖的
|
| 225 |
+
# 是 `httpx2`(不是 `httpx`)。所以"顺手 import 一个我以为在的库"在这条路上是错的:
|
| 226 |
+
# 唯一可以依赖的是 `requirements.txt` 声明的那个发行包自己的接口。
|
| 227 |
+
client = OpenAI(
|
| 228 |
+
base_url=os.environ["HG_AGENT_BASE_URL"],
|
| 229 |
+
api_key=os.environ["HG_AGENT_API_KEY"],
|
| 230 |
+
timeout=float(os.environ.get("HG_AGENT_TIMEOUT_S", "180")),
|
| 231 |
+
max_retries=0, # retried here, so the count is ours to record
|
| 232 |
+
default_headers={"Connection": "close"},
|
| 233 |
+
)
|
| 234 |
+
model = os.environ["HG_AGENT_MODEL"]
|
| 235 |
+
attempts = int(os.environ.get("HG_AGENT_RETRIES", "3"))
|
| 236 |
+
last: Exception | None = None
|
| 237 |
+
|
| 238 |
+
for attempt in range(attempts):
|
| 239 |
+
try:
|
| 240 |
+
resp = client.chat.completions.create(
|
| 241 |
+
model=model, messages=messages, temperature=0.0,
|
| 242 |
+
max_tokens=MAX_OUTPUT_TOKENS,
|
| 243 |
+
)
|
| 244 |
+
_record_usage(getattr(resp, "usage", None))
|
| 245 |
+
return resp.choices[0].message.content or ""
|
| 246 |
+
except Exception as exc: # noqa: BLE001
|
| 247 |
+
last = exc
|
| 248 |
+
# **历史太长是可恢复的,以前不是。** 实测(2026-10-04):`git-leak-recovery` 和
|
| 249 |
+
# `regex-chess` 死在 `maximum context length is 32768 tokens ... at least 32769
|
| 250 |
+
# input tokens`,而两道题之前都已经跑了十几步的有效功。字符预算挡不住它
|
| 251 |
+
# (见 `_trim_history`),所以这里按模型自己的拒绝削一半历史再试一次 —— 削掉的
|
| 252 |
+
# 步数记进 `USAGE["context_trims"]`,由主循环写进 trace,不是悄悄改历史。
|
| 253 |
+
if any(marker in str(exc) for marker in _CONTEXT_ERROR_MARKERS) \
|
| 254 |
+
and len(messages) > 4 and attempt + 1 < attempts:
|
| 255 |
+
dropped = _trim_history(messages, budget=(CONTEXT_CHAR_BUDGET // 2))
|
| 256 |
+
if not dropped:
|
| 257 |
+
dropped = _trim_history(messages, budget=1)
|
| 258 |
+
USAGE["context_trims"] += 1
|
| 259 |
+
USAGE["retries"] += 1
|
| 260 |
+
continue
|
| 261 |
+
if attempt + 1 < attempts:
|
| 262 |
+
USAGE["retries"] += 1
|
| 263 |
+
time.sleep(min(2 ** attempt, 30))
|
| 264 |
+
# Out of attempts: raise, so the caller records a harness failure rather than
|
| 265 |
+
# scoring an empty answer as a wrong one.
|
| 266 |
+
raise RuntimeError(f"{attempts} attempts failed, last: {last}") from last
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
def _complete(messages: list[dict]) -> str:
|
| 270 |
+
"""Every model call in this harness goes through here, so this is where the
|
| 271 |
+
count is kept. Counting anywhere else means some caller is invisible."""
|
| 272 |
+
USAGE["calls"] += 1
|
| 273 |
+
return _call_mock(messages) if _backend() == "mock" else _call_openai(messages)
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
# ------------------------------------------------------------- the loop -----
|
| 277 |
+
|
| 278 |
+
class _Action(dict):
|
| 279 |
+
"""A parsed action, plus what the parser had to repair to get it.
|
| 280 |
+
|
| 281 |
+
An attribute rather than a second return value, because every caller wants the
|
| 282 |
+
dict and only one wants the repair note. `duplicates` empty means the reply was
|
| 283 |
+
well formed and nothing was guessed.
|
| 284 |
+
"""
|
| 285 |
+
duplicates: tuple[str, ...] = ()
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
def _first_key_wins(pairs):
|
| 289 |
+
"""Duplicated JSON keys: keep the **first** value, and say which keys repeated.
|
| 290 |
+
|
| 291 |
+
**This is measured, not defensive.** The local 9B (Qwen3.5-9B) writes a file like
|
| 292 |
+
this, and it is the whole reason `cancel-async-tasks` scored 0.0 in
|
| 293 |
+
`local-floor-9`:
|
| 294 |
+
|
| 295 |
+
{"tool": "bash", "command": "cat > /app/run.py << 'EOF'\n...\nEOF\n", "command": ""}
|
| 296 |
+
|
| 297 |
+
The real command is there, and then the model appends `, "command": ""`. JSON says
|
| 298 |
+
a duplicate key keeps the **last** value, so `json.loads` (and `raw_decode`) handed
|
| 299 |
+
the harness an empty command. The harness then ran the empty string -- exit 0, no
|
| 300 |
+
output -- and told the model `exit=0`. The model read that as success, answered
|
| 301 |
+
"the file /app/run.py has been created", and the verifier found no file. All 16
|
| 302 |
+
steps of that trajectory are the model writing the file, being told it worked, and
|
| 303 |
+
checking. Not one step of it wrote anything.
|
| 304 |
+
|
| 305 |
+
Taking the first value is the repair that matches intent here: the long command is
|
| 306 |
+
what the model meant, and the trailing `""` is noise from the same malformation
|
| 307 |
+
that produces its stray braces. It is recorded (`duplicate_keys` in the trace)
|
| 308 |
+
because a harness that silently rewrites the model's action and one that does not
|
| 309 |
+
are different harnesses.
|
| 310 |
+
"""
|
| 311 |
+
action = _Action()
|
| 312 |
+
repeated: list[str] = []
|
| 313 |
+
for key, value in pairs:
|
| 314 |
+
if key in action:
|
| 315 |
+
repeated.append(key)
|
| 316 |
+
continue
|
| 317 |
+
action[key] = value
|
| 318 |
+
if repeated:
|
| 319 |
+
action.duplicates = tuple(repeated)
|
| 320 |
+
return action
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def _json_block_end(text: str, start: int) -> int:
|
| 324 |
+
"""Skip a malformed JSON block without treating its strings as actions."""
|
| 325 |
+
depth = 0
|
| 326 |
+
quoted = escaped = False
|
| 327 |
+
for i in range(start, len(text)):
|
| 328 |
+
ch = text[i]
|
| 329 |
+
if quoted:
|
| 330 |
+
if escaped:
|
| 331 |
+
escaped = False
|
| 332 |
+
elif ch == "\\":
|
| 333 |
+
escaped = True
|
| 334 |
+
elif ch == '"':
|
| 335 |
+
quoted = False
|
| 336 |
+
elif ch == '"':
|
| 337 |
+
quoted = True
|
| 338 |
+
elif ch in "{[":
|
| 339 |
+
depth += 1
|
| 340 |
+
elif ch in "}]":
|
| 341 |
+
depth -= 1
|
| 342 |
+
if depth == 0:
|
| 343 |
+
return i + 1
|
| 344 |
+
return len(text)
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def _parse(reply: str) -> dict:
|
| 348 |
+
"""First complete action, across prose/fences and preceding structured data.
|
| 349 |
+
|
| 350 |
+
Consume whole JSON blocks, so nested data and quoted example actions cannot
|
| 351 |
+
become commands. Never close a truncated command or execute its prefix.
|
| 352 |
+
"""
|
| 353 |
+
decoder = json.JSONDecoder(object_pairs_hook=_first_key_wins)
|
| 354 |
+
i = 0
|
| 355 |
+
while i < len(reply):
|
| 356 |
+
if reply[i] not in "{[":
|
| 357 |
+
i += 1
|
| 358 |
+
continue
|
| 359 |
+
try:
|
| 360 |
+
obj, end = decoder.raw_decode(reply, i)
|
| 361 |
+
except json.JSONDecodeError:
|
| 362 |
+
i = _json_block_end(reply, i)
|
| 363 |
+
continue
|
| 364 |
+
i = end
|
| 365 |
+
if not isinstance(obj, dict) or obj.get("tool", "bash") != "bash":
|
| 366 |
+
continue
|
| 367 |
+
cmd = obj.get("command", "")
|
| 368 |
+
if isinstance(cmd, str) and cmd.strip():
|
| 369 |
+
return obj
|
| 370 |
+
if cmd == "" and "answer" in obj:
|
| 371 |
+
# An outer action can be valid JSON while its answer contains broken
|
| 372 |
+
# inner JSON. Reject it here so the ordinary parse retry can recover.
|
| 373 |
+
_answer_text(obj["answer"])
|
| 374 |
+
return obj
|
| 375 |
+
raise ValueError("no complete JSON action found in reply")
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
def _answer_text(value: object) -> str:
|
| 379 |
+
"""Transport a final answer without inventing or dropping prediction fields.
|
| 380 |
+
|
| 381 |
+
Schema validation belongs to the task's verifier. This only checks transport:
|
| 382 |
+
objects must stay JSON (str(dict) produces Python syntax), and JSON-looking
|
| 383 |
+
strings must be complete. Never close truncated JSON or reinterpret literals.
|
| 384 |
+
"""
|
| 385 |
+
if isinstance(value, dict):
|
| 386 |
+
return json.dumps(value, ensure_ascii=False, allow_nan=False)
|
| 387 |
+
if not isinstance(value, str):
|
| 388 |
+
raise ValueError("final answer must be a string or a JSON object")
|
| 389 |
+
if value.lstrip().startswith("{"):
|
| 390 |
+
try:
|
| 391 |
+
json.loads(value)
|
| 392 |
+
except ValueError as exc:
|
| 393 |
+
raise ValueError(f"final answer contains malformed JSON: {exc}") from exc
|
| 394 |
+
return value
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
#: goal 里形如 `/app/move.txt`、`/app/learned_dag.csv` 的路径。这是**通用**的:
|
| 398 |
+
#: 它不针对任何一道题,只看题面自己说了要写到哪个文件。
|
| 399 |
+
_PATH_RE = __import__("re").compile(r"/[A-Za-z0-9_./-]+\.[A-Za-z0-9]{1,6}\b")
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
def _missing_deliverables(task: dict, workdir: Path) -> list[str]:
|
| 403 |
+
"""题面点名要写、但现在**不存在**的文件。
|
| 404 |
+
|
| 405 |
+
这是 `loop` 自带的交卷闸门,刻意做成通用的两条:
|
| 406 |
+
|
| 407 |
+
* 只看题面(goal)里写出来的绝对路径 —— harness 没有任何途径知道判分脚本要什么
|
| 408 |
+
(`task.json` 里只有 goal),所以它只能相信题面;
|
| 409 |
+
* 只做 `exists` 检查,不执行任何东西。
|
| 410 |
+
|
| 411 |
+
题面没提路径(比如"回答一个问题")时返回空列表,闸门不生效 —— 这时判断对错是平台
|
| 412 |
+
的事,harness 不该假装知道。
|
| 413 |
+
"""
|
| 414 |
+
goal = str(task.get("goal") or "")
|
| 415 |
+
wanted = {m for m in _PATH_RE.findall(goal)}
|
| 416 |
+
missing = []
|
| 417 |
+
for raw in sorted(wanted):
|
| 418 |
+
# 容器里绝对路径就是它自己;宿主上则落在 workdir 之内。两种都查,取存在的那个。
|
| 419 |
+
candidates = [Path(raw)]
|
| 420 |
+
try:
|
| 421 |
+
candidates.append(workdir / Path(raw).relative_to("/app"))
|
| 422 |
+
except ValueError:
|
| 423 |
+
pass
|
| 424 |
+
if not any(c.exists() for c in candidates):
|
| 425 |
+
missing.append(raw)
|
| 426 |
+
return missing
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
def _clip_text(out: str, limit: int) -> str:
|
| 430 |
+
if len(out) <= limit:
|
| 431 |
+
return out
|
| 432 |
+
marker = f"\n... [text clipped; original {len(out)} characters] ...\n"
|
| 433 |
+
room = max(0, limit - len(marker))
|
| 434 |
+
head = (room + 1) // 2
|
| 435 |
+
tail = room // 2
|
| 436 |
+
return (out[:head] + marker + (out[-tail:] if tail else ""))[:limit]
|
| 437 |
+
|
| 438 |
+
|
| 439 |
+
def _json_preview(value: list | dict, limit: int) -> str | None:
|
| 440 |
+
"""A bounded, valid JSON preview containing whole first/last entries."""
|
| 441 |
+
mapping = isinstance(value, dict)
|
| 442 |
+
items = list(value.items()) if mapping else value
|
| 443 |
+
head, tail = [], []
|
| 444 |
+
|
| 445 |
+
def render():
|
| 446 |
+
return json.dumps({"_harness_preview": {
|
| 447 |
+
"total_items": len(items), "omitted_items": len(items) - len(head) - len(tail)},
|
| 448 |
+
"head": dict(head) if mapping else head,
|
| 449 |
+
"tail": dict(tail) if mapping else tail}, ensure_ascii=False, separators=(",", ":"))
|
| 450 |
+
|
| 451 |
+
shown = render()
|
| 452 |
+
if len(shown) > limit:
|
| 453 |
+
return None
|
| 454 |
+
front, back = 0, len(items) - 1
|
| 455 |
+
while front <= back:
|
| 456 |
+
added = False
|
| 457 |
+
head.append(items[front])
|
| 458 |
+
candidate = render()
|
| 459 |
+
if len(candidate) <= limit:
|
| 460 |
+
shown = candidate
|
| 461 |
+
front += 1
|
| 462 |
+
added = True
|
| 463 |
+
else:
|
| 464 |
+
head.pop()
|
| 465 |
+
if front <= back:
|
| 466 |
+
tail.insert(0, items[back])
|
| 467 |
+
candidate = render()
|
| 468 |
+
if len(candidate) <= limit:
|
| 469 |
+
shown = candidate
|
| 470 |
+
back -= 1
|
| 471 |
+
added = True
|
| 472 |
+
else:
|
| 473 |
+
tail.pop(0)
|
| 474 |
+
if not added:
|
| 475 |
+
break
|
| 476 |
+
return shown
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
def _clip_output(out: str) -> str:
|
| 480 |
+
"""Compact leading JSON losslessly before bounding; retain whole list items.
|
| 481 |
+
|
| 482 |
+
Non-JSON suffixes (including shell errors) remain visible. The caller saves
|
| 483 |
+
the original separately whenever this view differs from the output.
|
| 484 |
+
"""
|
| 485 |
+
if len(out) <= OUTPUT_LIMIT:
|
| 486 |
+
return out
|
| 487 |
+
stripped = out.lstrip()
|
| 488 |
+
try:
|
| 489 |
+
obj, end = json.JSONDecoder().raw_decode(stripped)
|
| 490 |
+
except (ValueError, RecursionError):
|
| 491 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 492 |
+
if not isinstance(obj, (dict, list)):
|
| 493 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 494 |
+
suffix = stripped[end:]
|
| 495 |
+
compact = json.dumps(obj, ensure_ascii=False, separators=(",", ":")) + suffix
|
| 496 |
+
if len(compact) <= OUTPUT_LIMIT:
|
| 497 |
+
return compact
|
| 498 |
+
preview = _json_preview(obj, OUTPUT_LIMIT - len(suffix))
|
| 499 |
+
if preview is not None:
|
| 500 |
+
return preview + suffix
|
| 501 |
+
return _clip_text(compact, OUTPUT_LIMIT)
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
def _shell_runtime() -> tuple[str, str]:
|
| 505 |
+
"""Choose once before any task action; never retry side effects in another shell."""
|
| 506 |
+
bash = shutil.which("bash")
|
| 507 |
+
return (bash, "Bash") if bash else ("/bin/sh", "POSIX sh")
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
def _trim_history(messages: list[dict], budget: int | None = None) -> int:
|
| 511 |
+
"""丢最旧的成对消息,直到历史在 `budget`(默认 `CONTEXT_CHAR_BUDGET`)以内。返回丢掉的条数。
|
| 512 |
+
|
| 513 |
+
`messages[0]` 是 system,`messages[1]` 是题面,两者永不丢。之后严格成对
|
| 514 |
+
(assistant 动作、user 结果),所以一次删两条,而不是一条 —— 删一条会让"结果"成为
|
| 515 |
+
历史里的第一条,模型会读到一段没有对应动作的输出。
|
| 516 |
+
|
| 517 |
+
**为什么需要一个更小的 `budget` 参数。** 字符数不是 token 数,两者的比例随内容在
|
| 518 |
+
2:1 到 4:1 之间浮动:代码、git 对象、base64 每 token 只有一两个字符,英文散文有
|
| 519 |
+
四个。实测(2026-10-04,`local-screen-1`):60000 字符的历史在 `git-leak-recovery` 和
|
| 520 |
+
`regex-chess` 上被 vLLM 判为 "at least 32769 input tokens" —— 字符预算满足了,token
|
| 521 |
+
预算没有。所以唯一可靠的判据是**模型自己说的**那个错误:`_call_openai` 收到它就按
|
| 522 |
+
一半预算再削一次历史并重���,而不是让整道题死掉。
|
| 523 |
+
"""
|
| 524 |
+
limit = CONTEXT_CHAR_BUDGET if budget is None else budget
|
| 525 |
+
dropped = 0
|
| 526 |
+
while len(messages) > 4 and \
|
| 527 |
+
sum(len(m.get("content") or "") for m in messages) > limit:
|
| 528 |
+
del messages[2:4]
|
| 529 |
+
dropped += 2
|
| 530 |
+
return dropped
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
#: 模型拒绝一条 prompt 时的两种说法(vLLM/OpenAI 兼容端点各一种)。判据是模型自己的措辞,
|
| 534 |
+
#: 不是我们对 token 的估算 —— 估错了会削掉本该保留的历史,或者留下一个必然失败的长度。
|
| 535 |
+
_CONTEXT_ERROR_MARKERS = ("maximum context length", "context length is", "context_length_exceeded",
|
| 536 |
+
"reduce the length of the input prompt")
|
| 537 |
+
|
| 538 |
+
|
| 539 |
+
def run(task: dict, workdir: Path) -> str:
|
| 540 |
+
"""Execute one task. Returns the answer string.
|
| 541 |
+
|
| 542 |
+
The trace written to <workdir>/trace.jsonl is what the framework collects
|
| 543 |
+
and hands to the Trainer (INTERFACE.md §4.1).
|
| 544 |
+
"""
|
| 545 |
+
trace_path = workdir / "trace.jsonl"
|
| 546 |
+
shell, dialect = _shell_runtime()
|
| 547 |
+
messages = [
|
| 548 |
+
{"role": "system", "content": SYSTEM + (
|
| 549 |
+
f"\nShell runtime: {shell} -c ({dialect}). Each command starts a new shell.\n"
|
| 550 |
+
+ ("Bash arrays and PIPESTATUS are supported.\n" if dialect == "Bash" else
|
| 551 |
+
"Use POSIX syntax; Bash arrays, PIPESTATUS and [[ ]] are unavailable.\n"))},
|
| 552 |
+
{"role": "user", "content": json.dumps(task)},
|
| 553 |
+
]
|
| 554 |
+
|
| 555 |
+
answer = ""
|
| 556 |
+
submits = 0
|
| 557 |
+
parse_retries = 0
|
| 558 |
+
repeats = 0
|
| 559 |
+
last_cmd = ""
|
| 560 |
+
output_dir = None
|
| 561 |
+
# **行缓冲,不是默认的 8KB 块缓冲。** 实测(2026-10-04,本地模型跑 `bn-fit-modify`):
|
| 562 |
+
# harness 已经跑了 8 分钟、正在装 pandas,而 `/app/trace.jsonl` 是 0 字节、打开的 fd
|
| 563 |
+
# `pos: 0` —— 一行都还没落盘。代价有三条:
|
| 564 |
+
# * 实时的轨迹看不见,面板和调试都只能等它结束;
|
| 565 |
+
# * 被超时杀掉的题会丢掉缓冲区里的尾巴(≤8KB)。一般长跑无所谓(`adaptive-rejection-sampler`
|
| 566 |
+
# 那次写了 1MB,尾巴只占零头),但一道死在第一个命令里的题,尾巴就是**全部**;
|
| 567 |
+
# * `harness_failed` 的判据是"轨迹为空",于是"被杀"和"从没跑起来"在记录里同形。
|
| 568 |
+
# 行缓冲每写一行就落盘,这三条一起消失,代价是一次 write 系统调用。
|
| 569 |
+
with trace_path.open("w", buffering=1) as trace:
|
| 570 |
+
# **这份 harness 自己声明它的运行时预算。**
|
| 571 |
+
#
|
| 572 |
+
# 平台从外面只能看见 harness 目录的哈希。可哈希相同、行为不同的两份 harness 是
|
| 573 |
+
# 存在的:`HG_AGENT_MAX_STEPS=16` 和 `=32` 跑同一个文件,一条轨迹 16 步就停、
|
| 574 |
+
# 另一条能跑 32 步 —— 实测(2026-10-04,本地 9B 跑 `build-pmars`)32 步需要约
|
| 575 |
+
# 1100 秒,超过题目自带的 900 秒预算,于是它超时;16 步则跑得完。这两次测量的
|
| 576 |
+
# 曲线点上原来没有任何一个字段不同,读者无法分辨"同一外壳跑两次"和"两个预算
|
| 577 |
+
# 各跑一次"。
|
| 578 |
+
#
|
| 579 |
+
# 所以这里声明一次,由平台记到曲线点上(`harnessgrad/identity.py:harness_config`)。
|
| 580 |
+
# 同时声明 model/backend:这个 harness 读 `HG_AGENT_MODEL`,但只有它自己知道读到
|
| 581 |
+
# 了什么,平台的环境变量在别处会因改名而与实际不符(INTERFACE.md §3)。
|
| 582 |
+
identity = {"harness": "loop", "config": {
|
| 583 |
+
"max_steps": MAX_STEPS, "submit_retries": SUBMIT_RETRIES,
|
| 584 |
+
"parse_retries": PARSE_RETRIES, "finish_nudge_steps": FINISH_NUDGE_STEPS,
|
| 585 |
+
"repeat_nudge_limit": REPEAT_NUDGE_LIMIT, "output_limit": OUTPUT_LIMIT,
|
| 586 |
+
"context_chars": CONTEXT_CHAR_BUDGET,
|
| 587 |
+
"shell": shell, "shell_dialect": dialect,
|
| 588 |
+
"max_output_tokens": MAX_OUTPUT_TOKENS}}
|
| 589 |
+
for key, value in (("agent_model", os.environ.get("HG_AGENT_MODEL")),
|
| 590 |
+
("agent_backend", _backend())):
|
| 591 |
+
if value:
|
| 592 |
+
identity[key] = value
|
| 593 |
+
trace.write(json.dumps({"harness_identity": identity}) + "\n")
|
| 594 |
+
# **每一步的时间去哪了。** 实测(2026-10-04):本地 9B 跑 `build-pmars`,26 步撞上
|
| 595 |
+
# 题目自带的 900 秒预算被杀。可它是"模型慢"还是"命令慢",记录里看不出来 —— trace
|
| 596 |
+
# 只有步数,没有任何时间字段。这两件事的平台处置完全相反:模型慢要缩步数上限或
|
| 597 |
+
# 换模型,命令慢是这道题自己的成本(装依赖),换模型没用。
|
| 598 |
+
#
|
| 599 |
+
# 所以每步记两个毫秒数:等模型的时间、跑命令的时间。总和不等于墙钟时,差额就是
|
| 600 |
+
# harness 自己的开销,那也是要看得见的东西。
|
| 601 |
+
started = time.time()
|
| 602 |
+
model_s = command_s = 0.0
|
| 603 |
+
trims_before = USAGE["context_trims"]
|
| 604 |
+
for step in range(MAX_STEPS):
|
| 605 |
+
dropped = _trim_history(messages)
|
| 606 |
+
if dropped:
|
| 607 |
+
trace.write(json.dumps({"step": step, "history_dropped": dropped}) + "\n")
|
| 608 |
+
t0 = time.time()
|
| 609 |
+
reply = _complete(messages)
|
| 610 |
+
took = time.time() - t0
|
| 611 |
+
model_s += took
|
| 612 |
+
trace.write(json.dumps({"step": step, "reply": reply,
|
| 613 |
+
"model_ms": int(took * 1000)}) + "\n")
|
| 614 |
+
# 这一步的 prompt 被模型拒绝过,harness 因此削短了历史再问。模型这一步看到的
|
| 615 |
+
# 历史比上一步短 —— 不记下来的话,"它为什么换了做法"在 trace 里没有答案。
|
| 616 |
+
if USAGE["context_trims"] > trims_before:
|
| 617 |
+
trace.write(json.dumps({
|
| 618 |
+
"step": step, "context_trims": USAGE["context_trims"],
|
| 619 |
+
"history_kept": len(messages)}) + "\n")
|
| 620 |
+
trims_before = USAGE["context_trims"]
|
| 621 |
+
messages.append({"role": "assistant", "content": reply})
|
| 622 |
+
|
| 623 |
+
try:
|
| 624 |
+
action = _parse(reply)
|
| 625 |
+
except Exception as exc:
|
| 626 |
+
# 退回给模型,而不是结束整道题。trace 里记下第几次重试,因为平台看不到
|
| 627 |
+
# 容器内部:没有这条记录,一次"读不懂的回复"在记录里和一次"一步就交卷"
|
| 628 |
+
# 长得一样。次数用完仍然是 harness 失败(它确实读不出动作),但那时记录
|
| 629 |
+
# 里已经有 N 次尝试,而不是一次。
|
| 630 |
+
trace.write(json.dumps({"step": step, "parse_error": str(exc),
|
| 631 |
+
"parse_retry": parse_retries}) + "\n")
|
| 632 |
+
if parse_retries >= PARSE_RETRIES:
|
| 633 |
+
break
|
| 634 |
+
parse_retries += 1
|
| 635 |
+
# Keep the full failed reply in the trace, not as an example for
|
| 636 |
+
# the next completion to copy. In particular, token-cut commands
|
| 637 |
+
# should be shortened by the model, never completed by the parser.
|
| 638 |
+
messages[-1]["content"] = "[Unparseable reply omitted; see trace.jsonl.]"
|
| 639 |
+
messages.append({"role": "user", "content": (
|
| 640 |
+
f"Your reply could not be read as an action: {exc}\n"
|
| 641 |
+
"Nothing was executed. It may have been cut off by the output token limit.\n"
|
| 642 |
+
"Send one short command; use a loop/script instead of enumerating calls.\n"
|
| 643 |
+
f"You have {MAX_STEPS - step - 1} step(s) left.\n"
|
| 644 |
+
"Reply with EXACTLY ONE JSON object and nothing else, one of:\n"
|
| 645 |
+
' {"tool": "bash", "command": "<shell command>"}\n'
|
| 646 |
+
' {"answer": "<your final answer>"}\n'
|
| 647 |
+
'For structured predictions, put the complete JSON object in "answer"; '
|
| 648 |
+
'preserve the task\'s prediction schema.')})
|
| 649 |
+
continue
|
| 650 |
+
|
| 651 |
+
parse_retries = 0
|
| 652 |
+
# Prose or echoed data before a recovered action is not part of the
|
| 653 |
+
# executed command. Store only the parsed action in model history.
|
| 654 |
+
messages[-1]["content"] = json.dumps(action)
|
| 655 |
+
|
| 656 |
+
# **修过的地方要留痕。** 重复键的回复被解析成"第一个值放前面"之后,模型看到的
|
| 657 |
+
# 命令和它写的不完全一样(它写了两遍,harness 取了第一遍)。一次被静默改写的
|
| 658 |
+
# 动作和一次原样执行的动作不是同一件事,记录里必须分开。
|
| 659 |
+
repaired = getattr(action, "duplicates", ())
|
| 660 |
+
if repaired:
|
| 661 |
+
trace.write(json.dumps({"step": step,
|
| 662 |
+
"duplicate_keys": list(repaired)}) + "\n")
|
| 663 |
+
|
| 664 |
+
# **交卷闸门。** 顺序按"它想干什么"判断,而不是按哪个键先出现:
|
| 665 |
+
# 一条回复里同时带 command 和 answer 时,以前"先看 answer"会让那条命令
|
| 666 |
+
# 永远不执行(实测:`{"tool":"bash","command":"cat > /app/run.py …"}` 被当成
|
| 667 |
+
# 空答案,文件从未创建)。所以:有命令就先执行命令;只有**没有**命令时才算交卷。
|
| 668 |
+
cmd = action.get("command", "")
|
| 669 |
+
if not cmd and "answer" in action:
|
| 670 |
+
missing = _missing_deliverables(task, workdir)
|
| 671 |
+
if missing and submits < SUBMIT_RETRIES:
|
| 672 |
+
submits += 1
|
| 673 |
+
note = ("You answered but these paths the task asks for do not exist: "
|
| 674 |
+
+ ", ".join(missing)
|
| 675 |
+
+ ". Create them first, then answer again.")
|
| 676 |
+
trace.write(json.dumps({"step": step, "submit_rejected": missing}) + "\n")
|
| 677 |
+
messages.append({"role": "user", "content": note})
|
| 678 |
+
continue
|
| 679 |
+
trace.write(json.dumps({"step": step, "submitted": True,
|
| 680 |
+
"missing": missing}) + "\n")
|
| 681 |
+
answer = _answer_text(action["answer"])
|
| 682 |
+
break
|
| 683 |
+
t0 = time.time()
|
| 684 |
+
proc = subprocess.run(
|
| 685 |
+
# `errors="replace"`: a command may emit arbitrary bytes, and a strict decode
|
| 686 |
+
# raises UnicodeDecodeError inside the harness, which ends the episode and is
|
| 687 |
+
# recorded as a zero for a task nobody finished. Measured 2026-10-15.
|
| 688 |
+
[shell, "-c", cmd], cwd=workdir, capture_output=True, text=True,
|
| 689 |
+
errors="replace"
|
| 690 |
+
)
|
| 691 |
+
took = time.time() - t0
|
| 692 |
+
command_s += took
|
| 693 |
+
out = proc.stdout + proc.stderr
|
| 694 |
+
trace.write(json.dumps({"step": step, "command": cmd,
|
| 695 |
+
"exit": proc.returncode,
|
| 696 |
+
"shell": shell,
|
| 697 |
+
"command_ms": int(took * 1000), "output": out}) + "\n")
|
| 698 |
+
shown = _clip_output(out)
|
| 699 |
+
output_note = ""
|
| 700 |
+
if shown != out:
|
| 701 |
+
if output_dir is None:
|
| 702 |
+
import tempfile
|
| 703 |
+
output_dir = Path(tempfile.mkdtemp(prefix=".hg-output-", dir=workdir))
|
| 704 |
+
saved = output_dir / f"step-{step}.txt"
|
| 705 |
+
saved.write_text(out)
|
| 706 |
+
relative = saved.relative_to(workdir)
|
| 707 |
+
output_note = (f"\nFull output: {relative} (use shell tools to inspect/filter it).\n"
|
| 708 |
+
"The view below may omit records; omitted does not mean absent.\n")
|
| 709 |
+
trace.write(json.dumps({"step": step, "output_clipped": len(out),
|
| 710 |
+
"shown": len(shown), "output_file": str(relative),
|
| 711 |
+
"output_view": shown}) + "\n")
|
| 712 |
+
messages.append({"role": "user", "content":
|
| 713 |
+
f"exit={proc.returncode}{output_note}\n{shown}"})
|
| 714 |
+
|
| 715 |
+
# **两条提醒,都放在命令跑完之后**,因为它们改变的是"下一步做什么"。
|
| 716 |
+
#
|
| 717 |
+
# 先记进 trace 再发出去:平台看不到容器内部,没有这两条记录,"模型在原地打转"
|
| 718 |
+
# 在一次 32 步的运行里和"模型在认真工作"长得一模一样。
|
| 719 |
+
if cmd and cmd == last_cmd and repeats < REPEAT_NUDGE_LIMIT:
|
| 720 |
+
repeats += 1
|
| 721 |
+
trace.write(json.dumps({"step": step, "repeat_nudge": cmd[:120]}) + "\n")
|
| 722 |
+
messages[-1]["content"] += "\n" + (
|
| 723 |
+
"That is the same command as the previous step and its output has not "
|
| 724 |
+
"changed. Do something different, or finish now with "
|
| 725 |
+
'{"answer": "<your final answer>"} if the work is already done.')
|
| 726 |
+
last_cmd = cmd
|
| 727 |
+
|
| 728 |
+
left = MAX_STEPS - (step + 1)
|
| 729 |
+
# 只在进入收尾区和最后一步各说一次:每一步都重复同一句话不会更有用,
|
| 730 |
+
# 只会把最近几轮的命令输出挤远。
|
| 731 |
+
if left and (left == FINISH_NUDGE_STEPS or left == 1):
|
| 732 |
+
trace.write(json.dumps({"step": step, "finish_nudge": left}) + "\n")
|
| 733 |
+
messages[-1]["content"] += "\n" + (
|
| 734 |
+
f"You have {left} step(s) left. Stop exploring. Create every file the "
|
| 735 |
+
"task asks for now, then reply with exactly one JSON object: "
|
| 736 |
+
'{"answer": "<your final answer>"}')
|
| 737 |
+
|
| 738 |
+
# Where the wall clock went. Separate from `usage` (which counts tokens):
|
| 739 |
+
# a reader asking "was this killed for being slow, and slow at what" gets one
|
| 740 |
+
# line, and a harness that is slow on its own shows up as `total` exceeding
|
| 741 |
+
# model + commands.
|
| 742 |
+
trace.write(json.dumps({"wall_clock_s": {
|
| 743 |
+
"model": round(model_s, 1), "commands": round(command_s, 1),
|
| 744 |
+
"total": round(time.time() - started, 1)}}) + "\n")
|
| 745 |
+
|
| 746 |
+
# What the run cost. Kept because a harness that cannot say what it spent
|
| 747 |
+
# cannot be compared with a cheaper one at the same score -- and because
|
| 748 |
+
# `USAGE` is the only place the model calls are counted.
|
| 749 |
+
trace.write(json.dumps({"usage": dict(USAGE)}) + "\n")
|
| 750 |
+
|
| 751 |
+
(workdir / "answer.txt").write_text(answer)
|
| 752 |
+
return answer
|
| 753 |
+
|
| 754 |
+
|
| 755 |
+
def main() -> int:
|
| 756 |
+
ap = argparse.ArgumentParser()
|
| 757 |
+
ap.add_argument("--task", required=True)
|
| 758 |
+
ap.add_argument("--workdir", required=True)
|
| 759 |
+
args = ap.parse_args()
|
| 760 |
+
|
| 761 |
+
task = json.loads(Path(args.task).read_text())
|
| 762 |
+
run(task, Path(args.workdir))
|
| 763 |
+
return 0
|
| 764 |
+
|
| 765 |
+
|
| 766 |
+
if __name__ == "__main__":
|
| 767 |
+
sys.exit(main())
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-0/harness.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "loop",
|
| 3 |
+
"version": "0.2.0",
|
| 4 |
+
"path": ".",
|
| 5 |
+
"entrypoint": "agent.py",
|
| 6 |
+
"backend": "cli",
|
| 7 |
+
"install": "requirements.txt",
|
| 8 |
+
"env_kinds": [
|
| 9 |
+
"files",
|
| 10 |
+
"exec"
|
| 11 |
+
]
|
| 12 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-0/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
openai>=1.0
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-1/.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
_harnessgrad/
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.pyc
|
| 5 |
+
.state/
|
| 6 |
+
*.bak
|
| 7 |
+
*.orig
|
| 8 |
+
*.rej
|
| 9 |
+
*~
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-1/agent.py
ADDED
|
@@ -0,0 +1,1399 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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3
|
| 2 |
+
"""The reference base harness: a minimal ReAct loop.
|
| 3 |
+
|
| 4 |
+
Deliberately the simplest thing that satisfies the contract in
|
| 5 |
+
`docs/writing_a_harness.md`. Its job is not to be strong -- it is to be:
|
| 6 |
+
|
| 7 |
+
1. a valid starting point that a method can improve, and
|
| 8 |
+
2. the proof that the contract is implementable at all.
|
| 9 |
+
|
| 10 |
+
A method may replace every file here. That is the point.
|
| 11 |
+
|
| 12 |
+
**What it ships, and why that changed.** This harness used to be a bare loop: no
|
| 13 |
+
context policy, no output bounding, no retries. That is still the design -- but
|
| 14 |
+
these mechanisms are now in it, and each is here because a measurement said the
|
| 15 |
+
bare loop could not be measured at all, not because a mechanism is nice to have:
|
| 16 |
+
|
| 17 |
+
* `PARSE_RETRIES`, `SUBMIT_RETRIES`, `FINISH_NUDGE_STEPS`, `REPEAT_NUDGE_LIMIT`
|
| 18 |
+
-- one unreadable reply, or one premature "I am done", used to end the whole
|
| 19 |
+
task. Measured: 73 of 266 runs reached the step cap with nothing submitted,
|
| 20 |
+
and one task died after exactly one model call.
|
| 21 |
+
* `OUTPUT_LIMIT`, `CONTEXT_CHAR_BUDGET` -- a command that printed a large file
|
| 22 |
+
left the next call over the model's context limit, which killed the task.
|
| 23 |
+
* line-buffered trace writes -- a block buffer meant a killed task lost its tail,
|
| 24 |
+
so "killed at step 30" and "never started" were the same record.
|
| 25 |
+
|
| 26 |
+
All of them are still named switches with an `HG_AGENT_*` override, so a method
|
| 27 |
+
may change or remove any of them; what a method adds *on top* is the measurement.
|
| 28 |
+
The values actually in force go into the trace (`harness_identity.config`, below)
|
| 29 |
+
and land on the curve point, because two runs of this same file at two different
|
| 30 |
+
step caps are two different harnesses and the file hash cannot tell them apart.
|
| 31 |
+
"""
|
| 32 |
+
from __future__ import annotations
|
| 33 |
+
|
| 34 |
+
import argparse
|
| 35 |
+
import json
|
| 36 |
+
import os
|
| 37 |
+
import re
|
| 38 |
+
import shutil
|
| 39 |
+
import subprocess
|
| 40 |
+
import sys
|
| 41 |
+
import time
|
| 42 |
+
from pathlib import Path
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
#: How many model calls one task gets. **A floor on capability, not a tuning knob.**
|
| 46 |
+
#:
|
| 47 |
+
#: Measured at 8, on Terminal-Bench, 4 rounds x 5 tasks: four of the five tasks used all
|
| 48 |
+
#: eight and produced no graded artifact at all -- `build-pmars` was still installing
|
| 49 |
+
#: packages, `bn-fit-modify` had just finished installing pandas/numpy/sklearn and
|
| 50 |
+
#: printed one correlation matrix, `chess-best-move` had opened the PNG and never wrote
|
| 51 |
+
#: `/app/move.txt`. The score was 0.0 on every task in every round, which is not a weak
|
| 52 |
+
#: harness being measured: it is a floor effect, and a floor makes every method look
|
| 53 |
+
#: identical because there is no gradient for one to move.
|
| 54 |
+
#:
|
| 55 |
+
#: Raising this does not make the harness cleverer -- `legacy/adapters/harnessgrad_domain/`
|
| 56 |
+
#: already names this lever as the trap ("helps only if the model is already using the
|
| 57 |
+
#: steps it has"). Here the trace shows it *was* using them, which is exactly when the
|
| 58 |
+
#: lever is legitimate. What it costs is bounded by the task, not by this number: the
|
| 59 |
+
#: wall clock is capped by the environment's `agent_timeout_s` (900 s for most
|
| 60 |
+
#: Terminal-Bench tasks, 3600 s for `bn-fit-modify`). A step is fast (~0.2 s model round
|
| 61 |
+
#: trip through the local gateway), so the extra ceiling mostly buys back the steps that
|
| 62 |
+
#: environment setup eats. The loop still stops the moment the model answers -- the cap
|
| 63 |
+
#: is a ceiling, not a quota.
|
| 64 |
+
MAX_STEPS = int(os.environ.get("HG_AGENT_MAX_STEPS", "32"))
|
| 65 |
+
MAX_OUTPUT_TOKENS = int(os.environ.get("HG_AGENT_MAX_OUTPUT_TOKENS", "2048"))
|
| 66 |
+
if MAX_OUTPUT_TOKENS < 1:
|
| 67 |
+
raise ValueError("HG_AGENT_MAX_OUTPUT_TOKENS must be positive")
|
| 68 |
+
|
| 69 |
+
#: Extra shell steps granted on top of the environment's **own** action budget.
|
| 70 |
+
#:
|
| 71 |
+
#: The failure this repairs is not "32 is too few": it is that the harness had a
|
| 72 |
+
#: global cap while the environment declares its own budget in the goal text
|
| 73 |
+
#: (`**50** steps`). A run could therefore spend 32 shell steps, of which only
|
| 74 |
+
#: some are environment actions, and be killed by the harness while the
|
| 75 |
+
#: environment still had most of its budget left. The cap is derived per task
|
| 76 |
+
#: from that declared number; the slack pays for the free commands (`alf look`)
|
| 77 |
+
#: and for the harness's own push-backs. It is not a tuning knob.
|
| 78 |
+
STEP_SLACK = int(os.environ.get("HG_AGENT_STEP_SLACK", "16"))
|
| 79 |
+
|
| 80 |
+
#: 模型说"我做完了"之后,允许它再被退回几次。
|
| 81 |
+
#:
|
| 82 |
+
#: 为什么需要这个:harness 以前**从不检查交付物**。模型回一句 {"answer": ...} 就被当成
|
| 83 |
+
#: 任务结束、退出循环。实测(2026-10-02,terminal_bench round 0):五道题的 agent 阶段是
|
| 84 |
+
#: 101s / 31s / 183s / **4.5s** / 105s —— 而步数上限是 32。4.5 秒等于一次模型调用就
|
| 85 |
+
#: "交卷"了,产物根本不存在;`cancel-async-tasks` 的判分因此是
|
| 86 |
+
#: `File /app/run.py does not exist`。
|
| 87 |
+
#:
|
| 88 |
+
#: 所以 0 分的机制不是"步数不够",而是"**harness 把模型说的完成当成了完成**"。
|
| 89 |
+
#: 一个会自己检查交付物、并把"文件不存在"退回给模型重试的 harness,才是这一步该有的样子。
|
| 90 |
+
SUBMIT_RETRIES = int(os.environ.get("HG_AGENT_SUBMIT_RETRIES", "2"))
|
| 91 |
+
|
| 92 |
+
#: 模型吐出一段**读不出动作**的回复之后,允许它再试几次。
|
| 93 |
+
#:
|
| 94 |
+
#: 和上面那条同源,方向相反:一条是"模型说做完了,但产物不在",一条是"模型说的话读不出
|
| 95 |
+
#: 动作"。两条以前都会让**整道题**结束。
|
| 96 |
+
#:
|
| 97 |
+
#: 为什么它必须由起点 harness 负责,而不是留给方法去发现 —— 这是数出来的,不是想出来的。
|
| 98 |
+
#: 统计所有跑道里"方法自己写了理由"的 35 个轮次:**16 个在修解析或格式容错**,而且几乎
|
| 99 |
+
#: 每条跑道的第一轮都在修它:
|
| 100 |
+
#:
|
| 101 |
+
#: `loop-terminal_bench-26452c` 五道题各只调了一次模型就死在
|
| 102 |
+
#: `parse_error: Extra data`(`calls: 1`),此后每一轮都从同一个不能用的 harness 出发;
|
| 103 |
+
#: `flash-three-1/2`、`deepseek-eigen-2`、`strong-model-1` 的第一/第二轮全都写成
|
| 104 |
+
#: "让一次读不懂的回复不再结束整道题"。
|
| 105 |
+
#:
|
| 106 |
+
#: 代价不只是浪费一轮。方法之间开始比"谁先想到修 parser":RRSI 的 leakage critic 两次把
|
| 107 |
+
#: 改 `_parse` 的候选判成 TASK-SPECIALIZATION / LEAKAGE 而拒绝,那一轮于是什么都没改。
|
| 108 |
+
#: 一个起点 harness 必须在被测量之前就活过一次跑题的回复,否则第一轮比较的不是解题能力,
|
| 109 |
+
#: 是管线运气。
|
| 110 |
+
PARSE_RETRIES = int(os.environ.get("HG_AGENT_PARSE_RETRIES", "2"))
|
| 111 |
+
|
| 112 |
+
#: 步数还剩这么多时,明确要求模型收尾。
|
| 113 |
+
#:
|
| 114 |
+
#: 数出来的,不是猜的:266 条历史轨迹里 **73 条(27%)跑满 32 步、一次都没交卷**,而那些
|
| 115 |
+
#: 轨迹的最后两步常常是同一条命令重复(抽样:`python /app/test_outputs.py 2>&1` 两次、
|
| 116 |
+
#: 同一条 `echo ... >` 两次、同一个 `cat > /app/run.py << 'EOF'` 两次)。那些任务不是
|
| 117 |
+
#: "做错了",是**没停下来交卷**:步数用完,`answer` 是空字符串,平台只能拿检查的判决当分数。
|
| 118 |
+
#: `improvers/skill.md` 早就把这条记成已知失败模式("预算用满、什么都没交"),但起点 harness
|
| 119 |
+
#: 一直没有对应动作。一个被测量的 harness 应该在预算耗尽前把话说完。
|
| 120 |
+
FINISH_NUDGE_STEPS = int(os.environ.get("HG_AGENT_FINISH_NUDGE_STEPS", "4"))
|
| 121 |
+
|
| 122 |
+
#: 同一条命令连续重复时提醒几次(每条跑道限量,免得把上下文塞满)。
|
| 123 |
+
REPEAT_NUDGE_LIMIT = int(os.environ.get("HG_AGENT_REPEAT_NUDGE_LIMIT", "2"))
|
| 124 |
+
|
| 125 |
+
#: 单条命令的输出进入消息历史时的字符上限。先压紧 JSON,再保留完整记录预览;
|
| 126 |
+
#: 纯文本留头尾。完整输出留在工作目录,模型可按需读取。
|
| 127 |
+
#:
|
| 128 |
+
#: 实测(2026-10-04,本地 9B,5 道题):**3 道题死于
|
| 129 |
+
#: `This model's maximum context length is 32768 tokens ... your prompt contains at least
|
| 130 |
+
#: 32769 input tokens`(BadRequestError 400)**。起点 harness 以前把每条命令的**完整**输出
|
| 131 |
+
#: 一直往历史里追加,永不截断:一道题里单条输出就有 11773 字符,装一次包、cat 一个大文件
|
| 132 |
+
#: 就够撞上 32k 的窗口。那不是模型的问题,是 harness 没有上下文管理。
|
| 133 |
+
OUTPUT_LIMIT = int(os.environ.get("HG_AGENT_OUTPUT_LIMIT", "4000"))
|
| 134 |
+
|
| 135 |
+
#: 消息历史(不含 system 与题面)的字符预算。按 4 字符 ≈ 1 token 粗估,60k 字符约 15k token,
|
| 136 |
+
#: 给 32k 窗口的模型留出输出空间。超了就丢**最旧的成对消息**,并在轨迹里记下丢了几条 ——
|
| 137 |
+
#: 一个悄悄改变模型所见历史的 harness,和一个被测量的 harness,不是同一件事。
|
| 138 |
+
CONTEXT_CHAR_BUDGET = int(os.environ.get("HG_AGENT_CONTEXT_CHARS", "60000"))
|
| 139 |
+
|
| 140 |
+
SYSTEM = """You are an agent solving a task in a working directory.
|
| 141 |
+
|
| 142 |
+
You have one tool: run a shell command.
|
| 143 |
+
|
| 144 |
+
Reply with EXACTLY one of:
|
| 145 |
+
{"tool": "bash", "command": "<shell command>"}
|
| 146 |
+
{"answer": "<your final answer>"}
|
| 147 |
+
|
| 148 |
+
For a structured final answer, "answer" may be a JSON object containing the task's
|
| 149 |
+
prediction fields.
|
| 150 |
+
|
| 151 |
+
Rules:
|
| 152 |
+
- One action per reply. No prose outside the JSON.
|
| 153 |
+
- Keep commands concise. Use a loop or a script instead of enumerating many calls.
|
| 154 |
+
- To inspect files use shell commands (ls, cat, grep, ...).
|
| 155 |
+
- Give the final answer only when you are confident.
|
| 156 |
+
"""
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
# ---------------------------------------------------------------- backends ---
|
| 160 |
+
|
| 161 |
+
def _backend() -> str:
|
| 162 |
+
"""Which completion backend to use.
|
| 163 |
+
|
| 164 |
+
`mock` exists so the framework can be exercised end-to-end with zero network
|
| 165 |
+
and zero cost. Any real curve must declare its backend and model on the curve
|
| 166 |
+
point (INTERFACE.md §3, `identity.agent_model`).
|
| 167 |
+
"""
|
| 168 |
+
return os.environ.get("HG_AGENT_BACKEND", "mock")
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def _call_mock(messages: list[dict]) -> str:
|
| 172 |
+
"""Deterministic stand-in: read answer.txt if present, else list the dir."""
|
| 173 |
+
task_text = messages[1]["content"] if len(messages) > 1 else ""
|
| 174 |
+
if "answer.txt exists" in task_text or "already" in task_text:
|
| 175 |
+
return json.dumps({"answer": "READ_FROM_FILE"})
|
| 176 |
+
return json.dumps({"tool": "bash", "command": "ls -a"})
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
# --------------------------------------------------------------- usage ---
|
| 180 |
+
|
| 181 |
+
#: Token usage accumulated over the run, filled by whichever backend is active.
|
| 182 |
+
#: Read into the trace at the end. Recorded because a mechanism that spends model
|
| 183 |
+
#: calls (history_summary does) is only comparable against a free one if the
|
| 184 |
+
#: spend is visible -- and because a harness whose cost is unknown cannot be
|
| 185 |
+
#: ranked against a cheaper one that scores the same.
|
| 186 |
+
#: `context_trims` 单独计数:它是"模型拒绝了这条 prompt,于是我们削短了历史"的次数。
|
| 187 |
+
#: 和 `retries`(网络/限流)不同 —— 那一种重试发的是同一条 prompt,这一种发的是**更短的**
|
| 188 |
+
#: 一条,模型看到的历史因此和上一步不同。要能分开,才能解释"那一步为什么换了做法"。
|
| 189 |
+
USAGE = {"calls": 0, "input_tokens": 0, "output_tokens": 0, "retries": 0,
|
| 190 |
+
"context_trims": 0}
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def _record_usage(usage) -> None:
|
| 194 |
+
"""Fold provider token counts into the run's total.
|
| 195 |
+
|
| 196 |
+
The call count is NOT incremented here: it is incremented by `_complete`,
|
| 197 |
+
which is the one place every model call goes through. Counting calls at the
|
| 198 |
+
provider boundary would miss the mock backend entirely -- and a mechanism that
|
| 199 |
+
spends model calls on a mock run would then report zero cost, which is exactly
|
| 200 |
+
the invisible-spend the usage block exists to prevent.
|
| 201 |
+
"""
|
| 202 |
+
if usage is None:
|
| 203 |
+
return
|
| 204 |
+
# Provider fields that are absent stay absent rather than becoming zero: a
|
| 205 |
+
# zero that means "not reported" is indistinguishable from a real zero.
|
| 206 |
+
for attr, key in (("prompt_tokens", "input_tokens"),
|
| 207 |
+
("completion_tokens", "output_tokens")):
|
| 208 |
+
v = getattr(usage, attr, None)
|
| 209 |
+
if isinstance(v, int):
|
| 210 |
+
USAGE[key] += v
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def _call_openai(messages: list[dict]) -> str:
|
| 214 |
+
"""One completion, with a deadline and bounded retries.
|
| 215 |
+
|
| 216 |
+
A harness that dies on a transient provider error loses a whole task run, and
|
| 217 |
+
an unbounded retry loop turns a provider outage into a hung experiment. Both
|
| 218 |
+
failures are silent in a batch unless the harness is defensive here.
|
| 219 |
+
"""
|
| 220 |
+
from openai import OpenAI
|
| 221 |
+
|
| 222 |
+
# **每次请求用一条新连接,不复用。** 不是性能取舍,是正确性:
|
| 223 |
+
#
|
| 224 |
+
# 实测(2026-10-02,容器内复现):vLLM 的 uvicorn 默认 5 秒关掉空闲 keep-alive,而
|
| 225 |
+
# 容器到模型之间还有平台发布的一层字节转发网关,它在上游 EOF 时会把 EOF 半关到
|
| 226 |
+
# 客户端。于是"跑一条几十秒的命令、再发起下一次模型调用"就必然复用一条死连接 ——
|
| 227 |
+
# `RemoteDisconnected` → openai 报 `APIConnectionError: Connection error`。
|
| 228 |
+
# 实测那一次,两道题(跑 pandas 的、跑 PIL 的)就是这样死的,而平台把它们记成了 0 分。
|
| 229 |
+
#
|
| 230 |
+
# keep-alive 本身是 HTTP 客户端的正常行为,所以这是网关的缺陷(见 eval/modelgate.py);
|
| 231 |
+
# 但一个 harness 不该把自己的测量押在"中间那一层是否正确处理空闲连接"上。一次本地
|
| 232 |
+
# TCP 握手的代价可以忽略。
|
| 233 |
+
#
|
| 234 |
+
# **用 `default_headers`,不要 import httpx。** 第一版写的是
|
| 235 |
+
# `http_client=httpx.Client(...)`,结果是每次调用都 `ModuleNotFoundError: No module
|
| 236 |
+
# named 'httpx'` —— 这个平台的 harness 依赖由覆盖层提供,而这里 `openai` 3.22.1 依赖的
|
| 237 |
+
# 是 `httpx2`(不是 `httpx`)。所以"顺手 import 一个我以为在的库"在这条路上是错的:
|
| 238 |
+
# 唯一可以依赖的是 `requirements.txt` 声明的那个发行包自己的接口。
|
| 239 |
+
client = OpenAI(
|
| 240 |
+
base_url=os.environ["HG_AGENT_BASE_URL"],
|
| 241 |
+
api_key=os.environ["HG_AGENT_API_KEY"],
|
| 242 |
+
timeout=float(os.environ.get("HG_AGENT_TIMEOUT_S", "180")),
|
| 243 |
+
max_retries=0, # retried here, so the count is ours to record
|
| 244 |
+
default_headers={"Connection": "close"},
|
| 245 |
+
)
|
| 246 |
+
model = os.environ["HG_AGENT_MODEL"]
|
| 247 |
+
attempts = int(os.environ.get("HG_AGENT_RETRIES", "3"))
|
| 248 |
+
last: Exception | None = None
|
| 249 |
+
|
| 250 |
+
for attempt in range(attempts):
|
| 251 |
+
try:
|
| 252 |
+
resp = client.chat.completions.create(
|
| 253 |
+
model=model, messages=messages, temperature=0.0,
|
| 254 |
+
max_tokens=MAX_OUTPUT_TOKENS,
|
| 255 |
+
)
|
| 256 |
+
_record_usage(getattr(resp, "usage", None))
|
| 257 |
+
return resp.choices[0].message.content or ""
|
| 258 |
+
except Exception as exc: # noqa: BLE001
|
| 259 |
+
last = exc
|
| 260 |
+
# **历史太长是可恢复的,以前不是。** 实测(2026-10-04):`git-leak-recovery` 和
|
| 261 |
+
# `regex-chess` 死在 `maximum context length is 32768 tokens ... at least 32769
|
| 262 |
+
# input tokens`,而两道题之前都已经跑了十几步的有效功。字符预算挡不住它
|
| 263 |
+
# (见 `_trim_history`),所以这里按模型自己的拒绝削一半历史再试一次 —— 削掉的
|
| 264 |
+
# 步数记进 `USAGE["context_trims"]`,由主循环写进 trace,不是悄悄改历史。
|
| 265 |
+
if any(marker in str(exc) for marker in _CONTEXT_ERROR_MARKERS) \
|
| 266 |
+
and len(messages) > 4 and attempt + 1 < attempts:
|
| 267 |
+
dropped = _trim_history(messages, budget=(CONTEXT_CHAR_BUDGET // 2))
|
| 268 |
+
if not dropped:
|
| 269 |
+
dropped = _trim_history(messages, budget=1)
|
| 270 |
+
USAGE["context_trims"] += 1
|
| 271 |
+
USAGE["retries"] += 1
|
| 272 |
+
continue
|
| 273 |
+
if attempt + 1 < attempts:
|
| 274 |
+
USAGE["retries"] += 1
|
| 275 |
+
time.sleep(min(2 ** attempt, 30))
|
| 276 |
+
# Out of attempts: raise, so the caller records a harness failure rather than
|
| 277 |
+
# scoring an empty answer as a wrong one.
|
| 278 |
+
raise RuntimeError(f"{attempts} attempts failed, last: {last}") from last
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def _complete(messages: list[dict]) -> str:
|
| 282 |
+
"""Every model call in this harness goes through here, so this is where the
|
| 283 |
+
count is kept. Counting anywhere else means some caller is invisible."""
|
| 284 |
+
USAGE["calls"] += 1
|
| 285 |
+
return _call_mock(messages) if _backend() == "mock" else _call_openai(messages)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
# ------------------------------------------------------------- the loop -----
|
| 289 |
+
|
| 290 |
+
class _Action(dict):
|
| 291 |
+
"""A parsed action, plus what the parser had to repair to get it.
|
| 292 |
+
|
| 293 |
+
An attribute rather than a second return value, because every caller wants the
|
| 294 |
+
dict and only one wants the repair note. `duplicates` empty means the reply was
|
| 295 |
+
well formed and nothing was guessed.
|
| 296 |
+
"""
|
| 297 |
+
duplicates: tuple[str, ...] = ()
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
def _first_key_wins(pairs):
|
| 301 |
+
"""Duplicated JSON keys: keep the **first** value, and say which keys repeated.
|
| 302 |
+
|
| 303 |
+
**This is measured, not defensive.** The local 9B (Qwen3.5-9B) writes a file like
|
| 304 |
+
this, and it is the whole reason `cancel-async-tasks` scored 0.0 in
|
| 305 |
+
`local-floor-9`:
|
| 306 |
+
|
| 307 |
+
{"tool": "bash", "command": "cat > /app/run.py << 'EOF'\n...\nEOF\n", "command": ""}
|
| 308 |
+
|
| 309 |
+
The real command is there, and then the model appends `, "command": ""`. JSON says
|
| 310 |
+
a duplicate key keeps the **last** value, so `json.loads` (and `raw_decode`) handed
|
| 311 |
+
the harness an empty command. The harness then ran the empty string -- exit 0, no
|
| 312 |
+
output -- and told the model `exit=0`. The model read that as success, answered
|
| 313 |
+
"the file /app/run.py has been created", and the verifier found no file. All 16
|
| 314 |
+
steps of that trajectory are the model writing the file, being told it worked, and
|
| 315 |
+
checking. Not one step of it wrote anything.
|
| 316 |
+
|
| 317 |
+
Taking the first value is the repair that matches intent here: the long command is
|
| 318 |
+
what the model meant, and the trailing `""` is noise from the same malformation
|
| 319 |
+
that produces its stray braces. It is recorded (`duplicate_keys` in the trace)
|
| 320 |
+
because a harness that silently rewrites the model's action and one that does not
|
| 321 |
+
are different harnesses.
|
| 322 |
+
"""
|
| 323 |
+
action = _Action()
|
| 324 |
+
repeated: list[str] = []
|
| 325 |
+
for key, value in pairs:
|
| 326 |
+
if key in action:
|
| 327 |
+
repeated.append(key)
|
| 328 |
+
continue
|
| 329 |
+
action[key] = value
|
| 330 |
+
if repeated:
|
| 331 |
+
action.duplicates = tuple(repeated)
|
| 332 |
+
return action
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
def _json_block_end(text: str, start: int) -> int:
|
| 336 |
+
"""Skip a malformed JSON block without treating its strings as actions."""
|
| 337 |
+
depth = 0
|
| 338 |
+
quoted = escaped = False
|
| 339 |
+
for i in range(start, len(text)):
|
| 340 |
+
ch = text[i]
|
| 341 |
+
if quoted:
|
| 342 |
+
if escaped:
|
| 343 |
+
escaped = False
|
| 344 |
+
elif ch == "\\":
|
| 345 |
+
escaped = True
|
| 346 |
+
elif ch == '"':
|
| 347 |
+
quoted = False
|
| 348 |
+
elif ch == '"':
|
| 349 |
+
quoted = True
|
| 350 |
+
elif ch in "{[":
|
| 351 |
+
depth += 1
|
| 352 |
+
elif ch in "}]":
|
| 353 |
+
depth -= 1
|
| 354 |
+
if depth == 0:
|
| 355 |
+
return i + 1
|
| 356 |
+
return len(text)
|
| 357 |
+
|
| 358 |
+
|
| 359 |
+
def _parse(reply: str) -> dict:
|
| 360 |
+
"""First complete action, across prose/fences and preceding structured data.
|
| 361 |
+
|
| 362 |
+
Consume whole JSON blocks, so nested data and quoted example actions cannot
|
| 363 |
+
become commands. Never close a truncated command or execute its prefix.
|
| 364 |
+
"""
|
| 365 |
+
decoder = json.JSONDecoder(object_pairs_hook=_first_key_wins)
|
| 366 |
+
i = 0
|
| 367 |
+
while i < len(reply):
|
| 368 |
+
if reply[i] not in "{[":
|
| 369 |
+
i += 1
|
| 370 |
+
continue
|
| 371 |
+
try:
|
| 372 |
+
obj, end = decoder.raw_decode(reply, i)
|
| 373 |
+
except json.JSONDecodeError:
|
| 374 |
+
i = _json_block_end(reply, i)
|
| 375 |
+
continue
|
| 376 |
+
i = end
|
| 377 |
+
if not isinstance(obj, dict) or obj.get("tool", "bash") != "bash":
|
| 378 |
+
continue
|
| 379 |
+
cmd = obj.get("command", "")
|
| 380 |
+
if isinstance(cmd, str) and cmd.strip():
|
| 381 |
+
return obj
|
| 382 |
+
if cmd == "" and "answer" in obj:
|
| 383 |
+
# An outer action can be valid JSON while its answer contains broken
|
| 384 |
+
# inner JSON. Reject it here so the ordinary parse retry can recover.
|
| 385 |
+
_answer_text(obj["answer"])
|
| 386 |
+
return obj
|
| 387 |
+
raise ValueError("no complete JSON action found in reply")
|
| 388 |
+
|
| 389 |
+
|
| 390 |
+
def _answer_text(value: object) -> str:
|
| 391 |
+
"""Transport a final answer without inventing or dropping prediction fields.
|
| 392 |
+
|
| 393 |
+
Schema validation belongs to the task's verifier. This only checks transport:
|
| 394 |
+
objects must stay JSON (str(dict) produces Python syntax), and JSON-looking
|
| 395 |
+
strings must be complete. Never close truncated JSON or reinterpret literals.
|
| 396 |
+
|
| 397 |
+
Scalars are transported as JSON too. Measured on this benchmark: after the
|
| 398 |
+
environment had already solved a task, the model answered `{"answer": true}`;
|
| 399 |
+
rejecting the boolean as "not a string or dict" burned both parse retries and
|
| 400 |
+
ended the run in a parse error. No verifier reads the answer here -- the
|
| 401 |
+
actions do -- so refusing a perfectly well-formed scalar is a harness bug.
|
| 402 |
+
"""
|
| 403 |
+
if isinstance(value, (str,)):
|
| 404 |
+
if value.lstrip().startswith("{"):
|
| 405 |
+
try:
|
| 406 |
+
json.loads(value)
|
| 407 |
+
except ValueError as exc:
|
| 408 |
+
raise ValueError(f"final answer contains malformed JSON: {exc}") from exc
|
| 409 |
+
return value
|
| 410 |
+
if isinstance(value, (dict, list, bool, int, float)) or value is None:
|
| 411 |
+
return json.dumps(value, ensure_ascii=False, allow_nan=False)
|
| 412 |
+
raise ValueError("final answer must be JSON-transportable")
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
#: goal 里形如 `/app/move.txt`、`/app/learned_dag.csv` 的路径。这是**通用**的:
|
| 416 |
+
#: 它不针对任何一道题,只看题面自己说了要写到哪个文件。
|
| 417 |
+
_PATH_RE = __import__("re").compile(r"/[A-Za-z0-9_./-]+\.[A-Za-z0-9]{1,6}\b")
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
def _missing_deliverables(task: dict, workdir: Path) -> list[str]:
|
| 421 |
+
"""题面点名要写、但现在**不存在**的文件。
|
| 422 |
+
|
| 423 |
+
这是 `loop` 自带的交卷闸门,刻意做成通用的两条:
|
| 424 |
+
|
| 425 |
+
* 只看题面(goal)里写出来的绝对路径 —— harness 没有任何途径知道判分脚本要什么
|
| 426 |
+
(`task.json` 里只有 goal),所以它只能相信题面;
|
| 427 |
+
* 只做 `exists` 检查,不执行任何东西。
|
| 428 |
+
|
| 429 |
+
题面没提路径(比如"回答一个问题")时返回空列表,闸门不生效 —— 这时判断对错是平台
|
| 430 |
+
的事,harness 不该假装知道。
|
| 431 |
+
"""
|
| 432 |
+
goal = str(task.get("goal") or "")
|
| 433 |
+
wanted = {m for m in _PATH_RE.findall(goal)}
|
| 434 |
+
missing = []
|
| 435 |
+
for raw in sorted(wanted):
|
| 436 |
+
# 容器里绝对路径就是它自己;宿主上则落在 workdir 之内。两种都查,取存在的那个。
|
| 437 |
+
candidates = [Path(raw)]
|
| 438 |
+
try:
|
| 439 |
+
candidates.append(workdir / Path(raw).relative_to("/app"))
|
| 440 |
+
except ValueError:
|
| 441 |
+
pass
|
| 442 |
+
if not any(c.exists() for c in candidates):
|
| 443 |
+
missing.append(raw)
|
| 444 |
+
return missing
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
# ------------------------------------------------- the environment's state ---
|
| 448 |
+
#
|
| 449 |
+
# The tasks in this benchmark are not file-editing tasks: they are a text
|
| 450 |
+
# environment (`python3 alf ...`) whose *own* output already carries the whole
|
| 451 |
+
# ground truth -- the step counter, whether the goal is solved, what is in every
|
| 452 |
+
# container, what the agent holds, and what has been cleaned/cooled/heated/placed.
|
| 453 |
+
# The harness used to append that output raw and throw the structure away. A 9B
|
| 454 |
+
# model then had to reconstruct "I have the bowl, I cleaned it, but I still have
|
| 455 |
+
# not put it in the fridge" from forty blocks of prose, and measured on 100 ALF
|
| 456 |
+
# tasks it did not: 47 runs were unsolved, and the failure was not ignorance --
|
| 457 |
+
# the target object had already been seen in 23 of them, and 30 of them declared
|
| 458 |
+
# `alf done` while the environment still printed `in progress`.
|
| 459 |
+
#
|
| 460 |
+
# So the loop now reads the environment's own report and gives it back compactly:
|
| 461 |
+
# the goal, the env step, what is held/processed/placed, and the one action that
|
| 462 |
+
# is next. That is context policy (skill item 3), not a new prompt constant.
|
| 463 |
+
|
| 464 |
+
_ALF_STEP_RE = re.compile(r"\[alf\] step (\d+)/(\d+); (SOLVED|in progress)")
|
| 465 |
+
_ALF_OBJ_RE = re.compile(r"\b(?:a|an) ([a-z]+) (\d+)\b")
|
| 466 |
+
_ALF_DONE_RE = re.compile(r"\balf\s+done\b")
|
| 467 |
+
_ALF_DO_RE = re.compile(r"\balf\s+do\b")
|
| 468 |
+
_ALF_CONTAINERS = frozenset({"cabinet", "drawer", "fridge", "microwave", "safe", "cart"})
|
| 469 |
+
_ALF_APPLIANCE = {"clean": "sinkbasin", "cool": "fridge",
|
| 470 |
+
"heat": "microwave", "light": "desklamp"}
|
| 471 |
+
|
| 472 |
+
|
| 473 |
+
def _obj_base(obj: str) -> str:
|
| 474 |
+
return obj.split()[0].lower()
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
def _alf_mission(task: dict) -> dict | None:
|
| 478 |
+
"""Read target / destination / required state / budget from the goal prose.
|
| 479 |
+
|
| 480 |
+
ALFWorld goals have a fixed shape (`put a cool bowl in diningtable`,
|
| 481 |
+
`examine the book with the desklamp`). The words are the platform's own task
|
| 482 |
+
text, not a hard-coded object list; deriving them lets the harness repeat the
|
| 483 |
+
goal back to a small model instead of hoping it re-reads the system prompt.
|
| 484 |
+
Returns None for non-environment tasks, which leaves the generic loop alone.
|
| 485 |
+
"""
|
| 486 |
+
goal = str(task.get("goal") or "")
|
| 487 |
+
blob = goal + " " + str(task.get("initial_state") or "")
|
| 488 |
+
if "alf" not in blob.lower():
|
| 489 |
+
return None
|
| 490 |
+
m = re.search(r"Your task is to:\s*(.+?)(?:\n|\*\*|$)", goal, re.S)
|
| 491 |
+
if not m:
|
| 492 |
+
return None
|
| 493 |
+
raw = m.group(1).strip().strip("*").strip().rstrip(".").strip()
|
| 494 |
+
if not raw:
|
| 495 |
+
return None
|
| 496 |
+
low = raw.lower()
|
| 497 |
+
|
| 498 |
+
target = None
|
| 499 |
+
mt = re.search(r"\b(?:put|find)\s+(?:a|an|some|two|the)\s+"
|
| 500 |
+
r"(?:(?:clean|cool|hot|cold|warm)\s+)?([a-z]+)", low)
|
| 501 |
+
if not mt:
|
| 502 |
+
mt = re.search(r"\b(?:clean|cool|heat)\s+(?:a|an|some|two|the)\s+([a-z]+)", low)
|
| 503 |
+
if not mt:
|
| 504 |
+
mt = re.search(r"\b(?:examine|look at)\s+(?:the\s+)?([a-z]+)", low)
|
| 505 |
+
if mt:
|
| 506 |
+
target = mt.group(1)
|
| 507 |
+
if not target:
|
| 508 |
+
return None
|
| 509 |
+
|
| 510 |
+
kind = None
|
| 511 |
+
if "desklamp" in low:
|
| 512 |
+
kind, dest = "light", "desklamp"
|
| 513 |
+
else:
|
| 514 |
+
if re.search(r"\bclean\b", low):
|
| 515 |
+
kind = "clean"
|
| 516 |
+
elif re.search(r"\bcool\b|\bcold\b", low):
|
| 517 |
+
kind = "cool"
|
| 518 |
+
elif re.search(r"\bheat\b|\bhot\b", low):
|
| 519 |
+
kind = "heat"
|
| 520 |
+
md = re.search(r"\b(?:in|on|to)\s+(?:the\s+)?([a-z]+)\s*$", low)
|
| 521 |
+
dest = md.group(1) if md else None
|
| 522 |
+
if not dest:
|
| 523 |
+
return None
|
| 524 |
+
|
| 525 |
+
budget = None
|
| 526 |
+
for pat in (r"\*\*(\d+)\*\*\s+steps", r"(\d+)[- ]step budget",
|
| 527 |
+
r"budget of (\d+)", r"within the (\d+)"):
|
| 528 |
+
mb = re.search(pat, goal, re.I)
|
| 529 |
+
if mb:
|
| 530 |
+
budget = int(mb.group(1))
|
| 531 |
+
break
|
| 532 |
+
# The verifier's own `--budget` is authoritative: it is what the replay
|
| 533 |
+
# enforces, so the harness cap must be derived from it rather than guessed
|
| 534 |
+
# from prose when both are present.
|
| 535 |
+
try:
|
| 536 |
+
argv = (task.get("verifier") or {}).get("argv") or []
|
| 537 |
+
for i, arg in enumerate(argv):
|
| 538 |
+
if arg == "--budget" and i + 1 < len(argv):
|
| 539 |
+
budget = int(argv[i + 1])
|
| 540 |
+
break
|
| 541 |
+
except (TypeError, ValueError):
|
| 542 |
+
pass
|
| 543 |
+
if budget is None or budget < 1:
|
| 544 |
+
budget = 50
|
| 545 |
+
|
| 546 |
+
count = 2 if re.search(r"\btwo\b", low) else 1
|
| 547 |
+
return {"raw": raw, "target": target, "dest": dest, "kind": kind,
|
| 548 |
+
"count": count, "budget": budget}
|
| 549 |
+
|
| 550 |
+
|
| 551 |
+
class _AlfState:
|
| 552 |
+
"""Fold the environment's text into progress and the next required action."""
|
| 553 |
+
|
| 554 |
+
def __init__(self, mission: dict | None):
|
| 555 |
+
self.mission = mission
|
| 556 |
+
self.loc: str | None = None
|
| 557 |
+
self.objects: dict[str, str] = {} # object -> fixture it was last seen in
|
| 558 |
+
self.saw: dict[str, str] = {} # object -> fixture (never forgotten)
|
| 559 |
+
self.fixtures: dict[str, set[str]] = {}
|
| 560 |
+
self.held: set[str] = set()
|
| 561 |
+
self.transformed: dict[str, set[str]] = {}
|
| 562 |
+
self.moved_to: dict[str, str] = {}
|
| 563 |
+
self.placed: set[str] = set()
|
| 564 |
+
self.open: set[str] = set()
|
| 565 |
+
self.searched: set[str] = set()
|
| 566 |
+
self.visited: set[str] = set()
|
| 567 |
+
self.lamp_on = False
|
| 568 |
+
self.step = 0
|
| 569 |
+
self.budget = mission["budget"] if mission else 0
|
| 570 |
+
self.solved = False
|
| 571 |
+
self.invalid = False
|
| 572 |
+
self.last_cmd = ""
|
| 573 |
+
self.admissible: set[str] = set()
|
| 574 |
+
|
| 575 |
+
def observe(self, out: str, cmd: str = "") -> None:
|
| 576 |
+
self.last_cmd = cmd
|
| 577 |
+
self.invalid = "Nothing happens." in out if out else False
|
| 578 |
+
if not out:
|
| 579 |
+
return
|
| 580 |
+
if "SOLVED" in out:
|
| 581 |
+
self.solved = True
|
| 582 |
+
for m in _ALF_STEP_RE.finditer(out):
|
| 583 |
+
self.step = int(m.group(1))
|
| 584 |
+
self.budget = int(m.group(2))
|
| 585 |
+
if m.group(3) == "SOLVED":
|
| 586 |
+
self.solved = True
|
| 587 |
+
legal = re.search(r"Admissible actions:\s*\n(.*?)(?:\n\[alf\]|\Z)", out, re.S)
|
| 588 |
+
if legal:
|
| 589 |
+
self.admissible = {line.strip() for line in legal.group(1).splitlines()
|
| 590 |
+
if line.strip()}
|
| 591 |
+
for m in re.finditer(r"You (?:arrive at|are facing the|are at) ([a-z]+ \d+)", out):
|
| 592 |
+
self.loc = m.group(1)
|
| 593 |
+
self.visited.add(self.loc)
|
| 594 |
+
for m in re.finditer(r"The ([a-z]+ \d+) is (open|closed)", out):
|
| 595 |
+
if m.group(2) == "open":
|
| 596 |
+
self.open.add(m.group(1))
|
| 597 |
+
else:
|
| 598 |
+
self.open.discard(m.group(1))
|
| 599 |
+
for m in re.finditer(r"You open the ([a-z]+ \d+)", out):
|
| 600 |
+
self.open.add(m.group(1))
|
| 601 |
+
room = re.search(r"Looking quickly around you, you see (.*?)\.", out, re.S)
|
| 602 |
+
if room:
|
| 603 |
+
for m in re.finditer(r"\b([a-z]+) (\d+)\b", room.group(1)):
|
| 604 |
+
self.fixtures.setdefault(m.group(1), set()).add(f"{m.group(1)} {m.group(2)}")
|
| 605 |
+
for m in re.finditer(r"(?:On|In) the ([a-z]+ \d+), you see ([^.]*)\.", out):
|
| 606 |
+
self._add_objects(m.group(1), m.group(2))
|
| 607 |
+
if self.loc:
|
| 608 |
+
for m in re.finditer(r"In it, you see ([^.]*)\.", out):
|
| 609 |
+
self._add_objects(self.loc, m.group(1))
|
| 610 |
+
for m in re.finditer(r"You pick up the ([a-z]+ \d+) from the ([a-z]+ \d+)", out):
|
| 611 |
+
obj, loc = m.group(1), m.group(2)
|
| 612 |
+
self.held.add(obj)
|
| 613 |
+
self.objects.pop(obj, None)
|
| 614 |
+
self.saw[obj] = loc
|
| 615 |
+
self.searched.add(loc)
|
| 616 |
+
for m in re.finditer(r"You move the ([a-z]+ \d+) to the ([a-z]+ \d+)", out):
|
| 617 |
+
obj, loc = m.group(1), m.group(2)
|
| 618 |
+
self.held.discard(obj)
|
| 619 |
+
self.moved_to[obj] = loc
|
| 620 |
+
self.objects[obj] = loc
|
| 621 |
+
self.saw[obj] = loc
|
| 622 |
+
if self._is_dest(loc):
|
| 623 |
+
self.placed.add(obj)
|
| 624 |
+
for m in re.finditer(r"You (clean|cool|heat) the ([a-z]+ \d+) "
|
| 625 |
+
r"using the ([a-z]+ \d+)", out):
|
| 626 |
+
self.transformed.setdefault(m.group(2), set()).add(m.group(1))
|
| 627 |
+
for m in re.finditer(r"You turn on the ([a-z]+ \d+)", out):
|
| 628 |
+
if _obj_base(m.group(1)) == "desklamp":
|
| 629 |
+
self.lamp_on = True
|
| 630 |
+
if "You are not carrying anything." in out:
|
| 631 |
+
self.held.clear()
|
| 632 |
+
|
| 633 |
+
def _add_objects(self, loc: str, text: str) -> None:
|
| 634 |
+
# Seeing the contents means the fixture is open/accessible; that is how
|
| 635 |
+
# ALFWorld reports a drawer/cabinet that was never explicitly opened.
|
| 636 |
+
self.open.add(loc)
|
| 637 |
+
self.searched.add(loc)
|
| 638 |
+
for m in _ALF_OBJ_RE.finditer(text):
|
| 639 |
+
obj = f"{m.group(1)} {m.group(2)}"
|
| 640 |
+
self.objects[obj] = loc
|
| 641 |
+
self.saw[obj] = loc
|
| 642 |
+
|
| 643 |
+
def _is_dest(self, loc: str) -> bool:
|
| 644 |
+
return bool(loc and self.mission and _obj_base(loc) == self.mission["dest"])
|
| 645 |
+
|
| 646 |
+
def _completed(self) -> set[str]:
|
| 647 |
+
"""Targets actually done: placed at the destination *and* processed.
|
| 648 |
+
|
| 649 |
+
Measured: several failing runs moved an unprocessed object to the goal
|
| 650 |
+
location (an egg to the countertop without cooling it, a soapbar to the
|
| 651 |
+
cart without cleaning it). Counting a raw `move` as completion made the
|
| 652 |
+
progress helper stop guiding exactly one action early.
|
| 653 |
+
"""
|
| 654 |
+
kind = self.mission["kind"] if self.mission else None
|
| 655 |
+
return {o for o in self.placed
|
| 656 |
+
if not kind or kind in self.transformed.get(o, ())}
|
| 657 |
+
|
| 658 |
+
def _fixture(self, kind: str) -> str | None:
|
| 659 |
+
want = _ALF_APPLIANCE[kind]
|
| 660 |
+
if self.loc and _obj_base(self.loc) == want:
|
| 661 |
+
return self.loc
|
| 662 |
+
seen = set(self.fixtures.get(want) or ())
|
| 663 |
+
if not seen:
|
| 664 |
+
seen = {o for o in self.saw if _obj_base(o) == want}
|
| 665 |
+
if not seen:
|
| 666 |
+
return f"{want} 1"
|
| 667 |
+
return sorted(seen, key=lambda s: (s.split()[0], int(s.split()[1])))[0]
|
| 668 |
+
|
| 669 |
+
def _dest(self) -> str | None:
|
| 670 |
+
want = self.mission["dest"]
|
| 671 |
+
if self.loc and _obj_base(self.loc) == want:
|
| 672 |
+
return self.loc
|
| 673 |
+
seen = set(self.fixtures.get(want) or ())
|
| 674 |
+
if not seen:
|
| 675 |
+
seen = {o for o in self.saw if _obj_base(o) == want}
|
| 676 |
+
if seen:
|
| 677 |
+
return sorted(seen, key=lambda s: (s.split()[0], int(s.split()[1])))[0]
|
| 678 |
+
return f"{want} 1"
|
| 679 |
+
|
| 680 |
+
def _lamp(self) -> tuple[str | None, str | None]:
|
| 681 |
+
"""The desklamp is an object on a surface, not a navigable location."""
|
| 682 |
+
lamps = sorted(o for o in self.saw if _obj_base(o) == "desklamp")
|
| 683 |
+
for lamp in lamps:
|
| 684 |
+
if self.saw.get(lamp) == self.loc:
|
| 685 |
+
return lamp, self.loc
|
| 686 |
+
if lamps:
|
| 687 |
+
lamp = lamps[0]
|
| 688 |
+
return lamp, self.saw.get(lamp)
|
| 689 |
+
return None, None
|
| 690 |
+
|
| 691 |
+
def _legal(self, step: str) -> bool:
|
| 692 |
+
"""The environment prints the legal actions; never suggest one outside them.
|
| 693 |
+
|
| 694 |
+
The trace replays what actually ran, so an illegal suggestion costs a real
|
| 695 |
+
environment step ("Nothing happens.") for nothing. Measured over all 100
|
| 696 |
+
incumbent traces, the planner's raw suggestion was outside the printed
|
| 697 |
+
admissible list 105 times; most were `go to X` for a fixture that was
|
| 698 |
+
already accessible, or `open X` for a drawer that was already open.
|
| 699 |
+
"""
|
| 700 |
+
return not self.admissible or step in self.admissible
|
| 701 |
+
|
| 702 |
+
def _takeable_target(self) -> str | None:
|
| 703 |
+
base = self.mission["target"]
|
| 704 |
+
done = self._completed()
|
| 705 |
+
# The environment may expose a target in an already-open container
|
| 706 |
+
# without a separate `go to`; trust its own take action over our map.
|
| 707 |
+
for act in sorted(self.admissible):
|
| 708 |
+
parts = act.split()
|
| 709 |
+
if len(parts) >= 3 and parts[0] == "take" and parts[1] == base \
|
| 710 |
+
and f"{parts[1]} {parts[2]}" not in done:
|
| 711 |
+
return act
|
| 712 |
+
here = sorted(o for o, loc in self.objects.items()
|
| 713 |
+
if _obj_base(o) == base and loc == self.loc and o not in done)
|
| 714 |
+
if here:
|
| 715 |
+
step = f"take {here[0]} from {self.loc}"
|
| 716 |
+
if not self._fail(step) and self._legal(step):
|
| 717 |
+
return step
|
| 718 |
+
seen = sorted(((o, loc) for o, loc in self.saw.items()
|
| 719 |
+
if _obj_base(o) == base and o not in done
|
| 720 |
+
and o not in self.held), key=lambda x: x[1])
|
| 721 |
+
if seen:
|
| 722 |
+
obj, loc = seen[0]
|
| 723 |
+
if loc == self.loc:
|
| 724 |
+
step = f"take {obj} from {loc}"
|
| 725 |
+
return step if not self._fail(step) and self._legal(step) else None
|
| 726 |
+
step = f"go to {loc}"
|
| 727 |
+
return step if not self._fail(step) and self._legal(step) else None
|
| 728 |
+
return None
|
| 729 |
+
|
| 730 |
+
def _fail(self, step: str) -> bool:
|
| 731 |
+
"""True when this exact step just produced 'Nothing happens.'"""
|
| 732 |
+
return bool(self.invalid and step in self.last_cmd)
|
| 733 |
+
|
| 734 |
+
def _search_step(self) -> str | None:
|
| 735 |
+
"""A systematic next move when the target has not been seen yet."""
|
| 736 |
+
if self.loc and _obj_base(self.loc) in _ALF_CONTAINERS and self.loc not in self.open:
|
| 737 |
+
step = f"open {self.loc}"
|
| 738 |
+
if not self._fail(step) and self._legal(step):
|
| 739 |
+
return step
|
| 740 |
+
unseen = [inst for typ, insts in self.fixtures.items() if typ != "desklamp"
|
| 741 |
+
for inst in insts if inst not in self.visited]
|
| 742 |
+
unseen.sort(key=lambda s: (s.split()[0], int(s.split()[1])))
|
| 743 |
+
for inst in unseen:
|
| 744 |
+
step = f"go to {inst}"
|
| 745 |
+
if not self._fail(step) and self._legal(step):
|
| 746 |
+
return step
|
| 747 |
+
closed = [inst for typ in _ALF_CONTAINERS
|
| 748 |
+
for inst in (self.fixtures.get(typ) or ()) if inst not in self.open]
|
| 749 |
+
closed.sort(key=lambda s: (s.split()[0], int(s.split()[1])))
|
| 750 |
+
for inst in closed:
|
| 751 |
+
step = f"go to {inst}" if self.loc != inst else f"open {inst}"
|
| 752 |
+
if not self._fail(step) and self._legal(step):
|
| 753 |
+
return step
|
| 754 |
+
return None
|
| 755 |
+
|
| 756 |
+
def next_action(self) -> str | None:
|
| 757 |
+
if not self.mission or self.solved:
|
| 758 |
+
return None
|
| 759 |
+
m = self.mission
|
| 760 |
+
base = m["target"]
|
| 761 |
+
held = sorted(o for o in self.held if _obj_base(o) == base)
|
| 762 |
+
placed = sorted(o for o in self._completed() if _obj_base(o) == base)
|
| 763 |
+
|
| 764 |
+
if m["kind"] == "light":
|
| 765 |
+
lamp, lamp_loc = self._lamp()
|
| 766 |
+
if not self.lamp_on:
|
| 767 |
+
if lamp and lamp_loc == self.loc:
|
| 768 |
+
step = f"use {lamp}"
|
| 769 |
+
if not self._fail(step):
|
| 770 |
+
return step
|
| 771 |
+
# Acquire the target before a long trip to a lamp, unless the
|
| 772 |
+
# lamp is already in this room.
|
| 773 |
+
if not held:
|
| 774 |
+
step = self._takeable_target()
|
| 775 |
+
if step:
|
| 776 |
+
return step
|
| 777 |
+
if lamp_loc:
|
| 778 |
+
step = f"go to {lamp_loc}"
|
| 779 |
+
if not self._fail(step):
|
| 780 |
+
return step
|
| 781 |
+
return self._search_step()
|
| 782 |
+
if not held:
|
| 783 |
+
return self._takeable_target() or self._search_step()
|
| 784 |
+
# A held target with a lamp already on should satisfy the check; if
|
| 785 |
+
# it has not fired, examine the held object while at the lamp, which
|
| 786 |
+
# is the other admissible action for "look at X in the light".
|
| 787 |
+
if lamp and lamp_loc == self.loc:
|
| 788 |
+
return f"examine {held[0]}"
|
| 789 |
+
if lamp_loc:
|
| 790 |
+
step = f"go to {lamp_loc}"
|
| 791 |
+
if not self._fail(step):
|
| 792 |
+
return step
|
| 793 |
+
return None
|
| 794 |
+
|
| 795 |
+
if len(placed) < m["count"]:
|
| 796 |
+
if held:
|
| 797 |
+
obj = held[0]
|
| 798 |
+
if m["kind"] and m["kind"] not in self.transformed.get(obj, ()):
|
| 799 |
+
app = self._fixture(m["kind"])
|
| 800 |
+
if app and self.loc != app:
|
| 801 |
+
step = f"go to {app}"
|
| 802 |
+
if not self._fail(step):
|
| 803 |
+
return step
|
| 804 |
+
if app and app not in self.open and _obj_base(app) in _ALF_CONTAINERS:
|
| 805 |
+
step = f"open {app}"
|
| 806 |
+
if not self._fail(step):
|
| 807 |
+
return step
|
| 808 |
+
if app:
|
| 809 |
+
step = f"{m['kind']} {obj} with {app}"
|
| 810 |
+
if not self._fail(step):
|
| 811 |
+
return step
|
| 812 |
+
dest = self._dest()
|
| 813 |
+
if dest and self.loc != dest:
|
| 814 |
+
step = f"go to {dest}"
|
| 815 |
+
if not self._fail(step):
|
| 816 |
+
return step
|
| 817 |
+
if dest and dest not in self.open and _obj_base(dest) in _ALF_CONTAINERS:
|
| 818 |
+
step = f"open {dest}"
|
| 819 |
+
if not self._fail(step):
|
| 820 |
+
return step
|
| 821 |
+
if dest:
|
| 822 |
+
step = f"move {obj} to {dest}"
|
| 823 |
+
if not self._fail(step):
|
| 824 |
+
return step
|
| 825 |
+
else:
|
| 826 |
+
return self._takeable_target() or self._search_step()
|
| 827 |
+
return None
|
| 828 |
+
|
| 829 |
+
def _legal_fallback(self, step: str) -> str | None:
|
| 830 |
+
"""A legal action with the same purpose when the exact step is not listed."""
|
| 831 |
+
if self._legal(step):
|
| 832 |
+
return step
|
| 833 |
+
if not self.admissible or not self.mission:
|
| 834 |
+
return None
|
| 835 |
+
m = self.mission
|
| 836 |
+
base = m["target"]
|
| 837 |
+
verb = step.split()[0] if step else ""
|
| 838 |
+
held = [o for o in self.held if _obj_base(o) == base]
|
| 839 |
+
if verb == "take":
|
| 840 |
+
for act in sorted(self.admissible):
|
| 841 |
+
parts = act.split()
|
| 842 |
+
if len(parts) >= 2 and parts[0] == "take" and parts[1] == base:
|
| 843 |
+
return act
|
| 844 |
+
return None
|
| 845 |
+
if verb == "move" and held:
|
| 846 |
+
for act in sorted(self.admissible):
|
| 847 |
+
parts = act.split()
|
| 848 |
+
if len(parts) >= 5 and parts[0] == "move" \
|
| 849 |
+
and f"{parts[1]} {parts[2]}" == held[0] \
|
| 850 |
+
and parts[-2] == m["dest"]:
|
| 851 |
+
return act
|
| 852 |
+
return None
|
| 853 |
+
if verb in ("clean", "cool", "heat") and held:
|
| 854 |
+
for act in sorted(self.admissible):
|
| 855 |
+
parts = act.split()
|
| 856 |
+
if len(parts) >= 4 and parts[0] == verb \
|
| 857 |
+
and f"{parts[1]} {parts[2]}" == held[0]:
|
| 858 |
+
return act
|
| 859 |
+
return None
|
| 860 |
+
if verb == "use":
|
| 861 |
+
for act in sorted(self.admissible):
|
| 862 |
+
if act.startswith("use desklamp"):
|
| 863 |
+
return act
|
| 864 |
+
return None
|
| 865 |
+
if verb == "examine" and held:
|
| 866 |
+
for act in sorted(self.admissible):
|
| 867 |
+
if act == f"examine {held[0]}":
|
| 868 |
+
return act
|
| 869 |
+
return None
|
| 870 |
+
if verb == "open":
|
| 871 |
+
for act in sorted(self.admissible):
|
| 872 |
+
if act.startswith("open "):
|
| 873 |
+
return act
|
| 874 |
+
return None
|
| 875 |
+
if verb == "go to":
|
| 876 |
+
for act in sorted(self.admissible):
|
| 877 |
+
if act.startswith("go to "):
|
| 878 |
+
return act
|
| 879 |
+
return None
|
| 880 |
+
return None
|
| 881 |
+
|
| 882 |
+
def hint(self) -> str:
|
| 883 |
+
if not self.mission:
|
| 884 |
+
return ""
|
| 885 |
+
m = self.mission
|
| 886 |
+
lines = [f"[harness] Goal: {m['raw']}."]
|
| 887 |
+
lines.append(f"Environment step {self.step}/{self.budget} "
|
| 888 |
+
f"({'SOLVED' if self.solved else 'NOT solved'}).")
|
| 889 |
+
held = sorted(o for o in self.held if _obj_base(o) == m["target"])
|
| 890 |
+
done = self._completed()
|
| 891 |
+
placed = sorted(o for o in done if _obj_base(o) == m["target"])
|
| 892 |
+
raw_at_dest = sorted(o for o in self.placed
|
| 893 |
+
if _obj_base(o) == m["target"] and o not in done)
|
| 894 |
+
if held:
|
| 895 |
+
processed = " (processed)" if all(
|
| 896 |
+
not m["kind"] or m["kind"] in self.transformed.get(o, ())
|
| 897 |
+
for o in held) else ""
|
| 898 |
+
lines.append("Holding: " + ", ".join(held) + processed + ".")
|
| 899 |
+
if placed:
|
| 900 |
+
lines.append(f"Already placed: {len(placed)}/{m['count']} "
|
| 901 |
+
+ ", ".join(placed) + ".")
|
| 902 |
+
if raw_at_dest:
|
| 903 |
+
lines.append("At the destination but NOT processed yet: "
|
| 904 |
+
+ ", ".join(raw_at_dest) + " (take it, process it, then place it).")
|
| 905 |
+
seen = sorted(o for o in self.saw if _obj_base(o) == m["target"]
|
| 906 |
+
and o not in done and o not in self.held
|
| 907 |
+
and o not in raw_at_dest)
|
| 908 |
+
if seen and len(placed) + len(held) < m["count"]:
|
| 909 |
+
lines.append("Target seen: "
|
| 910 |
+
+ ", ".join(f"{o} at {self.saw[o]}" for o in seen[:6]) + ".")
|
| 911 |
+
if self.invalid:
|
| 912 |
+
lines.append("The last action did nothing and still cost an environment "
|
| 913 |
+
"step; only use an action from the Admissible actions list.")
|
| 914 |
+
nxt = self.next_action()
|
| 915 |
+
if nxt and not self._legal(nxt):
|
| 916 |
+
nxt = self._legal_fallback(nxt)
|
| 917 |
+
if nxt and not self.solved:
|
| 918 |
+
lines.append(f'Next required action: python3 alf do "{nxt}"')
|
| 919 |
+
return "\n".join(lines)
|
| 920 |
+
|
| 921 |
+
|
| 922 |
+
def _loop_budget(mission: dict | None) -> int:
|
| 923 |
+
"""Shell steps for this task: the environment's budget plus free-command slack."""
|
| 924 |
+
if mission:
|
| 925 |
+
return min(max(MAX_STEPS, int(mission["budget"]) + STEP_SLACK), 200)
|
| 926 |
+
return MAX_STEPS
|
| 927 |
+
|
| 928 |
+
|
| 929 |
+
def _is_cycle(cmd: str, history: list[str]) -> bool:
|
| 930 |
+
"""True when `cmd` continues a short cycle that is already in `history`.
|
| 931 |
+
|
| 932 |
+
The old repeat guard fired only when a command equaled the *immediately*
|
| 933 |
+
previous one. Measured here: the model cycled `go to shelf 5`, `shelf 6`,
|
| 934 |
+
`shelf 7` for 24 steps and no guard fired once. A cycle of period 2 or 3 is
|
| 935 |
+
just as much a non-action as an immediate repeat, so break it before it is
|
| 936 |
+
run (skill item 4: do not feed the repeat back as another observation).
|
| 937 |
+
"""
|
| 938 |
+
for period in (1, 2, 3):
|
| 939 |
+
if period == 1:
|
| 940 |
+
if history and history[-1] == cmd:
|
| 941 |
+
return True
|
| 942 |
+
continue
|
| 943 |
+
if len(history) >= 2 * period and history[-period:] == history[-2 * period:-period] \
|
| 944 |
+
and cmd == history[-period]:
|
| 945 |
+
return True
|
| 946 |
+
return False
|
| 947 |
+
|
| 948 |
+
|
| 949 |
+
def _premature_finish_note(state: _AlfState, how: str) -> str:
|
| 950 |
+
hint = state.hint()
|
| 951 |
+
return (
|
| 952 |
+
f"[harness] You tried to finish ({how}), but the environment has NOT printed "
|
| 953 |
+
"SOLVED. The task is graded only by the actions replayed from "
|
| 954 |
+
"alf_actions.jsonl, so stopping now scores zero. Do not answer or run "
|
| 955 |
+
"`alf done` before the environment prints SOLVED.\n"
|
| 956 |
+
+ (hint + "\n" if hint else "")
|
| 957 |
+
+ "Continue now with exactly one action.")
|
| 958 |
+
|
| 959 |
+
|
| 960 |
+
def _cycle_note(state: _AlfState) -> str:
|
| 961 |
+
hint = state.hint()
|
| 962 |
+
return ("[harness] That command was NOT run: the last actions form a repeating "
|
| 963 |
+
"cycle, so running it again cannot change the environment. Choose a "
|
| 964 |
+
"different action.\n" + (hint if hint else ""))
|
| 965 |
+
|
| 966 |
+
|
| 967 |
+
def _clip_text(out: str, limit: int) -> str:
|
| 968 |
+
if len(out) <= limit:
|
| 969 |
+
return out
|
| 970 |
+
marker = f"\n... [text clipped; original {len(out)} characters] ...\n"
|
| 971 |
+
room = max(0, limit - len(marker))
|
| 972 |
+
head = (room + 1) // 2
|
| 973 |
+
tail = room // 2
|
| 974 |
+
return (out[:head] + marker + (out[-tail:] if tail else ""))[:limit]
|
| 975 |
+
|
| 976 |
+
|
| 977 |
+
def _json_preview(value: list | dict, limit: int) -> str | None:
|
| 978 |
+
"""A bounded, valid JSON preview containing whole first/last entries."""
|
| 979 |
+
mapping = isinstance(value, dict)
|
| 980 |
+
items = list(value.items()) if mapping else value
|
| 981 |
+
head, tail = [], []
|
| 982 |
+
|
| 983 |
+
def render():
|
| 984 |
+
return json.dumps({"_harness_preview": {
|
| 985 |
+
"total_items": len(items), "omitted_items": len(items) - len(head) - len(tail)},
|
| 986 |
+
"head": dict(head) if mapping else head,
|
| 987 |
+
"tail": dict(tail) if mapping else tail}, ensure_ascii=False, separators=(",", ":"))
|
| 988 |
+
|
| 989 |
+
shown = render()
|
| 990 |
+
if len(shown) > limit:
|
| 991 |
+
return None
|
| 992 |
+
front, back = 0, len(items) - 1
|
| 993 |
+
while front <= back:
|
| 994 |
+
added = False
|
| 995 |
+
head.append(items[front])
|
| 996 |
+
candidate = render()
|
| 997 |
+
if len(candidate) <= limit:
|
| 998 |
+
shown = candidate
|
| 999 |
+
front += 1
|
| 1000 |
+
added = True
|
| 1001 |
+
else:
|
| 1002 |
+
head.pop()
|
| 1003 |
+
if front <= back:
|
| 1004 |
+
tail.insert(0, items[back])
|
| 1005 |
+
candidate = render()
|
| 1006 |
+
if len(candidate) <= limit:
|
| 1007 |
+
shown = candidate
|
| 1008 |
+
back -= 1
|
| 1009 |
+
added = True
|
| 1010 |
+
else:
|
| 1011 |
+
tail.pop(0)
|
| 1012 |
+
if not added:
|
| 1013 |
+
break
|
| 1014 |
+
return shown
|
| 1015 |
+
|
| 1016 |
+
|
| 1017 |
+
def _clip_output(out: str) -> str:
|
| 1018 |
+
"""Compact leading JSON losslessly before bounding; retain whole list items.
|
| 1019 |
+
|
| 1020 |
+
Non-JSON suffixes (including shell errors) remain visible. The caller saves
|
| 1021 |
+
the original separately whenever this view differs from the output.
|
| 1022 |
+
"""
|
| 1023 |
+
if len(out) <= OUTPUT_LIMIT:
|
| 1024 |
+
return out
|
| 1025 |
+
stripped = out.lstrip()
|
| 1026 |
+
try:
|
| 1027 |
+
obj, end = json.JSONDecoder().raw_decode(stripped)
|
| 1028 |
+
except (ValueError, RecursionError):
|
| 1029 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 1030 |
+
if not isinstance(obj, (dict, list)):
|
| 1031 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 1032 |
+
suffix = stripped[end:]
|
| 1033 |
+
compact = json.dumps(obj, ensure_ascii=False, separators=(",", ":")) + suffix
|
| 1034 |
+
if len(compact) <= OUTPUT_LIMIT:
|
| 1035 |
+
return compact
|
| 1036 |
+
preview = _json_preview(obj, OUTPUT_LIMIT - len(suffix))
|
| 1037 |
+
if preview is not None:
|
| 1038 |
+
return preview + suffix
|
| 1039 |
+
return _clip_text(compact, OUTPUT_LIMIT)
|
| 1040 |
+
|
| 1041 |
+
|
| 1042 |
+
def _shell_runtime() -> tuple[str, str]:
|
| 1043 |
+
"""Choose once before any task action; never retry side effects in another shell."""
|
| 1044 |
+
bash = shutil.which("bash")
|
| 1045 |
+
return (bash, "Bash") if bash else ("/bin/sh", "POSIX sh")
|
| 1046 |
+
|
| 1047 |
+
|
| 1048 |
+
def _trim_history(messages: list[dict], budget: int | None = None) -> int:
|
| 1049 |
+
"""丢最旧的成对消息,直到历史在 `budget`(默认 `CONTEXT_CHAR_BUDGET`)以内。返回丢掉的条数。
|
| 1050 |
+
|
| 1051 |
+
`messages[0]` 是 system,`messages[1]` 是题面,两者永不丢。之后严格成对
|
| 1052 |
+
(assistant 动作、user 结果),所以一次删两条,而不是一条 —— 删一条会让"结果"成为
|
| 1053 |
+
历史里的第一条,模型会读到一段没有对应动作的输出。
|
| 1054 |
+
|
| 1055 |
+
**为什么需要一个更小的 `budget` 参数。** 字符数不是 token 数,两者的比例随内容在
|
| 1056 |
+
2:1 到 4:1 之间浮动:代码、git 对象、base64 每 token 只有一两个字符,英文散文有
|
| 1057 |
+
四个。实测(2026-10-04,`local-screen-1`):60000 字符的历史在 `git-leak-recovery` 和
|
| 1058 |
+
`regex-chess` 上被 vLLM 判为 "at least 32769 input tokens" —— 字符预算满足了,token
|
| 1059 |
+
预算没有。所以唯一可靠的判据是**模型自己说的**那个错误:`_call_openai` 收到它就按
|
| 1060 |
+
一半预算再削一次历史并重试,而不是让整道题死掉。
|
| 1061 |
+
"""
|
| 1062 |
+
limit = CONTEXT_CHAR_BUDGET if budget is None else budget
|
| 1063 |
+
dropped = 0
|
| 1064 |
+
while len(messages) > 4 and \
|
| 1065 |
+
sum(len(m.get("content") or "") for m in messages) > limit:
|
| 1066 |
+
del messages[2:4]
|
| 1067 |
+
dropped += 2
|
| 1068 |
+
return dropped
|
| 1069 |
+
|
| 1070 |
+
|
| 1071 |
+
#: 模型拒绝一条 prompt 时的两种说法(vLLM/OpenAI 兼容端点各一种)。判据是模型自己的措辞,
|
| 1072 |
+
#: 不是我们对 token 的估算 —— 估错了会削掉本该保留的历史,或者留下一个必然失败的长度。
|
| 1073 |
+
_CONTEXT_ERROR_MARKERS = ("maximum context length", "context length is", "context_length_exceeded",
|
| 1074 |
+
"reduce the length of the input prompt")
|
| 1075 |
+
|
| 1076 |
+
|
| 1077 |
+
def run(task: dict, workdir: Path) -> str:
|
| 1078 |
+
"""Execute one task. Returns the answer string.
|
| 1079 |
+
|
| 1080 |
+
The trace written to <workdir>/trace.jsonl is what the framework collects
|
| 1081 |
+
and hands to the Trainer (INTERFACE.md §4.1).
|
| 1082 |
+
"""
|
| 1083 |
+
trace_path = workdir / "trace.jsonl"
|
| 1084 |
+
shell, dialect = _shell_runtime()
|
| 1085 |
+
mission = _alf_mission(task)
|
| 1086 |
+
state = _AlfState(mission)
|
| 1087 |
+
max_steps = _loop_budget(mission)
|
| 1088 |
+
environment_note = ""
|
| 1089 |
+
if mission:
|
| 1090 |
+
environment_note = (
|
| 1091 |
+
"\nThis task is an interactive text environment reached through `python3 alf`.\n"
|
| 1092 |
+
"- `python3 alf look` is free and prints the current room plus the exact "
|
| 1093 |
+
"admissible actions. `python3 alf do \"...\"` costs one of the environment's "
|
| 1094 |
+
f"{mission['budget']} steps.\n"
|
| 1095 |
+
"- The environment prints `SOLVED` only when the goal is actually met. Never "
|
| 1096 |
+
"answer or run `alf done` before you see `SOLVED`.\n"
|
| 1097 |
+
"- After each step the harness prints your goal progress and the next required "
|
| 1098 |
+
"action; follow it unless you have a concrete reason not to.\n")
|
| 1099 |
+
messages = [
|
| 1100 |
+
{"role": "system", "content": SYSTEM + environment_note + (
|
| 1101 |
+
f"\nShell runtime: {shell} -c ({dialect}). Each command starts a new shell.\n"
|
| 1102 |
+
+ ("Bash arrays and PIPESTATUS are supported.\n" if dialect == "Bash" else
|
| 1103 |
+
"Use POSIX syntax; Bash arrays, PIPESTATUS and [[ ]] are unavailable.\n"))},
|
| 1104 |
+
{"role": "user", "content": json.dumps(task)},
|
| 1105 |
+
]
|
| 1106 |
+
|
| 1107 |
+
answer = ""
|
| 1108 |
+
submits = 0
|
| 1109 |
+
parse_retries = 0
|
| 1110 |
+
premature_finishes = 0
|
| 1111 |
+
cycle_blocks = 0
|
| 1112 |
+
alf_history: list[str] = []
|
| 1113 |
+
cmd_history: list[str] = []
|
| 1114 |
+
output_dir = None
|
| 1115 |
+
# **行缓冲,不是默认的 8KB 块缓冲。** 实测(2026-10-04,本地模型跑 `bn-fit-modify`):
|
| 1116 |
+
# harness 已经跑了 8 分钟、正在装 pandas,而 `/app/trace.jsonl` 是 0 字节、打开的 fd
|
| 1117 |
+
# `pos: 0` —— 一行都还没落盘。代价有三条:
|
| 1118 |
+
# * 实时的轨迹看不见,面板和调试都只能等它结束;
|
| 1119 |
+
# * 被超时杀掉的题会丢掉缓冲区里的尾巴(≤8KB)。一般长跑无所谓(`adaptive-rejection-sampler`
|
| 1120 |
+
# 那次写了 1MB,尾巴只占零头),但一道死在第一个命令里的题,尾巴就是**全部**;
|
| 1121 |
+
# * `harness_failed` 的判据是"轨迹为空",于是"被杀"和"从没跑起来"在记录里同形。
|
| 1122 |
+
# 行缓冲每写一行就落盘,这三条一起消失,代价是一次 write 系统调用。
|
| 1123 |
+
with trace_path.open("w", buffering=1) as trace:
|
| 1124 |
+
# **这份 harness 自己声明它的运行时预算。**
|
| 1125 |
+
#
|
| 1126 |
+
# 平台从外面只能看见 harness 目录的哈希。可哈希相同、行为不同的两份 harness 是
|
| 1127 |
+
# 存在的:`HG_AGENT_MAX_STEPS=16` 和 `=32` 跑同一个文件,一条轨迹 16 步就停、
|
| 1128 |
+
# 另一条能跑 32 步 —— 实测(2026-10-04,本地 9B 跑 `build-pmars`)32 步需要约
|
| 1129 |
+
# 1100 秒,超过题目自带的 900 秒预算,于是它超时;16 步则跑得完。这两次测量的
|
| 1130 |
+
# 曲线点上原来没有任何一个字段不同,读者无法分辨"同一外壳跑两次"和"两个预算
|
| 1131 |
+
# 各跑一次"。
|
| 1132 |
+
#
|
| 1133 |
+
# 所以这里声明一次,由平台记到曲线点上(`harnessgrad/identity.py:harness_config`)。
|
| 1134 |
+
# 同时声明 model/backend:这个 harness 读 `HG_AGENT_MODEL`,但只有它自己知道读到
|
| 1135 |
+
# 了什么,平台的环境变量在别处会因改名而与实际不符(INTERFACE.md §3)。
|
| 1136 |
+
identity = {"harness": "loop", "config": {
|
| 1137 |
+
"max_steps": max_steps,
|
| 1138 |
+
"env_budget": mission["budget"] if mission else None,
|
| 1139 |
+
"step_slack": STEP_SLACK if mission else 0,
|
| 1140 |
+
"submit_retries": SUBMIT_RETRIES,
|
| 1141 |
+
"parse_retries": PARSE_RETRIES, "finish_nudge_steps": FINISH_NUDGE_STEPS,
|
| 1142 |
+
"repeat_nudge_limit": REPEAT_NUDGE_LIMIT, "output_limit": OUTPUT_LIMIT,
|
| 1143 |
+
"context_chars": CONTEXT_CHAR_BUDGET,
|
| 1144 |
+
"shell": shell, "shell_dialect": dialect,
|
| 1145 |
+
"max_output_tokens": MAX_OUTPUT_TOKENS}}
|
| 1146 |
+
for key, value in (("agent_model", os.environ.get("HG_AGENT_MODEL")),
|
| 1147 |
+
("agent_backend", _backend())):
|
| 1148 |
+
if value:
|
| 1149 |
+
identity[key] = value
|
| 1150 |
+
trace.write(json.dumps({"harness_identity": identity}) + "\n")
|
| 1151 |
+
# **每一步的时间去哪了。** 实测(2026-10-04):本地 9B 跑 `build-pmars`,26 步撞上
|
| 1152 |
+
# 题目自带的 900 秒预算被杀。可它是"模型慢"还是"命令慢",记录里看不出来 —— trace
|
| 1153 |
+
# 只有步数,没有任何时间字段。这两件事的平台处置完全相反:模型慢要缩步数上限或
|
| 1154 |
+
# 换模型,命令慢是这道题自己的成本(装依赖),换模型没用。
|
| 1155 |
+
#
|
| 1156 |
+
# 所以每步记两个毫秒数:等模型的时间、跑命令的时间。总和不等于墙钟时,差额就是
|
| 1157 |
+
# harness 自己的开销,那也是要看得见的东西。
|
| 1158 |
+
started = time.time()
|
| 1159 |
+
model_s = command_s = 0.0
|
| 1160 |
+
trims_before = USAGE["context_trims"]
|
| 1161 |
+
for step in range(max_steps):
|
| 1162 |
+
dropped = _trim_history(messages)
|
| 1163 |
+
if dropped:
|
| 1164 |
+
trace.write(json.dumps({"step": step, "history_dropped": dropped}) + "\n")
|
| 1165 |
+
t0 = time.time()
|
| 1166 |
+
reply = _complete(messages)
|
| 1167 |
+
took = time.time() - t0
|
| 1168 |
+
model_s += took
|
| 1169 |
+
trace.write(json.dumps({"step": step, "reply": reply,
|
| 1170 |
+
"model_ms": int(took * 1000)}) + "\n")
|
| 1171 |
+
# 这一步的 prompt 被模型拒绝过,harness 因此削短了历史再问。模型这一步看到的
|
| 1172 |
+
# 历史比上一步短 —— 不记下来的话,"它为什么换了做法"在 trace 里没有答案。
|
| 1173 |
+
if USAGE["context_trims"] > trims_before:
|
| 1174 |
+
trace.write(json.dumps({
|
| 1175 |
+
"step": step, "context_trims": USAGE["context_trims"],
|
| 1176 |
+
"history_kept": len(messages)}) + "\n")
|
| 1177 |
+
trims_before = USAGE["context_trims"]
|
| 1178 |
+
messages.append({"role": "assistant", "content": reply})
|
| 1179 |
+
|
| 1180 |
+
try:
|
| 1181 |
+
action = _parse(reply)
|
| 1182 |
+
except Exception as exc:
|
| 1183 |
+
# 退回给模型,而不是结束整道题。trace 里记下第几次重试,因为平台看不到
|
| 1184 |
+
# 容器内部:没有这条记录,一次"读不懂的回复"在记录里和一次"一步就交卷"
|
| 1185 |
+
# 长得一样。次数用完仍然是 harness 失败(它确实读不出动作),但那时记录
|
| 1186 |
+
# 里已经有 N 次尝试,而不是一次。
|
| 1187 |
+
trace.write(json.dumps({"step": step, "parse_error": str(exc),
|
| 1188 |
+
"parse_retry": parse_retries}) + "\n")
|
| 1189 |
+
if parse_retries >= PARSE_RETRIES:
|
| 1190 |
+
break
|
| 1191 |
+
parse_retries += 1
|
| 1192 |
+
# Keep the full failed reply in the trace, not as an example for
|
| 1193 |
+
# the next completion to copy. In particular, token-cut commands
|
| 1194 |
+
# should be shortened by the model, never completed by the parser.
|
| 1195 |
+
messages[-1]["content"] = "[Unparseable reply omitted; see trace.jsonl.]"
|
| 1196 |
+
messages.append({"role": "user", "content": (
|
| 1197 |
+
f"Your reply could not be read as an action: {exc}\n"
|
| 1198 |
+
"Nothing was executed. It may have been cut off by the output token limit.\n"
|
| 1199 |
+
"Send one short command; use a loop/script instead of enumerating calls.\n"
|
| 1200 |
+
f"You have {max_steps - step - 1} step(s) left.\n"
|
| 1201 |
+
"Reply with EXACTLY ONE JSON object and nothing else, one of:\n"
|
| 1202 |
+
' {"tool": "bash", "command": "<shell command>"}\n'
|
| 1203 |
+
' {"answer": "<your final answer>"}\n'
|
| 1204 |
+
'For structured predictions, put the complete JSON object in "answer"; '
|
| 1205 |
+
'preserve the task\'s prediction schema.')})
|
| 1206 |
+
continue
|
| 1207 |
+
|
| 1208 |
+
parse_retries = 0
|
| 1209 |
+
# Prose or echoed data before a recovered action is not part of the
|
| 1210 |
+
# executed command. Store only the parsed action in model history.
|
| 1211 |
+
messages[-1]["content"] = json.dumps(action)
|
| 1212 |
+
|
| 1213 |
+
# **修过的地方要留痕。** 重复键的回复被解析成"第一个值放前面"之后,模型看到的
|
| 1214 |
+
# 命令和它写的不完全一样(它写了两遍,harness 取了第一遍)。一次被静默改写的
|
| 1215 |
+
# 动作和一次原样执行的动作不是同一件事,记录里必须分开。
|
| 1216 |
+
repaired = getattr(action, "duplicates", ())
|
| 1217 |
+
if repaired:
|
| 1218 |
+
trace.write(json.dumps({"step": step,
|
| 1219 |
+
"duplicate_keys": list(repaired)}) + "\n")
|
| 1220 |
+
|
| 1221 |
+
# **交卷闸门。** 顺序按"它想干什么"判断,而不是按哪个键先出现:
|
| 1222 |
+
# 一条回复里同时带 command 和 answer 时,以前"先看 answer"会让那条命令
|
| 1223 |
+
# 永远不执行(实测:`{"tool":"bash","command":"cat > /app/run.py …"}` 被当成
|
| 1224 |
+
# 空答案,文件从未创建)。所以:有命令就先执行命令;只有**没有**命令时才算交卷。
|
| 1225 |
+
cmd = action.get("command", "")
|
| 1226 |
+
if not cmd and "answer" in action:
|
| 1227 |
+
# The environment, not the model, decides whether this task is done.
|
| 1228 |
+
# Measured: 30 of 47 unsolved ALF runs ran `alf done` and submitted a
|
| 1229 |
+
# confident answer while the environment still printed `in progress`.
|
| 1230 |
+
# Accepting that answer throws away the remaining environment budget;
|
| 1231 |
+
# pushing back with the goal state gives the model the step it needed.
|
| 1232 |
+
if mission and not state.solved \
|
| 1233 |
+
and state.step < state.budget \
|
| 1234 |
+
and premature_finishes < SUBMIT_RETRIES + 1:
|
| 1235 |
+
premature_finishes += 1
|
| 1236 |
+
trace.write(json.dumps({"step": step, "premature_finish": "answer",
|
| 1237 |
+
"env_step": state.step}) + "\n")
|
| 1238 |
+
messages.append({"role": "user",
|
| 1239 |
+
"content": _premature_finish_note(state, "answer")})
|
| 1240 |
+
continue
|
| 1241 |
+
missing = _missing_deliverables(task, workdir)
|
| 1242 |
+
if missing and submits < SUBMIT_RETRIES:
|
| 1243 |
+
submits += 1
|
| 1244 |
+
note = ("You answered but these paths the task asks for do not exist: "
|
| 1245 |
+
+ ", ".join(missing)
|
| 1246 |
+
+ ". Create them first, then answer again.")
|
| 1247 |
+
trace.write(json.dumps({"step": step, "submit_rejected": missing}) + "\n")
|
| 1248 |
+
messages.append({"role": "user", "content": note})
|
| 1249 |
+
continue
|
| 1250 |
+
trace.write(json.dumps({"step": step, "submitted": True,
|
| 1251 |
+
"missing": missing}) + "\n")
|
| 1252 |
+
answer = _answer_text(action["answer"])
|
| 1253 |
+
break
|
| 1254 |
+
|
| 1255 |
+
# `alf done` is the model declaring completion, not the environment
|
| 1256 |
+
# reporting it. The verifier replays only the actions, so a premature
|
| 1257 |
+
# done is pure loss; refuse it and show what is still missing.
|
| 1258 |
+
if mission and not state.solved and _ALF_DONE_RE.search(cmd) \
|
| 1259 |
+
and not _ALF_DO_RE.search(cmd) \
|
| 1260 |
+
and state.step < state.budget \
|
| 1261 |
+
and premature_finishes < SUBMIT_RETRIES + 1:
|
| 1262 |
+
premature_finishes += 1
|
| 1263 |
+
trace.write(json.dumps({"step": step, "premature_finish": "alf done",
|
| 1264 |
+
"env_step": state.step}) + "\n")
|
| 1265 |
+
messages.append({"role": "user",
|
| 1266 |
+
"content": _premature_finish_note(state, "alf done")})
|
| 1267 |
+
continue
|
| 1268 |
+
|
| 1269 |
+
# Break a cycle *before* it executes: feeding the same observation back
|
| 1270 |
+
# is what let one run spend 24 steps walking shelf 5 -> 6 -> 7 -> 5.
|
| 1271 |
+
# Environment actions are compared among themselves (a free `alf look`
|
| 1272 |
+
# must not hide a cycle); every other command is compared against the
|
| 1273 |
+
# full command history, which preserves the old immediate-repeat guard.
|
| 1274 |
+
is_alf_action = bool(mission and _ALF_DO_RE.search(cmd))
|
| 1275 |
+
history = alf_history if is_alf_action else cmd_history
|
| 1276 |
+
if _is_cycle(cmd, history) and cycle_blocks < REPEAT_NUDGE_LIMIT * 3:
|
| 1277 |
+
cycle_blocks += 1
|
| 1278 |
+
trace.write(json.dumps({"step": step, "repeat_blocked": cmd[:160],
|
| 1279 |
+
"env_step": state.step}) + "\n")
|
| 1280 |
+
messages.append({"role": "user", "content": (
|
| 1281 |
+
_cycle_note(state) if mission else
|
| 1282 |
+
"[harness] That command was NOT run because it repeats a command "
|
| 1283 |
+
"that is already in the conversation; running it again cannot "
|
| 1284 |
+
"change the result. Choose a different action.")})
|
| 1285 |
+
continue
|
| 1286 |
+
if is_alf_action:
|
| 1287 |
+
alf_history.append(cmd.strip())
|
| 1288 |
+
if len(alf_history) > 12:
|
| 1289 |
+
del alf_history[:-12]
|
| 1290 |
+
cmd_history.append(cmd.strip())
|
| 1291 |
+
if len(cmd_history) > 12:
|
| 1292 |
+
del cmd_history[:-12]
|
| 1293 |
+
|
| 1294 |
+
t0 = time.time()
|
| 1295 |
+
proc = subprocess.run(
|
| 1296 |
+
# `errors="replace"`: a command may emit arbitrary bytes, and a strict decode
|
| 1297 |
+
# raises UnicodeDecodeError inside the harness, which ends the episode and is
|
| 1298 |
+
# recorded as a zero for a task nobody finished. Measured 2026-10-15.
|
| 1299 |
+
[shell, "-c", cmd], cwd=workdir, capture_output=True, text=True,
|
| 1300 |
+
errors="replace"
|
| 1301 |
+
)
|
| 1302 |
+
took = time.time() - t0
|
| 1303 |
+
command_s += took
|
| 1304 |
+
out = proc.stdout + proc.stderr
|
| 1305 |
+
trace.write(json.dumps({"step": step, "command": cmd,
|
| 1306 |
+
"exit": proc.returncode,
|
| 1307 |
+
"shell": shell,
|
| 1308 |
+
"command_ms": int(took * 1000), "output": out}) + "\n")
|
| 1309 |
+
shown = _clip_output(out)
|
| 1310 |
+
output_note = ""
|
| 1311 |
+
if shown != out:
|
| 1312 |
+
if output_dir is None:
|
| 1313 |
+
import tempfile
|
| 1314 |
+
output_dir = Path(tempfile.mkdtemp(prefix=".hg-output-", dir=workdir))
|
| 1315 |
+
saved = output_dir / f"step-{step}.txt"
|
| 1316 |
+
saved.write_text(out)
|
| 1317 |
+
relative = saved.relative_to(workdir)
|
| 1318 |
+
output_note = (f"\nFull output: {relative} (use shell tools to inspect/filter it).\n"
|
| 1319 |
+
"The view below may omit records; omitted does not mean absent.\n")
|
| 1320 |
+
trace.write(json.dumps({"step": step, "output_clipped": len(out),
|
| 1321 |
+
"shown": len(shown), "output_file": str(relative),
|
| 1322 |
+
"output_view": shown}) + "\n")
|
| 1323 |
+
state.observe(out, cmd)
|
| 1324 |
+
# A real environment action is progress; give the model a fresh set of
|
| 1325 |
+
# push-backs if it later tries to finish early again.
|
| 1326 |
+
if mission and _ALF_DO_RE.search(cmd):
|
| 1327 |
+
premature_finishes = 0
|
| 1328 |
+
observation = f"exit={proc.returncode}{output_note}\n{shown}"
|
| 1329 |
+
hint = state.hint() if mission else ""
|
| 1330 |
+
if hint:
|
| 1331 |
+
observation += "\n\n" + hint
|
| 1332 |
+
messages.append({"role": "user", "content": observation})
|
| 1333 |
+
|
| 1334 |
+
# The environment said SOLVED. Stop immediately: the verifier replays
|
| 1335 |
+
# the actions that are already in alf_actions.jsonl, so more calls can
|
| 1336 |
+
# only add noise (and the old loop answered after this with a boolean
|
| 1337 |
+
# and burned its parse retries for nothing).
|
| 1338 |
+
if mission and state.solved:
|
| 1339 |
+
trace.write(json.dumps({"step": step, "environment_solved": True,
|
| 1340 |
+
"env_step": state.step}) + "\n")
|
| 1341 |
+
answer = json.dumps({"task_id": task.get("task_id"),
|
| 1342 |
+
"status": "solved"})
|
| 1343 |
+
break
|
| 1344 |
+
|
| 1345 |
+
# The environment's own action budget is spent; no further action can
|
| 1346 |
+
# be graded as progress, so stop instead of answering after the cap.
|
| 1347 |
+
if mission and state.step >= state.budget:
|
| 1348 |
+
trace.write(json.dumps({"step": step, "environment_exhausted": True,
|
| 1349 |
+
"env_step": state.step}) + "\n")
|
| 1350 |
+
answer = json.dumps({"task_id": task.get("task_id"),
|
| 1351 |
+
"status": "environment budget exhausted"})
|
| 1352 |
+
break
|
| 1353 |
+
|
| 1354 |
+
left = max_steps - (step + 1)
|
| 1355 |
+
# 只在进入收尾区和最后一步各说一次:每一步都重复同一句话不会更有用,
|
| 1356 |
+
# 只会把最近几轮的命令输出挤远。
|
| 1357 |
+
if left and (left == FINISH_NUDGE_STEPS or left == 1):
|
| 1358 |
+
trace.write(json.dumps({"step": step, "finish_nudge": left}) + "\n")
|
| 1359 |
+
if mission:
|
| 1360 |
+
messages[-1]["content"] += "\n" + (
|
| 1361 |
+
f"You have {left} shell step(s) left; the environment is at "
|
| 1362 |
+
f"step {state.step}/{state.budget}. Follow the Next required "
|
| 1363 |
+
"action and do not answer before the environment prints SOLVED.")
|
| 1364 |
+
else:
|
| 1365 |
+
messages[-1]["content"] += "\n" + (
|
| 1366 |
+
f"You have {left} step(s) left. Stop exploring. Create every file the "
|
| 1367 |
+
"task asks for now, then reply with exactly one JSON object: "
|
| 1368 |
+
'{"answer": "<your final answer>"}')
|
| 1369 |
+
|
| 1370 |
+
# Where the wall clock went. Separate from `usage` (which counts tokens):
|
| 1371 |
+
# a reader asking "was this killed for being slow, and slow at what" gets one
|
| 1372 |
+
# line, and a harness that is slow on its own shows up as `total` exceeding
|
| 1373 |
+
# model + commands.
|
| 1374 |
+
trace.write(json.dumps({"wall_clock_s": {
|
| 1375 |
+
"model": round(model_s, 1), "commands": round(command_s, 1),
|
| 1376 |
+
"total": round(time.time() - started, 1)}}) + "\n")
|
| 1377 |
+
|
| 1378 |
+
# What the run cost. Kept because a harness that cannot say what it spent
|
| 1379 |
+
# cannot be compared with a cheaper one at the same score -- and because
|
| 1380 |
+
# `USAGE` is the only place the model calls are counted.
|
| 1381 |
+
trace.write(json.dumps({"usage": dict(USAGE)}) + "\n")
|
| 1382 |
+
|
| 1383 |
+
(workdir / "answer.txt").write_text(answer)
|
| 1384 |
+
return answer
|
| 1385 |
+
|
| 1386 |
+
|
| 1387 |
+
def main() -> int:
|
| 1388 |
+
ap = argparse.ArgumentParser()
|
| 1389 |
+
ap.add_argument("--task", required=True)
|
| 1390 |
+
ap.add_argument("--workdir", required=True)
|
| 1391 |
+
args = ap.parse_args()
|
| 1392 |
+
|
| 1393 |
+
task = json.loads(Path(args.task).read_text())
|
| 1394 |
+
run(task, Path(args.workdir))
|
| 1395 |
+
return 0
|
| 1396 |
+
|
| 1397 |
+
|
| 1398 |
+
if __name__ == "__main__":
|
| 1399 |
+
sys.exit(main())
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-1/harness.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "loop",
|
| 3 |
+
"version": "0.2.0",
|
| 4 |
+
"path": ".",
|
| 5 |
+
"entrypoint": "agent.py",
|
| 6 |
+
"backend": "cli",
|
| 7 |
+
"install": "requirements.txt",
|
| 8 |
+
"env_kinds": [
|
| 9 |
+
"files",
|
| 10 |
+
"exec"
|
| 11 |
+
]
|
| 12 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-1/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
openai>=1.0
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-2/.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
_harnessgrad/
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.pyc
|
| 5 |
+
.state/
|
| 6 |
+
*.bak
|
| 7 |
+
*.orig
|
| 8 |
+
*.rej
|
| 9 |
+
*~
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-2/agent.py
ADDED
|
@@ -0,0 +1,1491 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""The reference base harness: a minimal ReAct loop.
|
| 3 |
+
|
| 4 |
+
Deliberately the simplest thing that satisfies the contract in
|
| 5 |
+
`docs/writing_a_harness.md`. Its job is not to be strong -- it is to be:
|
| 6 |
+
|
| 7 |
+
1. a valid starting point that a method can improve, and
|
| 8 |
+
2. the proof that the contract is implementable at all.
|
| 9 |
+
|
| 10 |
+
A method may replace every file here. That is the point.
|
| 11 |
+
|
| 12 |
+
**What it ships, and why that changed.** This harness used to be a bare loop: no
|
| 13 |
+
context policy, no output bounding, no retries. That is still the design -- but
|
| 14 |
+
these mechanisms are now in it, and each is here because a measurement said the
|
| 15 |
+
bare loop could not be measured at all, not because a mechanism is nice to have:
|
| 16 |
+
|
| 17 |
+
* `PARSE_RETRIES`, `SUBMIT_RETRIES`, `FINISH_NUDGE_STEPS`, `REPEAT_NUDGE_LIMIT`
|
| 18 |
+
-- one unreadable reply, or one premature "I am done", used to end the whole
|
| 19 |
+
task. Measured: 73 of 266 runs reached the step cap with nothing submitted,
|
| 20 |
+
and one task died after exactly one model call.
|
| 21 |
+
* `OUTPUT_LIMIT`, `CONTEXT_CHAR_BUDGET` -- a command that printed a large file
|
| 22 |
+
left the next call over the model's context limit, which killed the task.
|
| 23 |
+
* line-buffered trace writes -- a block buffer meant a killed task lost its tail,
|
| 24 |
+
so "killed at step 30" and "never started" were the same record.
|
| 25 |
+
|
| 26 |
+
All of them are still named switches with an `HG_AGENT_*` override, so a method
|
| 27 |
+
may change or remove any of them; what a method adds *on top* is the measurement.
|
| 28 |
+
The values actually in force go into the trace (`harness_identity.config`, below)
|
| 29 |
+
and land on the curve point, because two runs of this same file at two different
|
| 30 |
+
step caps are two different harnesses and the file hash cannot tell them apart.
|
| 31 |
+
"""
|
| 32 |
+
from __future__ import annotations
|
| 33 |
+
|
| 34 |
+
import argparse
|
| 35 |
+
import json
|
| 36 |
+
import os
|
| 37 |
+
import re
|
| 38 |
+
import shutil
|
| 39 |
+
import subprocess
|
| 40 |
+
import sys
|
| 41 |
+
import time
|
| 42 |
+
from pathlib import Path
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
#: How many model calls one task gets. **A floor on capability, not a tuning knob.**
|
| 46 |
+
#:
|
| 47 |
+
#: Measured at 8, on Terminal-Bench, 4 rounds x 5 tasks: four of the five tasks used all
|
| 48 |
+
#: eight and produced no graded artifact at all -- `build-pmars` was still installing
|
| 49 |
+
#: packages, `bn-fit-modify` had just finished installing pandas/numpy/sklearn and
|
| 50 |
+
#: printed one correlation matrix, `chess-best-move` had opened the PNG and never wrote
|
| 51 |
+
#: `/app/move.txt`. The score was 0.0 on every task in every round, which is not a weak
|
| 52 |
+
#: harness being measured: it is a floor effect, and a floor makes every method look
|
| 53 |
+
#: identical because there is no gradient for one to move.
|
| 54 |
+
#:
|
| 55 |
+
#: Raising this does not make the harness cleverer -- `legacy/adapters/harnessgrad_domain/`
|
| 56 |
+
#: already names this lever as the trap ("helps only if the model is already using the
|
| 57 |
+
#: steps it has"). Here the trace shows it *was* using them, which is exactly when the
|
| 58 |
+
#: lever is legitimate. What it costs is bounded by the task, not by this number: the
|
| 59 |
+
#: wall clock is capped by the environment's `agent_timeout_s` (900 s for most
|
| 60 |
+
#: Terminal-Bench tasks, 3600 s for `bn-fit-modify`). A step is fast (~0.2 s model round
|
| 61 |
+
#: trip through the local gateway), so the extra ceiling mostly buys back the steps that
|
| 62 |
+
#: environment setup eats. The loop still stops the moment the model answers -- the cap
|
| 63 |
+
#: is a ceiling, not a quota.
|
| 64 |
+
MAX_STEPS = int(os.environ.get("HG_AGENT_MAX_STEPS", "32"))
|
| 65 |
+
MAX_OUTPUT_TOKENS = int(os.environ.get("HG_AGENT_MAX_OUTPUT_TOKENS", "2048"))
|
| 66 |
+
if MAX_OUTPUT_TOKENS < 1:
|
| 67 |
+
raise ValueError("HG_AGENT_MAX_OUTPUT_TOKENS must be positive")
|
| 68 |
+
|
| 69 |
+
#: Extra shell steps granted on top of the environment's **own** action budget.
|
| 70 |
+
#:
|
| 71 |
+
#: The failure this repairs is not "32 is too few": it is that the harness had a
|
| 72 |
+
#: global cap while the environment declares its own budget in the goal text
|
| 73 |
+
#: (`**50** steps`). A run could therefore spend 32 shell steps, of which only
|
| 74 |
+
#: some are environment actions, and be killed by the harness while the
|
| 75 |
+
#: environment still had most of its budget left. The cap is derived per task
|
| 76 |
+
#: from that declared number; the slack pays for the free commands (`alf look`)
|
| 77 |
+
#: and for the harness's own push-backs. It is not a tuning knob.
|
| 78 |
+
STEP_SLACK = int(os.environ.get("HG_AGENT_STEP_SLACK", "16"))
|
| 79 |
+
|
| 80 |
+
#: 模型说"我做完了"之后,允许它再被退回几次。
|
| 81 |
+
#:
|
| 82 |
+
#: 为什么需要这个:harness 以前**从不检查交付物**。模型回一句 {"answer": ...} 就被当成
|
| 83 |
+
#: 任务结束、退出循环。实测(2026-10-02,terminal_bench round 0):五道题的 agent 阶段是
|
| 84 |
+
#: 101s / 31s / 183s / **4.5s** / 105s —— 而步数上限是 32。4.5 秒等于一次模型调用就
|
| 85 |
+
#: "交卷"了,产物根本不存在;`cancel-async-tasks` 的判分因此是
|
| 86 |
+
#: `File /app/run.py does not exist`。
|
| 87 |
+
#:
|
| 88 |
+
#: 所以 0 分的机制不是"步数不够",而是"**harness 把模型说的完成当成了完成**"。
|
| 89 |
+
#: 一个会自己检查交付物、并把"文件不存在"退回给模型重试的 harness,才是这一步该有的样子。
|
| 90 |
+
SUBMIT_RETRIES = int(os.environ.get("HG_AGENT_SUBMIT_RETRIES", "2"))
|
| 91 |
+
|
| 92 |
+
#: 模型吐出一段**读不出动作**的回复之后,允许它再试几次。
|
| 93 |
+
#:
|
| 94 |
+
#: 和上面那条同源,方向相反:一条是"模型说做完了,但产物不在",一条是"模型说的话读不出
|
| 95 |
+
#: 动作"。两条以前都会让**整道题**结束。
|
| 96 |
+
#:
|
| 97 |
+
#: 为什么它必须由起点 harness 负责,而不是留给方法去发现 —— 这是数出来的,不是想出来的。
|
| 98 |
+
#: 统计所有跑道里"方法自己写了理由"的 35 个轮次:**16 个在修解析或格式容错**,而且几乎
|
| 99 |
+
#: 每条跑道的第一轮都在修它:
|
| 100 |
+
#:
|
| 101 |
+
#: `loop-terminal_bench-26452c` 五道题各只调了一次模型就死在
|
| 102 |
+
#: `parse_error: Extra data`(`calls: 1`),此后每一轮都从同一个不能用的 harness 出发;
|
| 103 |
+
#: `flash-three-1/2`、`deepseek-eigen-2`、`strong-model-1` 的第一/第二轮全都写成
|
| 104 |
+
#: "让一次读不懂的回复不再结束整道题"。
|
| 105 |
+
#:
|
| 106 |
+
#: 代价不只是浪费一轮。方法之间开始比"谁先想到修 parser":RRSI 的 leakage critic 两次把
|
| 107 |
+
#: 改 `_parse` 的候选判成 TASK-SPECIALIZATION / LEAKAGE 而拒绝,那一轮于是什么都没改。
|
| 108 |
+
#: 一个起点 harness 必须在被测量之前就活过一次跑题的回复,否则第一轮比较的不是解题能力,
|
| 109 |
+
#: 是管线运气。
|
| 110 |
+
PARSE_RETRIES = int(os.environ.get("HG_AGENT_PARSE_RETRIES", "2"))
|
| 111 |
+
|
| 112 |
+
#: 步数还剩这么多时,明确要求模型收尾。
|
| 113 |
+
#:
|
| 114 |
+
#: 数出来的,不是猜的:266 条历史轨迹里 **73 条(27%)跑满 32 步、一次都没交卷**,而那些
|
| 115 |
+
#: 轨迹的最后两步常常是同一条命令重复(抽样:`python /app/test_outputs.py 2>&1` 两次、
|
| 116 |
+
#: 同一条 `echo ... >` 两次、同一个 `cat > /app/run.py << 'EOF'` 两次)。那些任务不是
|
| 117 |
+
#: "做错了",是**没停下来交卷**:步数用完,`answer` 是空字符串,平台只能拿检查的判决当分数。
|
| 118 |
+
#: `improvers/skill.md` 早就把这条记成已知失败模式("预算用满、什么都没交"),但起点 harness
|
| 119 |
+
#: 一直没有对应动作。一个被测量的 harness 应该在预算耗尽前把话说完。
|
| 120 |
+
FINISH_NUDGE_STEPS = int(os.environ.get("HG_AGENT_FINISH_NUDGE_STEPS", "4"))
|
| 121 |
+
|
| 122 |
+
#: 同一条命令连续重复时提醒几次(每条跑道限量,免得把上下文塞满)。
|
| 123 |
+
REPEAT_NUDGE_LIMIT = int(os.environ.get("HG_AGENT_REPEAT_NUDGE_LIMIT", "2"))
|
| 124 |
+
|
| 125 |
+
#: 单条命令的输出进入消息历史时的字符上限。先压紧 JSON,再保留完整记录预览;
|
| 126 |
+
#: 纯文本留头尾。完整输出留在工作目录,模型可按需读取。
|
| 127 |
+
#:
|
| 128 |
+
#: 实测(2026-10-04,本地 9B,5 道题):**3 道题死于
|
| 129 |
+
#: `This model's maximum context length is 32768 tokens ... your prompt contains at least
|
| 130 |
+
#: 32769 input tokens`(BadRequestError 400)**。起点 harness 以前把每条命令的**完整**输出
|
| 131 |
+
#: 一直往历史里追加,永不截断:一道题里单条输出就有 11773 字符,装一次包、cat 一个大文件
|
| 132 |
+
#: 就够撞上 32k 的窗口。那不是模型的问题,是 harness 没有上下文管理。
|
| 133 |
+
OUTPUT_LIMIT = int(os.environ.get("HG_AGENT_OUTPUT_LIMIT", "4000"))
|
| 134 |
+
|
| 135 |
+
#: 消息历史(不含 system 与题面)的字符预算。按 4 字符 ≈ 1 token 粗估,60k 字符约 15k token,
|
| 136 |
+
#: 给 32k 窗口的模型留出输出空间。超了就丢**最旧的成对消息**,并在轨迹里记下丢了几条 ——
|
| 137 |
+
#: 一个悄悄改变模型所见历史的 harness,和一个被测量的 harness,不是同一件事。
|
| 138 |
+
CONTEXT_CHAR_BUDGET = int(os.environ.get("HG_AGENT_CONTEXT_CHARS", "60000"))
|
| 139 |
+
|
| 140 |
+
SYSTEM = """You are an agent solving a task in a working directory.
|
| 141 |
+
|
| 142 |
+
You have one tool: run a shell command.
|
| 143 |
+
|
| 144 |
+
Reply with EXACTLY one of:
|
| 145 |
+
{"tool": "bash", "command": "<shell command>"}
|
| 146 |
+
{"answer": "<your final answer>"}
|
| 147 |
+
|
| 148 |
+
For a structured final answer, "answer" may be a JSON object containing the task's
|
| 149 |
+
prediction fields.
|
| 150 |
+
|
| 151 |
+
Rules:
|
| 152 |
+
- One action per reply. No prose outside the JSON.
|
| 153 |
+
- Keep commands concise. Use a loop or a script instead of enumerating many calls.
|
| 154 |
+
- To inspect files use shell commands (ls, cat, grep, ...).
|
| 155 |
+
- Give the final answer only when you are confident.
|
| 156 |
+
"""
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
# ---------------------------------------------------------------- backends ---
|
| 160 |
+
|
| 161 |
+
def _backend() -> str:
|
| 162 |
+
"""Which completion backend to use.
|
| 163 |
+
|
| 164 |
+
`mock` exists so the framework can be exercised end-to-end with zero network
|
| 165 |
+
and zero cost. Any real curve must declare its backend and model on the curve
|
| 166 |
+
point (INTERFACE.md §3, `identity.agent_model`).
|
| 167 |
+
"""
|
| 168 |
+
return os.environ.get("HG_AGENT_BACKEND", "mock")
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def _call_mock(messages: list[dict]) -> str:
|
| 172 |
+
"""Deterministic stand-in: read answer.txt if present, else list the dir."""
|
| 173 |
+
task_text = messages[1]["content"] if len(messages) > 1 else ""
|
| 174 |
+
if "answer.txt exists" in task_text or "already" in task_text:
|
| 175 |
+
return json.dumps({"answer": "READ_FROM_FILE"})
|
| 176 |
+
return json.dumps({"tool": "bash", "command": "ls -a"})
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
# --------------------------------------------------------------- usage ---
|
| 180 |
+
|
| 181 |
+
#: Token usage accumulated over the run, filled by whichever backend is active.
|
| 182 |
+
#: Read into the trace at the end. Recorded because a mechanism that spends model
|
| 183 |
+
#: calls (history_summary does) is only comparable against a free one if the
|
| 184 |
+
#: spend is visible -- and because a harness whose cost is unknown cannot be
|
| 185 |
+
#: ranked against a cheaper one that scores the same.
|
| 186 |
+
#: `context_trims` 单独计数:它是"模型拒绝了这条 prompt,于是我们削短了历史"的次数。
|
| 187 |
+
#: 和 `retries`(网络/限流)不同 —— 那一种重试发的是同一条 prompt,这一种发的是**更短的**
|
| 188 |
+
#: 一条,模型看到的历史因此和上一步不同。要能分开,才能解释"那一步为什么换了做法"。
|
| 189 |
+
USAGE = {"calls": 0, "input_tokens": 0, "output_tokens": 0, "retries": 0,
|
| 190 |
+
"context_trims": 0}
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def _record_usage(usage) -> None:
|
| 194 |
+
"""Fold provider token counts into the run's total.
|
| 195 |
+
|
| 196 |
+
The call count is NOT incremented here: it is incremented by `_complete`,
|
| 197 |
+
which is the one place every model call goes through. Counting calls at the
|
| 198 |
+
provider boundary would miss the mock backend entirely -- and a mechanism that
|
| 199 |
+
spends model calls on a mock run would then report zero cost, which is exactly
|
| 200 |
+
the invisible-spend the usage block exists to prevent.
|
| 201 |
+
"""
|
| 202 |
+
if usage is None:
|
| 203 |
+
return
|
| 204 |
+
# Provider fields that are absent stay absent rather than becoming zero: a
|
| 205 |
+
# zero that means "not reported" is indistinguishable from a real zero.
|
| 206 |
+
for attr, key in (("prompt_tokens", "input_tokens"),
|
| 207 |
+
("completion_tokens", "output_tokens")):
|
| 208 |
+
v = getattr(usage, attr, None)
|
| 209 |
+
if isinstance(v, int):
|
| 210 |
+
USAGE[key] += v
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def _call_openai(messages: list[dict]) -> str:
|
| 214 |
+
"""One completion, with a deadline and bounded retries.
|
| 215 |
+
|
| 216 |
+
A harness that dies on a transient provider error loses a whole task run, and
|
| 217 |
+
an unbounded retry loop turns a provider outage into a hung experiment. Both
|
| 218 |
+
failures are silent in a batch unless the harness is defensive here.
|
| 219 |
+
"""
|
| 220 |
+
from openai import OpenAI
|
| 221 |
+
|
| 222 |
+
# **每次请求用一条新连接,不复用。** 不是性能取舍,是正确性:
|
| 223 |
+
#
|
| 224 |
+
# 实测(2026-10-02,容器内复现):vLLM 的 uvicorn 默认 5 秒关掉空闲 keep-alive,而
|
| 225 |
+
# 容器到模型之间还有平台发布的一层字节转发网关,它在上游 EOF 时会把 EOF 半关到
|
| 226 |
+
# 客户端。于是"跑一条几十秒的命令、再发起下一次模型调用"就必然复用一条死连接 ——
|
| 227 |
+
# `RemoteDisconnected` → openai 报 `APIConnectionError: Connection error`。
|
| 228 |
+
# 实测那一次,两道题(跑 pandas 的、跑 PIL 的)就是这样死的,而平台把它们记成了 0 分。
|
| 229 |
+
#
|
| 230 |
+
# keep-alive 本身是 HTTP 客户端的正常行为,所以这是网关的缺陷(见 eval/modelgate.py);
|
| 231 |
+
# 但一个 harness 不该把自己的测量押在"中间那一层是否正确处理空闲连接"上。一次本地
|
| 232 |
+
# TCP 握手的代价可以忽略。
|
| 233 |
+
#
|
| 234 |
+
# **用 `default_headers`,不要 import httpx。** 第一版写的是
|
| 235 |
+
# `http_client=httpx.Client(...)`,结果是每次调用都 `ModuleNotFoundError: No module
|
| 236 |
+
# named 'httpx'` —— 这个平台的 harness 依赖由覆盖层提供,而这里 `openai` 3.22.1 依赖的
|
| 237 |
+
# 是 `httpx2`(不是 `httpx`)。所以"顺手 import 一个我以为在的库"在这条路上是错的:
|
| 238 |
+
# 唯一可以依赖的是 `requirements.txt` 声明的那个发行包自己的接口。
|
| 239 |
+
client = OpenAI(
|
| 240 |
+
base_url=os.environ["HG_AGENT_BASE_URL"],
|
| 241 |
+
api_key=os.environ["HG_AGENT_API_KEY"],
|
| 242 |
+
timeout=float(os.environ.get("HG_AGENT_TIMEOUT_S", "180")),
|
| 243 |
+
max_retries=0, # retried here, so the count is ours to record
|
| 244 |
+
default_headers={"Connection": "close"},
|
| 245 |
+
)
|
| 246 |
+
model = os.environ["HG_AGENT_MODEL"]
|
| 247 |
+
attempts = int(os.environ.get("HG_AGENT_RETRIES", "3"))
|
| 248 |
+
last: Exception | None = None
|
| 249 |
+
|
| 250 |
+
for attempt in range(attempts):
|
| 251 |
+
try:
|
| 252 |
+
resp = client.chat.completions.create(
|
| 253 |
+
model=model, messages=messages, temperature=0.0,
|
| 254 |
+
max_tokens=MAX_OUTPUT_TOKENS,
|
| 255 |
+
)
|
| 256 |
+
_record_usage(getattr(resp, "usage", None))
|
| 257 |
+
return resp.choices[0].message.content or ""
|
| 258 |
+
except Exception as exc: # noqa: BLE001
|
| 259 |
+
last = exc
|
| 260 |
+
# **历史太长是可恢复的,以前不是。** 实测(2026-10-04):`git-leak-recovery` 和
|
| 261 |
+
# `regex-chess` 死在 `maximum context length is 32768 tokens ... at least 32769
|
| 262 |
+
# input tokens`,而两道题之前都已经跑了十几步的有效功。字符预算挡不住它
|
| 263 |
+
# (见 `_trim_history`),所以这里按模型自己的拒绝削一半历史再试一次 —— 削掉的
|
| 264 |
+
# 步数记进 `USAGE["context_trims"]`,由主循环写进 trace,不是悄悄改历史。
|
| 265 |
+
if any(marker in str(exc) for marker in _CONTEXT_ERROR_MARKERS) \
|
| 266 |
+
and len(messages) > 4 and attempt + 1 < attempts:
|
| 267 |
+
dropped = _trim_history(messages, budget=(CONTEXT_CHAR_BUDGET // 2))
|
| 268 |
+
if not dropped:
|
| 269 |
+
dropped = _trim_history(messages, budget=1)
|
| 270 |
+
USAGE["context_trims"] += 1
|
| 271 |
+
USAGE["retries"] += 1
|
| 272 |
+
continue
|
| 273 |
+
if attempt + 1 < attempts:
|
| 274 |
+
USAGE["retries"] += 1
|
| 275 |
+
time.sleep(min(2 ** attempt, 30))
|
| 276 |
+
# Out of attempts: raise, so the caller records a harness failure rather than
|
| 277 |
+
# scoring an empty answer as a wrong one.
|
| 278 |
+
raise RuntimeError(f"{attempts} attempts failed, last: {last}") from last
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def _complete(messages: list[dict]) -> str:
|
| 282 |
+
"""Every model call in this harness goes through here, so this is where the
|
| 283 |
+
count is kept. Counting anywhere else means some caller is invisible."""
|
| 284 |
+
USAGE["calls"] += 1
|
| 285 |
+
return _call_mock(messages) if _backend() == "mock" else _call_openai(messages)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
# ------------------------------------------------------------- the loop -----
|
| 289 |
+
|
| 290 |
+
class _Action(dict):
|
| 291 |
+
"""A parsed action, plus what the parser had to repair to get it.
|
| 292 |
+
|
| 293 |
+
An attribute rather than a second return value, because every caller wants the
|
| 294 |
+
dict and only one wants the repair note. `duplicates` empty means the reply was
|
| 295 |
+
well formed and nothing was guessed.
|
| 296 |
+
"""
|
| 297 |
+
duplicates: tuple[str, ...] = ()
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
def _first_key_wins(pairs):
|
| 301 |
+
"""Duplicated JSON keys: keep the **first** value, and say which keys repeated.
|
| 302 |
+
|
| 303 |
+
**This is measured, not defensive.** The local 9B (Qwen3.5-9B) writes a file like
|
| 304 |
+
this, and it is the whole reason `cancel-async-tasks` scored 0.0 in
|
| 305 |
+
`local-floor-9`:
|
| 306 |
+
|
| 307 |
+
{"tool": "bash", "command": "cat > /app/run.py << 'EOF'\n...\nEOF\n", "command": ""}
|
| 308 |
+
|
| 309 |
+
The real command is there, and then the model appends `, "command": ""`. JSON says
|
| 310 |
+
a duplicate key keeps the **last** value, so `json.loads` (and `raw_decode`) handed
|
| 311 |
+
the harness an empty command. The harness then ran the empty string -- exit 0, no
|
| 312 |
+
output -- and told the model `exit=0`. The model read that as success, answered
|
| 313 |
+
"the file /app/run.py has been created", and the verifier found no file. All 16
|
| 314 |
+
steps of that trajectory are the model writing the file, being told it worked, and
|
| 315 |
+
checking. Not one step of it wrote anything.
|
| 316 |
+
|
| 317 |
+
Taking the first value is the repair that matches intent here: the long command is
|
| 318 |
+
what the model meant, and the trailing `""` is noise from the same malformation
|
| 319 |
+
that produces its stray braces. It is recorded (`duplicate_keys` in the trace)
|
| 320 |
+
because a harness that silently rewrites the model's action and one that does not
|
| 321 |
+
are different harnesses.
|
| 322 |
+
"""
|
| 323 |
+
action = _Action()
|
| 324 |
+
repeated: list[str] = []
|
| 325 |
+
for key, value in pairs:
|
| 326 |
+
if key in action:
|
| 327 |
+
repeated.append(key)
|
| 328 |
+
continue
|
| 329 |
+
action[key] = value
|
| 330 |
+
if repeated:
|
| 331 |
+
action.duplicates = tuple(repeated)
|
| 332 |
+
return action
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
def _json_block_end(text: str, start: int) -> int:
|
| 336 |
+
"""Skip a malformed JSON block without treating its strings as actions."""
|
| 337 |
+
depth = 0
|
| 338 |
+
quoted = escaped = False
|
| 339 |
+
for i in range(start, len(text)):
|
| 340 |
+
ch = text[i]
|
| 341 |
+
if quoted:
|
| 342 |
+
if escaped:
|
| 343 |
+
escaped = False
|
| 344 |
+
elif ch == "\\":
|
| 345 |
+
escaped = True
|
| 346 |
+
elif ch == '"':
|
| 347 |
+
quoted = False
|
| 348 |
+
elif ch == '"':
|
| 349 |
+
quoted = True
|
| 350 |
+
elif ch in "{[":
|
| 351 |
+
depth += 1
|
| 352 |
+
elif ch in "}]":
|
| 353 |
+
depth -= 1
|
| 354 |
+
if depth == 0:
|
| 355 |
+
return i + 1
|
| 356 |
+
return len(text)
|
| 357 |
+
|
| 358 |
+
|
| 359 |
+
def _parse(reply: str) -> dict:
|
| 360 |
+
"""First complete action, across prose/fences and preceding structured data.
|
| 361 |
+
|
| 362 |
+
Consume whole JSON blocks, so nested data and quoted example actions cannot
|
| 363 |
+
become commands. Never close a truncated command or execute its prefix.
|
| 364 |
+
"""
|
| 365 |
+
decoder = json.JSONDecoder(object_pairs_hook=_first_key_wins)
|
| 366 |
+
i = 0
|
| 367 |
+
while i < len(reply):
|
| 368 |
+
if reply[i] not in "{[":
|
| 369 |
+
i += 1
|
| 370 |
+
continue
|
| 371 |
+
try:
|
| 372 |
+
obj, end = decoder.raw_decode(reply, i)
|
| 373 |
+
except json.JSONDecodeError:
|
| 374 |
+
i = _json_block_end(reply, i)
|
| 375 |
+
continue
|
| 376 |
+
i = end
|
| 377 |
+
if not isinstance(obj, dict) or obj.get("tool", "bash") != "bash":
|
| 378 |
+
continue
|
| 379 |
+
cmd = obj.get("command", "")
|
| 380 |
+
if isinstance(cmd, str) and cmd.strip():
|
| 381 |
+
return obj
|
| 382 |
+
if cmd == "" and "answer" in obj:
|
| 383 |
+
# An outer action can be valid JSON while its answer contains broken
|
| 384 |
+
# inner JSON. Reject it here so the ordinary parse retry can recover.
|
| 385 |
+
_answer_text(obj["answer"])
|
| 386 |
+
return obj
|
| 387 |
+
raise ValueError("no complete JSON action found in reply")
|
| 388 |
+
|
| 389 |
+
|
| 390 |
+
def _answer_text(value: object) -> str:
|
| 391 |
+
"""Transport a final answer without inventing or dropping prediction fields.
|
| 392 |
+
|
| 393 |
+
Schema validation belongs to the task's verifier. This only checks transport:
|
| 394 |
+
objects must stay JSON (str(dict) produces Python syntax), and JSON-looking
|
| 395 |
+
strings must be complete. Never close truncated JSON or reinterpret literals.
|
| 396 |
+
|
| 397 |
+
Scalars are transported as JSON too. Measured on this benchmark: after the
|
| 398 |
+
environment had already solved a task, the model answered `{"answer": true}`;
|
| 399 |
+
rejecting the boolean as "not a string or dict" burned both parse retries and
|
| 400 |
+
ended the run in a parse error. No verifier reads the answer here -- the
|
| 401 |
+
actions do -- so refusing a perfectly well-formed scalar is a harness bug.
|
| 402 |
+
"""
|
| 403 |
+
if isinstance(value, (str,)):
|
| 404 |
+
if value.lstrip().startswith("{"):
|
| 405 |
+
try:
|
| 406 |
+
json.loads(value)
|
| 407 |
+
except ValueError as exc:
|
| 408 |
+
raise ValueError(f"final answer contains malformed JSON: {exc}") from exc
|
| 409 |
+
return value
|
| 410 |
+
if isinstance(value, (dict, list, bool, int, float)) or value is None:
|
| 411 |
+
return json.dumps(value, ensure_ascii=False, allow_nan=False)
|
| 412 |
+
raise ValueError("final answer must be JSON-transportable")
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
#: goal 里形如 `/app/move.txt`、`/app/learned_dag.csv` 的路径。这是**通用**的:
|
| 416 |
+
#: 它不针对任何一道题,只看题面自己说了要写到哪个文件。
|
| 417 |
+
_PATH_RE = __import__("re").compile(r"/[A-Za-z0-9_./-]+\.[A-Za-z0-9]{1,6}\b")
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
def _missing_deliverables(task: dict, workdir: Path) -> list[str]:
|
| 421 |
+
"""题面点名要写、但现在**不存在**的文件。
|
| 422 |
+
|
| 423 |
+
这是 `loop` 自带的交卷闸门,刻意做成通用的两条:
|
| 424 |
+
|
| 425 |
+
* 只看题面(goal)里写出来的绝对路径 —— harness 没有任何途径知道判分脚本要什么
|
| 426 |
+
(`task.json` 里只有 goal),所以它只能相信题面;
|
| 427 |
+
* 只做 `exists` 检查,不执行任何东西。
|
| 428 |
+
|
| 429 |
+
题面没提路径(比如"回答一个问题")时返回空列表,闸门不生效 —— 这时判断对错是平台
|
| 430 |
+
的事,harness 不该假装知道。
|
| 431 |
+
"""
|
| 432 |
+
goal = str(task.get("goal") or "")
|
| 433 |
+
wanted = {m for m in _PATH_RE.findall(goal)}
|
| 434 |
+
missing = []
|
| 435 |
+
for raw in sorted(wanted):
|
| 436 |
+
# 容器里绝对路径就是它自己;宿主上则落在 workdir 之内。两种都查,取存在的那个。
|
| 437 |
+
candidates = [Path(raw)]
|
| 438 |
+
try:
|
| 439 |
+
candidates.append(workdir / Path(raw).relative_to("/app"))
|
| 440 |
+
except ValueError:
|
| 441 |
+
pass
|
| 442 |
+
if not any(c.exists() for c in candidates):
|
| 443 |
+
missing.append(raw)
|
| 444 |
+
return missing
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
# ------------------------------------------------- the environment's state ---
|
| 448 |
+
#
|
| 449 |
+
# The tasks in this benchmark are not file-editing tasks: they are a text
|
| 450 |
+
# environment (`python3 alf ...`) whose *own* output already carries the whole
|
| 451 |
+
# ground truth -- the step counter, whether the goal is solved, what is in every
|
| 452 |
+
# container, what the agent holds, and what has been cleaned/cooled/heated/placed.
|
| 453 |
+
# The harness used to append that output raw and throw the structure away. A 9B
|
| 454 |
+
# model then had to reconstruct "I have the bowl, I cleaned it, but I still have
|
| 455 |
+
# not put it in the fridge" from forty blocks of prose, and measured on 100 ALF
|
| 456 |
+
# tasks it did not: 47 runs were unsolved, and the failure was not ignorance --
|
| 457 |
+
# the target object had already been seen in 23 of them, and 30 of them declared
|
| 458 |
+
# `alf done` while the environment still printed `in progress`.
|
| 459 |
+
#
|
| 460 |
+
# So the loop now reads the environment's own report and gives it back compactly:
|
| 461 |
+
# the goal, the env step, what is held/processed/placed, and the one action that
|
| 462 |
+
# is next. That is context policy (skill item 3), not a new prompt constant.
|
| 463 |
+
|
| 464 |
+
_ALF_STEP_RE = re.compile(
|
| 465 |
+
r"\[alf\] step (\d+)/(\d+); (SOLVED|in progress|episode over)")
|
| 466 |
+
_ALF_OBJ_RE = re.compile(r"\b(?:a|an) ([a-z]+) (\d+)\b")
|
| 467 |
+
_ALF_DONE_RE = re.compile(r"\balf\s+done\b")
|
| 468 |
+
_ALF_DO_RE = re.compile(r"\balf\s+do\b")
|
| 469 |
+
|
| 470 |
+
#: Fixtures whose contents are only visible after an `open` action. `cart` is
|
| 471 |
+
#: deliberately NOT here: the environment shows its contents on arrival (the
|
| 472 |
+
#: traces have "go to cart 1 / On the cart 1, you see ..."), and suggesting
|
| 473 |
+
#: `open cart 1` costs an environment step for nothing.
|
| 474 |
+
_ALF_OPENABLE = frozenset({"cabinet", "drawer", "fridge", "microwave", "safe"})
|
| 475 |
+
_ALF_APPLIANCE = {"clean": "sinkbasin", "cool": "fridge",
|
| 476 |
+
"heat": "microwave", "light": "desklamp"}
|
| 477 |
+
|
| 478 |
+
#: Search order when the target has not been seen yet.
|
| 479 |
+
#:
|
| 480 |
+
#: Measured on the 100 incumbent ALF traces: 88 of the 99 targets whose first
|
| 481 |
+
#: location could be recovered were on a directly inspectable surface and only
|
| 482 |
+
#: 11 were inside an openable container. The old order was alphabetical, so it
|
| 483 |
+
#: visited every cabinet (two environment steps each: go, then open) before the
|
| 484 |
+
#: first countertop -- e.g. `pick_cool_then_place_in_recep-Potato-...` spent 40
|
| 485 |
+
#: of its 50 actions on closed cabinets before reaching the garbagecan holding
|
| 486 |
+
#: the potato, and `pick_clean_...-Apple-...` found the apple in the microwave
|
| 487 |
+
#: at env step 49 and had nothing left to clean or place it. Ordering by the
|
| 488 |
+
#: environment's own cost model (a surface costs one step, an openable container
|
| 489 |
+
#: costs two) and by how often each surface holds the goal object is the
|
| 490 |
+
#: exploration-policy repair, not a per-task hint.
|
| 491 |
+
_ALF_SURFACE_ORDER = (
|
| 492 |
+
"countertop", "diningtable", "desk", "bed", "dresser", "sidetable",
|
| 493 |
+
"shelf", "coffeemachine", "armchair", "handtowelholder", "garbagecan",
|
| 494 |
+
"toilet", "bathtubbasin", "stoveburner", "coffeetable", "sofa", "cart",
|
| 495 |
+
"toaster", "sinkbasin",
|
| 496 |
+
)
|
| 497 |
+
#: Openable containers: the one-instance appliance containers first (cheap to
|
| 498 |
+
#: exhaust, and they are plausible sources for a cool/heat goal object), then
|
| 499 |
+
#: the numerous bulk containers.
|
| 500 |
+
_ALF_OPENABLE_ORDER = ("fridge", "microwave", "safe", "cabinet", "drawer")
|
| 501 |
+
|
| 502 |
+
|
| 503 |
+
def _obj_base(obj: str) -> str:
|
| 504 |
+
return obj.split()[0].lower()
|
| 505 |
+
|
| 506 |
+
|
| 507 |
+
def _alf_mission(task: dict) -> dict | None:
|
| 508 |
+
"""Read target / destination / required state / budget from the goal prose.
|
| 509 |
+
|
| 510 |
+
ALFWorld goals have a fixed shape (`put a cool bowl in diningtable`,
|
| 511 |
+
`examine the book with the desklamp`). The words are the platform's own task
|
| 512 |
+
text, not a hard-coded object list; deriving them lets the harness repeat the
|
| 513 |
+
goal back to a small model instead of hoping it re-reads the system prompt.
|
| 514 |
+
Returns None for non-environment tasks, which leaves the generic loop alone.
|
| 515 |
+
"""
|
| 516 |
+
goal = str(task.get("goal") or "")
|
| 517 |
+
blob = goal + " " + str(task.get("initial_state") or "")
|
| 518 |
+
if "alf" not in blob.lower():
|
| 519 |
+
return None
|
| 520 |
+
m = re.search(r"Your task is to:\s*(.+?)(?:\n|\*\*|$)", goal, re.S)
|
| 521 |
+
if not m:
|
| 522 |
+
return None
|
| 523 |
+
raw = m.group(1).strip().strip("*").strip().rstrip(".").strip()
|
| 524 |
+
if not raw:
|
| 525 |
+
return None
|
| 526 |
+
low = raw.lower()
|
| 527 |
+
|
| 528 |
+
target = None
|
| 529 |
+
mt = re.search(r"\b(?:put|find)\s+(?:a|an|some|two|the)\s+"
|
| 530 |
+
r"(?:(?:clean|cool|hot|cold|warm)\s+)?([a-z]+)", low)
|
| 531 |
+
if not mt:
|
| 532 |
+
mt = re.search(r"\b(?:clean|cool|heat)\s+(?:a|an|some|two|the)\s+([a-z]+)", low)
|
| 533 |
+
if not mt:
|
| 534 |
+
mt = re.search(r"\b(?:examine|look at)\s+(?:the\s+)?([a-z]+)", low)
|
| 535 |
+
if mt:
|
| 536 |
+
target = mt.group(1)
|
| 537 |
+
if not target:
|
| 538 |
+
return None
|
| 539 |
+
|
| 540 |
+
kind = None
|
| 541 |
+
if "desklamp" in low:
|
| 542 |
+
kind, dest = "light", "desklamp"
|
| 543 |
+
else:
|
| 544 |
+
if re.search(r"\bclean\b", low):
|
| 545 |
+
kind = "clean"
|
| 546 |
+
elif re.search(r"\bcool\b|\bcold\b", low):
|
| 547 |
+
kind = "cool"
|
| 548 |
+
elif re.search(r"\bheat\b|\bhot\b", low):
|
| 549 |
+
kind = "heat"
|
| 550 |
+
md = re.search(r"\b(?:in|on|to)\s+(?:the\s+)?([a-z]+)\s*$", low)
|
| 551 |
+
dest = md.group(1) if md else None
|
| 552 |
+
if not dest:
|
| 553 |
+
return None
|
| 554 |
+
|
| 555 |
+
budget = None
|
| 556 |
+
for pat in (r"\*\*(\d+)\*\*\s+steps", r"(\d+)[- ]step budget",
|
| 557 |
+
r"budget of (\d+)", r"within the (\d+)"):
|
| 558 |
+
mb = re.search(pat, goal, re.I)
|
| 559 |
+
if mb:
|
| 560 |
+
budget = int(mb.group(1))
|
| 561 |
+
break
|
| 562 |
+
# The verifier's own `--budget` is authoritative: it is what the replay
|
| 563 |
+
# enforces, so the harness cap must be derived from it rather than guessed
|
| 564 |
+
# from prose when both are present.
|
| 565 |
+
try:
|
| 566 |
+
argv = (task.get("verifier") or {}).get("argv") or []
|
| 567 |
+
for i, arg in enumerate(argv):
|
| 568 |
+
if arg == "--budget" and i + 1 < len(argv):
|
| 569 |
+
budget = int(argv[i + 1])
|
| 570 |
+
break
|
| 571 |
+
except (TypeError, ValueError):
|
| 572 |
+
pass
|
| 573 |
+
if budget is None or budget < 1:
|
| 574 |
+
budget = 50
|
| 575 |
+
|
| 576 |
+
count = 2 if re.search(r"\btwo\b", low) else 1
|
| 577 |
+
return {"raw": raw, "target": target, "dest": dest, "kind": kind,
|
| 578 |
+
"count": count, "budget": budget}
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
class _AlfState:
|
| 582 |
+
"""Fold the environment's text into progress and the next required action."""
|
| 583 |
+
|
| 584 |
+
def __init__(self, mission: dict | None):
|
| 585 |
+
self.mission = mission
|
| 586 |
+
self.loc: str | None = None
|
| 587 |
+
self.objects: dict[str, str] = {} # object -> fixture it was last seen in
|
| 588 |
+
self.saw: dict[str, str] = {} # object -> fixture (never forgotten)
|
| 589 |
+
self.fixtures: dict[str, set[str]] = {}
|
| 590 |
+
self.held: set[str] = set()
|
| 591 |
+
self.transformed: dict[str, set[str]] = {}
|
| 592 |
+
self.moved_to: dict[str, str] = {}
|
| 593 |
+
self.placed: set[str] = set()
|
| 594 |
+
self.open: set[str] = set()
|
| 595 |
+
self.searched: set[str] = set()
|
| 596 |
+
self.visited: set[str] = set()
|
| 597 |
+
self.lamp_on = False
|
| 598 |
+
self.step = 0
|
| 599 |
+
self.budget = mission["budget"] if mission else 0
|
| 600 |
+
self.solved = False
|
| 601 |
+
self.invalid = False
|
| 602 |
+
self.last_cmd = ""
|
| 603 |
+
self.admissible: set[str] = set()
|
| 604 |
+
|
| 605 |
+
def observe(self, out: str, cmd: str = "") -> None:
|
| 606 |
+
self.last_cmd = cmd
|
| 607 |
+
self.invalid = "Nothing happens." in out if out else False
|
| 608 |
+
if not out:
|
| 609 |
+
return
|
| 610 |
+
if "SOLVED" in out:
|
| 611 |
+
self.solved = True
|
| 612 |
+
for m in _ALF_STEP_RE.finditer(out):
|
| 613 |
+
self.step = int(m.group(1))
|
| 614 |
+
self.budget = int(m.group(2))
|
| 615 |
+
if m.group(3) == "SOLVED":
|
| 616 |
+
self.solved = True
|
| 617 |
+
legal = re.search(r"Admissible actions:\s*\n(.*?)(?:\n\[alf\]|\Z)", out, re.S)
|
| 618 |
+
if legal:
|
| 619 |
+
self.admissible = {line.strip() for line in legal.group(1).splitlines()
|
| 620 |
+
if line.strip()}
|
| 621 |
+
for m in re.finditer(r"You (?:arrive at|are facing the|are at) ([a-z]+ \d+)", out):
|
| 622 |
+
self.loc = m.group(1)
|
| 623 |
+
self.visited.add(self.loc)
|
| 624 |
+
for m in re.finditer(r"The ([a-z]+ \d+) is (open|closed)", out):
|
| 625 |
+
if m.group(2) == "open":
|
| 626 |
+
self.open.add(m.group(1))
|
| 627 |
+
else:
|
| 628 |
+
self.open.discard(m.group(1))
|
| 629 |
+
for m in re.finditer(r"You open the ([a-z]+ \d+)", out):
|
| 630 |
+
self.open.add(m.group(1))
|
| 631 |
+
room = re.search(r"Looking quickly around you, you see (.*?)\.", out, re.S)
|
| 632 |
+
if room:
|
| 633 |
+
for m in re.finditer(r"\b([a-z]+) (\d+)\b", room.group(1)):
|
| 634 |
+
self.fixtures.setdefault(m.group(1), set()).add(f"{m.group(1)} {m.group(2)}")
|
| 635 |
+
for m in re.finditer(r"(?:On|In) the ([a-z]+ \d+), you see ([^.]*)\.", out):
|
| 636 |
+
self._add_objects(m.group(1), m.group(2))
|
| 637 |
+
if self.loc:
|
| 638 |
+
for m in re.finditer(r"In it, you see ([^.]*)\.", out):
|
| 639 |
+
self._add_objects(self.loc, m.group(1))
|
| 640 |
+
for m in re.finditer(r"You pick up the ([a-z]+ \d+) from the ([a-z]+ \d+)", out):
|
| 641 |
+
obj, loc = m.group(1), m.group(2)
|
| 642 |
+
self.held.add(obj)
|
| 643 |
+
self.objects.pop(obj, None)
|
| 644 |
+
self.saw[obj] = loc
|
| 645 |
+
self.searched.add(loc)
|
| 646 |
+
for m in re.finditer(r"You move the ([a-z]+ \d+) to the ([a-z]+ \d+)", out):
|
| 647 |
+
obj, loc = m.group(1), m.group(2)
|
| 648 |
+
self.held.discard(obj)
|
| 649 |
+
self.moved_to[obj] = loc
|
| 650 |
+
self.objects[obj] = loc
|
| 651 |
+
self.saw[obj] = loc
|
| 652 |
+
if self._is_dest(loc):
|
| 653 |
+
self.placed.add(obj)
|
| 654 |
+
for m in re.finditer(r"You (clean|cool|heat) the ([a-z]+ \d+) "
|
| 655 |
+
r"using the ([a-z]+ \d+)", out):
|
| 656 |
+
self.transformed.setdefault(m.group(2), set()).add(m.group(1))
|
| 657 |
+
for m in re.finditer(r"You turn on the ([a-z]+ \d+)", out):
|
| 658 |
+
if _obj_base(m.group(1)) == "desklamp":
|
| 659 |
+
self.lamp_on = True
|
| 660 |
+
if "You are not carrying anything." in out:
|
| 661 |
+
self.held.clear()
|
| 662 |
+
|
| 663 |
+
def _add_objects(self, loc: str, text: str) -> None:
|
| 664 |
+
# Seeing the contents means the fixture is open/accessible; that is how
|
| 665 |
+
# ALFWorld reports a drawer/cabinet that was never explicitly opened.
|
| 666 |
+
self.open.add(loc)
|
| 667 |
+
self.searched.add(loc)
|
| 668 |
+
for m in _ALF_OBJ_RE.finditer(text):
|
| 669 |
+
obj = f"{m.group(1)} {m.group(2)}"
|
| 670 |
+
self.objects[obj] = loc
|
| 671 |
+
self.saw[obj] = loc
|
| 672 |
+
|
| 673 |
+
def _is_dest(self, loc: str) -> bool:
|
| 674 |
+
return bool(loc and self.mission and _obj_base(loc) == self.mission["dest"])
|
| 675 |
+
|
| 676 |
+
def _completed(self) -> set[str]:
|
| 677 |
+
"""Targets actually done: placed at the destination *and* processed.
|
| 678 |
+
|
| 679 |
+
Measured: several failing runs moved an unprocessed object to the goal
|
| 680 |
+
location (an egg to the countertop without cooling it, a soapbar to the
|
| 681 |
+
cart without cleaning it). Counting a raw `move` as completion made the
|
| 682 |
+
progress helper stop guiding exactly one action early.
|
| 683 |
+
"""
|
| 684 |
+
kind = self.mission["kind"] if self.mission else None
|
| 685 |
+
return {o for o in self.placed
|
| 686 |
+
if not kind or kind in self.transformed.get(o, ())}
|
| 687 |
+
|
| 688 |
+
def _fixture(self, kind: str) -> str | None:
|
| 689 |
+
want = _ALF_APPLIANCE[kind]
|
| 690 |
+
if self.loc and _obj_base(self.loc) == want:
|
| 691 |
+
return self.loc
|
| 692 |
+
seen = set(self.fixtures.get(want) or ())
|
| 693 |
+
if not seen:
|
| 694 |
+
seen = {o for o in self.saw if _obj_base(o) == want}
|
| 695 |
+
if not seen:
|
| 696 |
+
return f"{want} 1"
|
| 697 |
+
return sorted(seen, key=lambda s: (s.split()[0], int(s.split()[1])))[0]
|
| 698 |
+
|
| 699 |
+
def _dest(self) -> str | None:
|
| 700 |
+
want = self.mission["dest"]
|
| 701 |
+
if self.loc and _obj_base(self.loc) == want:
|
| 702 |
+
return self.loc
|
| 703 |
+
seen = set(self.fixtures.get(want) or ())
|
| 704 |
+
if not seen:
|
| 705 |
+
seen = {o for o in self.saw if _obj_base(o) == want}
|
| 706 |
+
if seen:
|
| 707 |
+
return sorted(seen, key=lambda s: (s.split()[0], int(s.split()[1])))[0]
|
| 708 |
+
return f"{want} 1"
|
| 709 |
+
|
| 710 |
+
def _lamp(self) -> tuple[str | None, str | None]:
|
| 711 |
+
"""The desklamp is an object on a surface, not a navigable location."""
|
| 712 |
+
lamps = sorted(o for o in self.saw if _obj_base(o) == "desklamp")
|
| 713 |
+
for lamp in lamps:
|
| 714 |
+
if self.saw.get(lamp) == self.loc:
|
| 715 |
+
return lamp, self.loc
|
| 716 |
+
if lamps:
|
| 717 |
+
lamp = lamps[0]
|
| 718 |
+
return lamp, self.saw.get(lamp)
|
| 719 |
+
return None, None
|
| 720 |
+
|
| 721 |
+
def _legal(self, step: str) -> bool:
|
| 722 |
+
"""The environment prints the legal actions; never suggest one outside them.
|
| 723 |
+
|
| 724 |
+
The trace replays what actually ran, so an illegal suggestion costs a real
|
| 725 |
+
environment step ("Nothing happens.") for nothing. Measured over all 100
|
| 726 |
+
incumbent traces, the planner's raw suggestion was outside the printed
|
| 727 |
+
admissible list 105 times; most were `go to X` for a fixture that was
|
| 728 |
+
already accessible, or `open X` for a drawer that was already open.
|
| 729 |
+
"""
|
| 730 |
+
return not self.admissible or step in self.admissible
|
| 731 |
+
|
| 732 |
+
def _takeable_target(self) -> str | None:
|
| 733 |
+
base = self.mission["target"]
|
| 734 |
+
done = self._completed()
|
| 735 |
+
# The environment may expose a target in an already-open container
|
| 736 |
+
# without a separate `go to`; trust its own take action over our map.
|
| 737 |
+
for act in sorted(self.admissible):
|
| 738 |
+
parts = act.split()
|
| 739 |
+
if len(parts) >= 3 and parts[0] == "take" and parts[1] == base \
|
| 740 |
+
and f"{parts[1]} {parts[2]}" not in done:
|
| 741 |
+
return act
|
| 742 |
+
here = sorted(o for o, loc in self.objects.items()
|
| 743 |
+
if _obj_base(o) == base and loc == self.loc and o not in done)
|
| 744 |
+
if here:
|
| 745 |
+
step = f"take {here[0]} from {self.loc}"
|
| 746 |
+
if not self._fail(step) and self._legal(step):
|
| 747 |
+
return step
|
| 748 |
+
seen = sorted(((o, loc) for o, loc in self.saw.items()
|
| 749 |
+
if _obj_base(o) == base and o not in done
|
| 750 |
+
and o not in self.held), key=lambda x: x[1])
|
| 751 |
+
if seen:
|
| 752 |
+
obj, loc = seen[0]
|
| 753 |
+
if loc == self.loc:
|
| 754 |
+
step = f"take {obj} from {loc}"
|
| 755 |
+
return step if not self._fail(step) and self._legal(step) else None
|
| 756 |
+
step = f"go to {loc}"
|
| 757 |
+
return step if not self._fail(step) and self._legal(step) else None
|
| 758 |
+
return None
|
| 759 |
+
|
| 760 |
+
def _fail(self, step: str) -> bool:
|
| 761 |
+
"""True when this exact step just produced 'Nothing happens.'"""
|
| 762 |
+
return bool(self.invalid and step in self.last_cmd)
|
| 763 |
+
|
| 764 |
+
@staticmethod
|
| 765 |
+
def _fixture_index(inst: str) -> int:
|
| 766 |
+
try:
|
| 767 |
+
return int(inst.rsplit(" ", 1)[1])
|
| 768 |
+
except (IndexError, ValueError):
|
| 769 |
+
return 0
|
| 770 |
+
|
| 771 |
+
def _search_key(self, inst: str) -> tuple[int, int, int]:
|
| 772 |
+
"""Rank a fixture for the exploration order.
|
| 773 |
+
|
| 774 |
+
Tiers, not a magic constant: directly inspectable surfaces cost one
|
| 775 |
+
environment step, openable containers cost two, and the frequency order
|
| 776 |
+
encodes which surfaces the environment's object placements actually
|
| 777 |
+
favour. Unknown fixture types go last but are still searched.
|
| 778 |
+
"""
|
| 779 |
+
base = _obj_base(inst)
|
| 780 |
+
idx = self._fixture_index(inst)
|
| 781 |
+
if base in _ALF_SURFACE_ORDER:
|
| 782 |
+
return (0, _ALF_SURFACE_ORDER.index(base), idx)
|
| 783 |
+
if base in _ALF_OPENABLE_ORDER:
|
| 784 |
+
return (1, _ALF_OPENABLE_ORDER.index(base), idx)
|
| 785 |
+
return (2, 0, idx)
|
| 786 |
+
|
| 787 |
+
def _search_step(self) -> str | None:
|
| 788 |
+
"""A systematic next move when the target has not been seen yet."""
|
| 789 |
+
if self.loc and _obj_base(self.loc) in _ALF_OPENABLE and self.loc not in self.open:
|
| 790 |
+
step = f"open {self.loc}"
|
| 791 |
+
if not self._fail(step) and self._legal(step):
|
| 792 |
+
return step
|
| 793 |
+
unseen = [inst for typ, insts in self.fixtures.items() if typ != "desklamp"
|
| 794 |
+
for inst in insts if inst not in self.visited]
|
| 795 |
+
unseen.sort(key=self._search_key)
|
| 796 |
+
for inst in unseen:
|
| 797 |
+
step = f"go to {inst}"
|
| 798 |
+
if not self._fail(step) and self._legal(step):
|
| 799 |
+
return step
|
| 800 |
+
closed = [inst for typ in _ALF_OPENABLE
|
| 801 |
+
for inst in (self.fixtures.get(typ) or ()) if inst not in self.open]
|
| 802 |
+
closed.sort(key=self._search_key)
|
| 803 |
+
for inst in closed:
|
| 804 |
+
step = f"go to {inst}" if self.loc != inst else f"open {inst}"
|
| 805 |
+
if not self._fail(step) and self._legal(step):
|
| 806 |
+
return step
|
| 807 |
+
return None
|
| 808 |
+
|
| 809 |
+
def _held_other(self) -> list[str]:
|
| 810 |
+
"""Objects in hand that are not the goal object."""
|
| 811 |
+
if not self.mission:
|
| 812 |
+
return []
|
| 813 |
+
base = self.mission["target"]
|
| 814 |
+
return sorted(o for o in self.held if _obj_base(o) != base)
|
| 815 |
+
|
| 816 |
+
def _release_step(self) -> str | None:
|
| 817 |
+
"""Put down a wrong object so the target can be taken.
|
| 818 |
+
|
| 819 |
+
Measured (`pick_cool_then_place_in_recep-Pot-None-CounterTop-17`): the
|
| 820 |
+
model picked up a kettle on the way. `next_action` then alternated
|
| 821 |
+
forever between `go to stoveburner 1` (where the pot was visible) and
|
| 822 |
+
`go to <next unseen fixture>`, because the take was not admissible with
|
| 823 |
+
full hands, and burned the remaining 26 environment steps. The
|
| 824 |
+
environment's own admissible list already names the legal placement
|
| 825 |
+
(`move kettle 2 to cabinet 14`), so use it.
|
| 826 |
+
"""
|
| 827 |
+
others = self._held_other()
|
| 828 |
+
if not others:
|
| 829 |
+
return None
|
| 830 |
+
obj = others[0]
|
| 831 |
+
for act in sorted(self.admissible):
|
| 832 |
+
if act.startswith(f"move {obj} "):
|
| 833 |
+
return act
|
| 834 |
+
if self.loc:
|
| 835 |
+
step = f"move {obj} to {self.loc}"
|
| 836 |
+
if not self._fail(step) and self._legal(step):
|
| 837 |
+
return step
|
| 838 |
+
return None
|
| 839 |
+
|
| 840 |
+
def next_action(self) -> str | None:
|
| 841 |
+
if not self.mission or self.solved:
|
| 842 |
+
return None
|
| 843 |
+
m = self.mission
|
| 844 |
+
base = m["target"]
|
| 845 |
+
held = sorted(o for o in self.held if _obj_base(o) == base)
|
| 846 |
+
placed = sorted(o for o in self._completed() if _obj_base(o) == base)
|
| 847 |
+
|
| 848 |
+
release = self._release_step()
|
| 849 |
+
if release:
|
| 850 |
+
return release
|
| 851 |
+
|
| 852 |
+
if m["kind"] == "light":
|
| 853 |
+
lamp, lamp_loc = self._lamp()
|
| 854 |
+
if not self.lamp_on:
|
| 855 |
+
if lamp and lamp_loc == self.loc:
|
| 856 |
+
step = f"use {lamp}"
|
| 857 |
+
if not self._fail(step):
|
| 858 |
+
return step
|
| 859 |
+
# Acquire the target before a long trip to a lamp, unless the
|
| 860 |
+
# lamp is already in this room.
|
| 861 |
+
if not held:
|
| 862 |
+
step = self._takeable_target()
|
| 863 |
+
if step:
|
| 864 |
+
return step
|
| 865 |
+
if lamp_loc:
|
| 866 |
+
step = f"go to {lamp_loc}"
|
| 867 |
+
if not self._fail(step):
|
| 868 |
+
return step
|
| 869 |
+
return self._search_step()
|
| 870 |
+
if not held:
|
| 871 |
+
return self._takeable_target() or self._search_step()
|
| 872 |
+
# A held target with a lamp already on should satisfy the check; if
|
| 873 |
+
# it has not fired, examine the held object while at the lamp, which
|
| 874 |
+
# is the other admissible action for "look at X in the light".
|
| 875 |
+
if lamp and lamp_loc == self.loc:
|
| 876 |
+
return f"examine {held[0]}"
|
| 877 |
+
if lamp_loc:
|
| 878 |
+
step = f"go to {lamp_loc}"
|
| 879 |
+
if not self._fail(step):
|
| 880 |
+
return step
|
| 881 |
+
return None
|
| 882 |
+
|
| 883 |
+
if len(placed) < m["count"]:
|
| 884 |
+
if held:
|
| 885 |
+
obj = held[0]
|
| 886 |
+
if m["kind"] and m["kind"] not in self.transformed.get(obj, ()):
|
| 887 |
+
app = self._fixture(m["kind"])
|
| 888 |
+
if app and self.loc != app:
|
| 889 |
+
step = f"go to {app}"
|
| 890 |
+
if not self._fail(step):
|
| 891 |
+
return step
|
| 892 |
+
if app and app not in self.open and _obj_base(app) in _ALF_OPENABLE:
|
| 893 |
+
step = f"open {app}"
|
| 894 |
+
if not self._fail(step):
|
| 895 |
+
return step
|
| 896 |
+
if app:
|
| 897 |
+
step = f"{m['kind']} {obj} with {app}"
|
| 898 |
+
if not self._fail(step):
|
| 899 |
+
return step
|
| 900 |
+
dest = self._dest()
|
| 901 |
+
if dest and self.loc != dest:
|
| 902 |
+
step = f"go to {dest}"
|
| 903 |
+
if not self._fail(step):
|
| 904 |
+
return step
|
| 905 |
+
if dest and dest not in self.open and _obj_base(dest) in _ALF_OPENABLE:
|
| 906 |
+
step = f"open {dest}"
|
| 907 |
+
if not self._fail(step):
|
| 908 |
+
return step
|
| 909 |
+
if dest:
|
| 910 |
+
step = f"move {obj} to {dest}"
|
| 911 |
+
if not self._fail(step):
|
| 912 |
+
return step
|
| 913 |
+
else:
|
| 914 |
+
return self._takeable_target() or self._search_step()
|
| 915 |
+
return None
|
| 916 |
+
|
| 917 |
+
def _legal_fallback(self, step: str) -> str | None:
|
| 918 |
+
"""A legal action with the same purpose when the exact step is not listed."""
|
| 919 |
+
if self._legal(step):
|
| 920 |
+
return step
|
| 921 |
+
if not self.admissible or not self.mission:
|
| 922 |
+
return None
|
| 923 |
+
m = self.mission
|
| 924 |
+
base = m["target"]
|
| 925 |
+
verb = step.split()[0] if step else ""
|
| 926 |
+
held = [o for o in self.held if _obj_base(o) == base]
|
| 927 |
+
if verb == "take":
|
| 928 |
+
for act in sorted(self.admissible):
|
| 929 |
+
parts = act.split()
|
| 930 |
+
if len(parts) >= 2 and parts[0] == "take" and parts[1] == base:
|
| 931 |
+
return act
|
| 932 |
+
return None
|
| 933 |
+
if verb == "move" and held:
|
| 934 |
+
for act in sorted(self.admissible):
|
| 935 |
+
parts = act.split()
|
| 936 |
+
if len(parts) >= 5 and parts[0] == "move" \
|
| 937 |
+
and f"{parts[1]} {parts[2]}" == held[0] \
|
| 938 |
+
and parts[-2] == m["dest"]:
|
| 939 |
+
return act
|
| 940 |
+
return None
|
| 941 |
+
if verb in ("clean", "cool", "heat") and held:
|
| 942 |
+
for act in sorted(self.admissible):
|
| 943 |
+
parts = act.split()
|
| 944 |
+
if len(parts) >= 4 and parts[0] == verb \
|
| 945 |
+
and f"{parts[1]} {parts[2]}" == held[0]:
|
| 946 |
+
return act
|
| 947 |
+
return None
|
| 948 |
+
if verb == "use":
|
| 949 |
+
for act in sorted(self.admissible):
|
| 950 |
+
if act.startswith("use desklamp"):
|
| 951 |
+
return act
|
| 952 |
+
return None
|
| 953 |
+
if verb == "examine" and held:
|
| 954 |
+
for act in sorted(self.admissible):
|
| 955 |
+
if act == f"examine {held[0]}":
|
| 956 |
+
return act
|
| 957 |
+
return None
|
| 958 |
+
if verb == "open":
|
| 959 |
+
for act in sorted(self.admissible):
|
| 960 |
+
if act.startswith("open "):
|
| 961 |
+
return act
|
| 962 |
+
return None
|
| 963 |
+
if verb == "go to":
|
| 964 |
+
for act in sorted(self.admissible):
|
| 965 |
+
if act.startswith("go to "):
|
| 966 |
+
return act
|
| 967 |
+
return None
|
| 968 |
+
return None
|
| 969 |
+
|
| 970 |
+
def hint(self) -> str:
|
| 971 |
+
if not self.mission:
|
| 972 |
+
return ""
|
| 973 |
+
m = self.mission
|
| 974 |
+
lines = [f"[harness] Goal: {m['raw']}."]
|
| 975 |
+
lines.append(f"Environment step {self.step}/{self.budget} "
|
| 976 |
+
f"({'SOLVED' if self.solved else 'NOT solved'}).")
|
| 977 |
+
held = sorted(o for o in self.held if _obj_base(o) == m["target"])
|
| 978 |
+
done = self._completed()
|
| 979 |
+
placed = sorted(o for o in done if _obj_base(o) == m["target"])
|
| 980 |
+
raw_at_dest = sorted(o for o in self.placed
|
| 981 |
+
if _obj_base(o) == m["target"] and o not in done)
|
| 982 |
+
if held:
|
| 983 |
+
processed = " (processed)" if all(
|
| 984 |
+
not m["kind"] or m["kind"] in self.transformed.get(o, ())
|
| 985 |
+
for o in held) else ""
|
| 986 |
+
lines.append("Holding: " + ", ".join(held) + processed + ".")
|
| 987 |
+
others = self._held_other()
|
| 988 |
+
if others:
|
| 989 |
+
lines.append("Also holding (NOT the goal object): " + ", ".join(others)
|
| 990 |
+
+ " -- put it down first; full hands make the target untakeable.")
|
| 991 |
+
if placed:
|
| 992 |
+
lines.append(f"Already placed: {len(placed)}/{m['count']} "
|
| 993 |
+
+ ", ".join(placed) + ".")
|
| 994 |
+
if raw_at_dest:
|
| 995 |
+
lines.append("At the destination but NOT processed yet: "
|
| 996 |
+
+ ", ".join(raw_at_dest) + " (take it, process it, then place it).")
|
| 997 |
+
seen = sorted(o for o in self.saw if _obj_base(o) == m["target"]
|
| 998 |
+
and o not in done and o not in self.held
|
| 999 |
+
and o not in raw_at_dest)
|
| 1000 |
+
if seen and len(placed) + len(held) < m["count"]:
|
| 1001 |
+
lines.append("Target seen: "
|
| 1002 |
+
+ ", ".join(f"{o} at {self.saw[o]}" for o in seen[:6]) + ".")
|
| 1003 |
+
if self.invalid:
|
| 1004 |
+
lines.append("The last action did nothing and still cost an environment "
|
| 1005 |
+
"step; only use an action from the Admissible actions list.")
|
| 1006 |
+
nxt = self.next_action()
|
| 1007 |
+
if nxt and not self._legal(nxt):
|
| 1008 |
+
nxt = self._legal_fallback(nxt)
|
| 1009 |
+
if nxt and not self.solved:
|
| 1010 |
+
lines.append(f'Next required action: python3 alf do "{nxt}"')
|
| 1011 |
+
return "\n".join(lines)
|
| 1012 |
+
|
| 1013 |
+
|
| 1014 |
+
def _loop_budget(mission: dict | None) -> int:
|
| 1015 |
+
"""Shell steps for this task: the environment's budget plus free-command slack."""
|
| 1016 |
+
if mission:
|
| 1017 |
+
return min(max(MAX_STEPS, int(mission["budget"]) + STEP_SLACK), 200)
|
| 1018 |
+
return MAX_STEPS
|
| 1019 |
+
|
| 1020 |
+
|
| 1021 |
+
def _is_cycle(cmd: str, history: list[str]) -> bool:
|
| 1022 |
+
"""True when `cmd` continues a short cycle that is already in `history`.
|
| 1023 |
+
|
| 1024 |
+
The old repeat guard fired only when a command equaled the *immediately*
|
| 1025 |
+
previous one. Measured here: the model cycled `go to shelf 5`, `shelf 6`,
|
| 1026 |
+
`shelf 7` for 24 steps and no guard fired once. A cycle of period 2 or 3 is
|
| 1027 |
+
just as much a non-action as an immediate repeat, so break it before it is
|
| 1028 |
+
run (skill item 4: do not feed the repeat back as another observation).
|
| 1029 |
+
"""
|
| 1030 |
+
for period in (1, 2, 3):
|
| 1031 |
+
if period == 1:
|
| 1032 |
+
if history and history[-1] == cmd:
|
| 1033 |
+
return True
|
| 1034 |
+
continue
|
| 1035 |
+
if len(history) >= 2 * period and history[-period:] == history[-2 * period:-period] \
|
| 1036 |
+
and cmd == history[-period]:
|
| 1037 |
+
return True
|
| 1038 |
+
return False
|
| 1039 |
+
|
| 1040 |
+
|
| 1041 |
+
def _premature_finish_note(state: _AlfState, how: str) -> str:
|
| 1042 |
+
hint = state.hint()
|
| 1043 |
+
return (
|
| 1044 |
+
f"[harness] You tried to finish ({how}), but the environment has NOT printed "
|
| 1045 |
+
"SOLVED. The task is graded only by the actions replayed from "
|
| 1046 |
+
"alf_actions.jsonl, so stopping now scores zero. Do not answer or run "
|
| 1047 |
+
"`alf done` before the environment prints SOLVED.\n"
|
| 1048 |
+
+ (hint + "\n" if hint else "")
|
| 1049 |
+
+ "Continue now with exactly one action.")
|
| 1050 |
+
|
| 1051 |
+
|
| 1052 |
+
def _cycle_note(state: _AlfState) -> str:
|
| 1053 |
+
hint = state.hint()
|
| 1054 |
+
return ("[harness] That command was NOT run: the last actions form a repeating "
|
| 1055 |
+
"cycle, so running it again cannot change the environment. Choose a "
|
| 1056 |
+
"different action.\n" + (hint if hint else ""))
|
| 1057 |
+
|
| 1058 |
+
|
| 1059 |
+
def _clip_text(out: str, limit: int) -> str:
|
| 1060 |
+
if len(out) <= limit:
|
| 1061 |
+
return out
|
| 1062 |
+
marker = f"\n... [text clipped; original {len(out)} characters] ...\n"
|
| 1063 |
+
room = max(0, limit - len(marker))
|
| 1064 |
+
head = (room + 1) // 2
|
| 1065 |
+
tail = room // 2
|
| 1066 |
+
return (out[:head] + marker + (out[-tail:] if tail else ""))[:limit]
|
| 1067 |
+
|
| 1068 |
+
|
| 1069 |
+
def _json_preview(value: list | dict, limit: int) -> str | None:
|
| 1070 |
+
"""A bounded, valid JSON preview containing whole first/last entries."""
|
| 1071 |
+
mapping = isinstance(value, dict)
|
| 1072 |
+
items = list(value.items()) if mapping else value
|
| 1073 |
+
head, tail = [], []
|
| 1074 |
+
|
| 1075 |
+
def render():
|
| 1076 |
+
return json.dumps({"_harness_preview": {
|
| 1077 |
+
"total_items": len(items), "omitted_items": len(items) - len(head) - len(tail)},
|
| 1078 |
+
"head": dict(head) if mapping else head,
|
| 1079 |
+
"tail": dict(tail) if mapping else tail}, ensure_ascii=False, separators=(",", ":"))
|
| 1080 |
+
|
| 1081 |
+
shown = render()
|
| 1082 |
+
if len(shown) > limit:
|
| 1083 |
+
return None
|
| 1084 |
+
front, back = 0, len(items) - 1
|
| 1085 |
+
while front <= back:
|
| 1086 |
+
added = False
|
| 1087 |
+
head.append(items[front])
|
| 1088 |
+
candidate = render()
|
| 1089 |
+
if len(candidate) <= limit:
|
| 1090 |
+
shown = candidate
|
| 1091 |
+
front += 1
|
| 1092 |
+
added = True
|
| 1093 |
+
else:
|
| 1094 |
+
head.pop()
|
| 1095 |
+
if front <= back:
|
| 1096 |
+
tail.insert(0, items[back])
|
| 1097 |
+
candidate = render()
|
| 1098 |
+
if len(candidate) <= limit:
|
| 1099 |
+
shown = candidate
|
| 1100 |
+
back -= 1
|
| 1101 |
+
added = True
|
| 1102 |
+
else:
|
| 1103 |
+
tail.pop(0)
|
| 1104 |
+
if not added:
|
| 1105 |
+
break
|
| 1106 |
+
return shown
|
| 1107 |
+
|
| 1108 |
+
|
| 1109 |
+
def _clip_output(out: str) -> str:
|
| 1110 |
+
"""Compact leading JSON losslessly before bounding; retain whole list items.
|
| 1111 |
+
|
| 1112 |
+
Non-JSON suffixes (including shell errors) remain visible. The caller saves
|
| 1113 |
+
the original separately whenever this view differs from the output.
|
| 1114 |
+
"""
|
| 1115 |
+
if len(out) <= OUTPUT_LIMIT:
|
| 1116 |
+
return out
|
| 1117 |
+
stripped = out.lstrip()
|
| 1118 |
+
try:
|
| 1119 |
+
obj, end = json.JSONDecoder().raw_decode(stripped)
|
| 1120 |
+
except (ValueError, RecursionError):
|
| 1121 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 1122 |
+
if not isinstance(obj, (dict, list)):
|
| 1123 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 1124 |
+
suffix = stripped[end:]
|
| 1125 |
+
compact = json.dumps(obj, ensure_ascii=False, separators=(",", ":")) + suffix
|
| 1126 |
+
if len(compact) <= OUTPUT_LIMIT:
|
| 1127 |
+
return compact
|
| 1128 |
+
preview = _json_preview(obj, OUTPUT_LIMIT - len(suffix))
|
| 1129 |
+
if preview is not None:
|
| 1130 |
+
return preview + suffix
|
| 1131 |
+
return _clip_text(compact, OUTPUT_LIMIT)
|
| 1132 |
+
|
| 1133 |
+
|
| 1134 |
+
def _shell_runtime() -> tuple[str, str]:
|
| 1135 |
+
"""Choose once before any task action; never retry side effects in another shell."""
|
| 1136 |
+
bash = shutil.which("bash")
|
| 1137 |
+
return (bash, "Bash") if bash else ("/bin/sh", "POSIX sh")
|
| 1138 |
+
|
| 1139 |
+
|
| 1140 |
+
def _trim_history(messages: list[dict], budget: int | None = None) -> int:
|
| 1141 |
+
"""丢最旧的成对消息,直到历史在 `budget`(默认 `CONTEXT_CHAR_BUDGET`)以内。返回丢掉的条数。
|
| 1142 |
+
|
| 1143 |
+
`messages[0]` 是 system,`messages[1]` 是题面,两者永不丢。之后严格成对
|
| 1144 |
+
(assistant 动作、user 结果),所以一次删两条,而不是一条 —— 删一条会让"结果"成为
|
| 1145 |
+
历史里的第一条,模型会读到一段没有对应动作的输出。
|
| 1146 |
+
|
| 1147 |
+
**为什么需要一个更小的 `budget` 参数。** 字符数不是 token 数,两者的比例随内容在
|
| 1148 |
+
2:1 到 4:1 之间浮动:代码、git 对象、base64 每 token 只有一两个字符,英文散文有
|
| 1149 |
+
四个。实测(2026-10-04,`local-screen-1`):60000 字符的历史在 `git-leak-recovery` 和
|
| 1150 |
+
`regex-chess` 上被 vLLM 判为 "at least 32769 input tokens" —— 字符预算满足了,token
|
| 1151 |
+
预算没有。所以唯一可靠的判据是**模型自己说的**那个错误:`_call_openai` 收到它就按
|
| 1152 |
+
一半预算再削一次历史并重试,而不是让整道题死掉。
|
| 1153 |
+
"""
|
| 1154 |
+
limit = CONTEXT_CHAR_BUDGET if budget is None else budget
|
| 1155 |
+
dropped = 0
|
| 1156 |
+
while len(messages) > 4 and \
|
| 1157 |
+
sum(len(m.get("content") or "") for m in messages) > limit:
|
| 1158 |
+
del messages[2:4]
|
| 1159 |
+
dropped += 2
|
| 1160 |
+
return dropped
|
| 1161 |
+
|
| 1162 |
+
|
| 1163 |
+
#: 模型拒绝一条 prompt 时的两种说法(vLLM/OpenAI 兼容端点各一种)。判据是模型自己的措辞,
|
| 1164 |
+
#: 不是我们对 token 的估算 —— 估错了会削掉本该保留的历史,或者留下一个必然失败的长度。
|
| 1165 |
+
_CONTEXT_ERROR_MARKERS = ("maximum context length", "context length is", "context_length_exceeded",
|
| 1166 |
+
"reduce the length of the input prompt")
|
| 1167 |
+
|
| 1168 |
+
|
| 1169 |
+
def run(task: dict, workdir: Path) -> str:
|
| 1170 |
+
"""Execute one task. Returns the answer string.
|
| 1171 |
+
|
| 1172 |
+
The trace written to <workdir>/trace.jsonl is what the framework collects
|
| 1173 |
+
and hands to the Trainer (INTERFACE.md §4.1).
|
| 1174 |
+
"""
|
| 1175 |
+
trace_path = workdir / "trace.jsonl"
|
| 1176 |
+
shell, dialect = _shell_runtime()
|
| 1177 |
+
mission = _alf_mission(task)
|
| 1178 |
+
state = _AlfState(mission)
|
| 1179 |
+
max_steps = _loop_budget(mission)
|
| 1180 |
+
environment_note = ""
|
| 1181 |
+
if mission:
|
| 1182 |
+
environment_note = (
|
| 1183 |
+
"\nThis task is an interactive text environment reached through `python3 alf`.\n"
|
| 1184 |
+
"- `python3 alf look` is free and prints the current room plus the exact "
|
| 1185 |
+
"admissible actions. `python3 alf do \"...\"` costs one of the environment's "
|
| 1186 |
+
f"{mission['budget']} steps.\n"
|
| 1187 |
+
"- The environment prints `SOLVED` only when the goal is actually met. Never "
|
| 1188 |
+
"answer or run `alf done` before you see `SOLVED`.\n"
|
| 1189 |
+
"- After each step the harness prints your goal progress and the next required "
|
| 1190 |
+
"action; follow it unless you have a concrete reason not to.\n")
|
| 1191 |
+
messages = [
|
| 1192 |
+
{"role": "system", "content": SYSTEM + environment_note + (
|
| 1193 |
+
f"\nShell runtime: {shell} -c ({dialect}). Each command starts a new shell.\n"
|
| 1194 |
+
+ ("Bash arrays and PIPESTATUS are supported.\n" if dialect == "Bash" else
|
| 1195 |
+
"Use POSIX syntax; Bash arrays, PIPESTATUS and [[ ]] are unavailable.\n"))},
|
| 1196 |
+
{"role": "user", "content": json.dumps(task)},
|
| 1197 |
+
]
|
| 1198 |
+
|
| 1199 |
+
answer = ""
|
| 1200 |
+
submits = 0
|
| 1201 |
+
parse_retries = 0
|
| 1202 |
+
premature_finishes = 0
|
| 1203 |
+
cycle_blocks = 0
|
| 1204 |
+
alf_history: list[str] = []
|
| 1205 |
+
cmd_history: list[str] = []
|
| 1206 |
+
output_dir = None
|
| 1207 |
+
# **行缓冲,不是默认的 8KB 块缓冲。** 实测(2026-10-04,本地模型跑 `bn-fit-modify`):
|
| 1208 |
+
# harness 已经跑了 8 分钟、正在装 pandas,而 `/app/trace.jsonl` 是 0 字节、打开的 fd
|
| 1209 |
+
# `pos: 0` —— 一行都还没落盘。代价有三条:
|
| 1210 |
+
# * 实时的轨迹看不见,面板和调试都只能等它结束;
|
| 1211 |
+
# * 被超时杀掉的题会丢掉缓冲区里的尾巴(≤8KB)。一般长跑无所谓(`adaptive-rejection-sampler`
|
| 1212 |
+
# 那次写了 1MB,尾巴只占零头),但一道死在第一个命令里的题,尾巴就是**全部**;
|
| 1213 |
+
# * `harness_failed` 的判据是"轨迹为空",于是"被杀"和"从没跑起来"在记录里同形。
|
| 1214 |
+
# 行缓冲每写一行就落盘,这三条一起消失,代价是一次 write 系统调用。
|
| 1215 |
+
with trace_path.open("w", buffering=1) as trace:
|
| 1216 |
+
# **这份 harness 自己声明它的运行时预算。**
|
| 1217 |
+
#
|
| 1218 |
+
# 平台从外面只能看见 harness 目录的哈希。可哈希相同、行为不同的两份 harness 是
|
| 1219 |
+
# 存在的:`HG_AGENT_MAX_STEPS=16` 和 `=32` 跑同一个文件,一条轨迹 16 步就停、
|
| 1220 |
+
# 另一条能跑 32 步 —— 实测(2026-10-04,本地 9B 跑 `build-pmars`)32 步需要约
|
| 1221 |
+
# 1100 秒,超过题目自带的 900 秒预算,于是它超时;16 步则跑得完。这两次测量的
|
| 1222 |
+
# 曲线点上原来没有任何一个字段不同,读者无法分辨"同一外壳跑两次"和"两个预算
|
| 1223 |
+
# 各跑一次"。
|
| 1224 |
+
#
|
| 1225 |
+
# 所以这里声明一次,由平台记到曲线点上(`harnessgrad/identity.py:harness_config`)。
|
| 1226 |
+
# 同时声明 model/backend:这个 harness 读 `HG_AGENT_MODEL`,但只有它自己知道读到
|
| 1227 |
+
# 了什么,平台的环境变量在别处会因改名而与实际不符(INTERFACE.md §3)。
|
| 1228 |
+
identity = {"harness": "loop", "config": {
|
| 1229 |
+
"max_steps": max_steps,
|
| 1230 |
+
"env_budget": mission["budget"] if mission else None,
|
| 1231 |
+
"step_slack": STEP_SLACK if mission else 0,
|
| 1232 |
+
"submit_retries": SUBMIT_RETRIES,
|
| 1233 |
+
"parse_retries": PARSE_RETRIES, "finish_nudge_steps": FINISH_NUDGE_STEPS,
|
| 1234 |
+
"repeat_nudge_limit": REPEAT_NUDGE_LIMIT, "output_limit": OUTPUT_LIMIT,
|
| 1235 |
+
"context_chars": CONTEXT_CHAR_BUDGET,
|
| 1236 |
+
"shell": shell, "shell_dialect": dialect,
|
| 1237 |
+
"max_output_tokens": MAX_OUTPUT_TOKENS}}
|
| 1238 |
+
for key, value in (("agent_model", os.environ.get("HG_AGENT_MODEL")),
|
| 1239 |
+
("agent_backend", _backend())):
|
| 1240 |
+
if value:
|
| 1241 |
+
identity[key] = value
|
| 1242 |
+
trace.write(json.dumps({"harness_identity": identity}) + "\n")
|
| 1243 |
+
# **每一步的时间去哪了。** 实测(2026-10-04):本地 9B 跑 `build-pmars`,26 步撞上
|
| 1244 |
+
# 题目自带的 900 秒预算被杀。可它是"模型慢"还是"命令慢",记录里看不出来 —— trace
|
| 1245 |
+
# 只有步数,没有任何时间字段。这两件事的平台处置完全相反:模型慢要缩步数上限或
|
| 1246 |
+
# 换模型,命令慢是这道题自己的成本(装依赖),换模型没用。
|
| 1247 |
+
#
|
| 1248 |
+
# 所以每步记两个毫秒数:等模型的时间、跑命令的时间。总和不等于墙钟时,差额就是
|
| 1249 |
+
# harness 自己的开销,那也是要看得见的东西。
|
| 1250 |
+
started = time.time()
|
| 1251 |
+
model_s = command_s = 0.0
|
| 1252 |
+
trims_before = USAGE["context_trims"]
|
| 1253 |
+
for step in range(max_steps):
|
| 1254 |
+
dropped = _trim_history(messages)
|
| 1255 |
+
if dropped:
|
| 1256 |
+
trace.write(json.dumps({"step": step, "history_dropped": dropped}) + "\n")
|
| 1257 |
+
t0 = time.time()
|
| 1258 |
+
reply = _complete(messages)
|
| 1259 |
+
took = time.time() - t0
|
| 1260 |
+
model_s += took
|
| 1261 |
+
trace.write(json.dumps({"step": step, "reply": reply,
|
| 1262 |
+
"model_ms": int(took * 1000)}) + "\n")
|
| 1263 |
+
# 这一步的 prompt 被模型拒绝过,harness 因此削短了历史再问。模型这一步看到的
|
| 1264 |
+
# 历史比上一步短 —— 不记下来的话,"它为什么换了做法"在 trace 里没有答案。
|
| 1265 |
+
if USAGE["context_trims"] > trims_before:
|
| 1266 |
+
trace.write(json.dumps({
|
| 1267 |
+
"step": step, "context_trims": USAGE["context_trims"],
|
| 1268 |
+
"history_kept": len(messages)}) + "\n")
|
| 1269 |
+
trims_before = USAGE["context_trims"]
|
| 1270 |
+
messages.append({"role": "assistant", "content": reply})
|
| 1271 |
+
|
| 1272 |
+
try:
|
| 1273 |
+
action = _parse(reply)
|
| 1274 |
+
except Exception as exc:
|
| 1275 |
+
# 退回给模型,而不是结束整道题。trace 里记下第几次重试,因为平台看不到
|
| 1276 |
+
# 容器内部:没有这条记录,一次"读不懂的回复"在记录里和一次"一步就交卷"
|
| 1277 |
+
# 长得一样。次数用完仍然是 harness 失败(它确实读不出动作),但那时记录
|
| 1278 |
+
# 里已经有 N 次尝试,而不是一次。
|
| 1279 |
+
trace.write(json.dumps({"step": step, "parse_error": str(exc),
|
| 1280 |
+
"parse_retry": parse_retries}) + "\n")
|
| 1281 |
+
if parse_retries >= PARSE_RETRIES:
|
| 1282 |
+
break
|
| 1283 |
+
parse_retries += 1
|
| 1284 |
+
# Keep the full failed reply in the trace, not as an example for
|
| 1285 |
+
# the next completion to copy. In particular, token-cut commands
|
| 1286 |
+
# should be shortened by the model, never completed by the parser.
|
| 1287 |
+
messages[-1]["content"] = "[Unparseable reply omitted; see trace.jsonl.]"
|
| 1288 |
+
messages.append({"role": "user", "content": (
|
| 1289 |
+
f"Your reply could not be read as an action: {exc}\n"
|
| 1290 |
+
"Nothing was executed. It may have been cut off by the output token limit.\n"
|
| 1291 |
+
"Send one short command; use a loop/script instead of enumerating calls.\n"
|
| 1292 |
+
f"You have {max_steps - step - 1} step(s) left.\n"
|
| 1293 |
+
"Reply with EXACTLY ONE JSON object and nothing else, one of:\n"
|
| 1294 |
+
' {"tool": "bash", "command": "<shell command>"}\n'
|
| 1295 |
+
' {"answer": "<your final answer>"}\n'
|
| 1296 |
+
'For structured predictions, put the complete JSON object in "answer"; '
|
| 1297 |
+
'preserve the task\'s prediction schema.')})
|
| 1298 |
+
continue
|
| 1299 |
+
|
| 1300 |
+
parse_retries = 0
|
| 1301 |
+
# Prose or echoed data before a recovered action is not part of the
|
| 1302 |
+
# executed command. Store only the parsed action in model history.
|
| 1303 |
+
messages[-1]["content"] = json.dumps(action)
|
| 1304 |
+
|
| 1305 |
+
# **修过的地方要留痕。** 重复键的回复被解析成"第一个值放前面"之后,模型看到的
|
| 1306 |
+
# 命令和它写的不完全一样(它写了两遍,harness 取了第一遍)。一次被静默改写的
|
| 1307 |
+
# 动作和一次原样执行的动作不是同一件事,记录里必须分开。
|
| 1308 |
+
repaired = getattr(action, "duplicates", ())
|
| 1309 |
+
if repaired:
|
| 1310 |
+
trace.write(json.dumps({"step": step,
|
| 1311 |
+
"duplicate_keys": list(repaired)}) + "\n")
|
| 1312 |
+
|
| 1313 |
+
# **交卷闸门。** 顺序按"它想干什么"判断,而不是按哪个键先出现:
|
| 1314 |
+
# 一条回复里同时带 command 和 answer 时,以前"先看 answer"会让那条命令
|
| 1315 |
+
# 永远不执行(实测:`{"tool":"bash","command":"cat > /app/run.py …"}` 被当成
|
| 1316 |
+
# 空答案,文件从未创建)。所以:有命令就先执行命令;只有**没有**命令时才算交卷。
|
| 1317 |
+
cmd = action.get("command", "")
|
| 1318 |
+
if not cmd and "answer" in action:
|
| 1319 |
+
# The environment, not the model, decides whether this task is done.
|
| 1320 |
+
# Measured: 30 of 47 unsolved ALF runs ran `alf done` and submitted a
|
| 1321 |
+
# confident answer while the environment still printed `in progress`.
|
| 1322 |
+
# Accepting that answer throws away the remaining environment budget;
|
| 1323 |
+
# pushing back with the goal state gives the model the step it needed.
|
| 1324 |
+
if mission and not state.solved \
|
| 1325 |
+
and state.step < state.budget \
|
| 1326 |
+
and premature_finishes < SUBMIT_RETRIES + 1:
|
| 1327 |
+
premature_finishes += 1
|
| 1328 |
+
trace.write(json.dumps({"step": step, "premature_finish": "answer",
|
| 1329 |
+
"env_step": state.step}) + "\n")
|
| 1330 |
+
messages.append({"role": "user",
|
| 1331 |
+
"content": _premature_finish_note(state, "answer")})
|
| 1332 |
+
continue
|
| 1333 |
+
missing = _missing_deliverables(task, workdir)
|
| 1334 |
+
if missing and submits < SUBMIT_RETRIES:
|
| 1335 |
+
submits += 1
|
| 1336 |
+
note = ("You answered but these paths the task asks for do not exist: "
|
| 1337 |
+
+ ", ".join(missing)
|
| 1338 |
+
+ ". Create them first, then answer again.")
|
| 1339 |
+
trace.write(json.dumps({"step": step, "submit_rejected": missing}) + "\n")
|
| 1340 |
+
messages.append({"role": "user", "content": note})
|
| 1341 |
+
continue
|
| 1342 |
+
trace.write(json.dumps({"step": step, "submitted": True,
|
| 1343 |
+
"missing": missing}) + "\n")
|
| 1344 |
+
answer = _answer_text(action["answer"])
|
| 1345 |
+
break
|
| 1346 |
+
|
| 1347 |
+
# `alf done` is the model declaring completion, not the environment
|
| 1348 |
+
# reporting it. The verifier replays only the actions, so a premature
|
| 1349 |
+
# done is pure loss; refuse it and show what is still missing.
|
| 1350 |
+
if mission and not state.solved and _ALF_DONE_RE.search(cmd) \
|
| 1351 |
+
and not _ALF_DO_RE.search(cmd) \
|
| 1352 |
+
and state.step < state.budget \
|
| 1353 |
+
and premature_finishes < SUBMIT_RETRIES + 1:
|
| 1354 |
+
premature_finishes += 1
|
| 1355 |
+
trace.write(json.dumps({"step": step, "premature_finish": "alf done",
|
| 1356 |
+
"env_step": state.step}) + "\n")
|
| 1357 |
+
messages.append({"role": "user",
|
| 1358 |
+
"content": _premature_finish_note(state, "alf done")})
|
| 1359 |
+
continue
|
| 1360 |
+
|
| 1361 |
+
# Break a cycle *before* it executes: feeding the same observation back
|
| 1362 |
+
# is what let one run spend 24 steps walking shelf 5 -> 6 -> 7 -> 5.
|
| 1363 |
+
# Environment actions are compared among themselves (a free `alf look`
|
| 1364 |
+
# must not hide a cycle); every other command is compared against the
|
| 1365 |
+
# full command history, which preserves the old immediate-repeat guard.
|
| 1366 |
+
is_alf_action = bool(mission and _ALF_DO_RE.search(cmd))
|
| 1367 |
+
history = alf_history if is_alf_action else cmd_history
|
| 1368 |
+
if _is_cycle(cmd, history) and cycle_blocks < REPEAT_NUDGE_LIMIT * 3:
|
| 1369 |
+
cycle_blocks += 1
|
| 1370 |
+
trace.write(json.dumps({"step": step, "repeat_blocked": cmd[:160],
|
| 1371 |
+
"env_step": state.step}) + "\n")
|
| 1372 |
+
messages.append({"role": "user", "content": (
|
| 1373 |
+
_cycle_note(state) if mission else
|
| 1374 |
+
"[harness] That command was NOT run because it repeats a command "
|
| 1375 |
+
"that is already in the conversation; running it again cannot "
|
| 1376 |
+
"change the result. Choose a different action.")})
|
| 1377 |
+
continue
|
| 1378 |
+
if is_alf_action:
|
| 1379 |
+
alf_history.append(cmd.strip())
|
| 1380 |
+
if len(alf_history) > 12:
|
| 1381 |
+
del alf_history[:-12]
|
| 1382 |
+
cmd_history.append(cmd.strip())
|
| 1383 |
+
if len(cmd_history) > 12:
|
| 1384 |
+
del cmd_history[:-12]
|
| 1385 |
+
|
| 1386 |
+
t0 = time.time()
|
| 1387 |
+
proc = subprocess.run(
|
| 1388 |
+
# `errors="replace"`: a command may emit arbitrary bytes, and a strict decode
|
| 1389 |
+
# raises UnicodeDecodeError inside the harness, which ends the episode and is
|
| 1390 |
+
# recorded as a zero for a task nobody finished. Measured 2026-10-15.
|
| 1391 |
+
[shell, "-c", cmd], cwd=workdir, capture_output=True, text=True,
|
| 1392 |
+
errors="replace"
|
| 1393 |
+
)
|
| 1394 |
+
took = time.time() - t0
|
| 1395 |
+
command_s += took
|
| 1396 |
+
out = proc.stdout + proc.stderr
|
| 1397 |
+
trace.write(json.dumps({"step": step, "command": cmd,
|
| 1398 |
+
"exit": proc.returncode,
|
| 1399 |
+
"shell": shell,
|
| 1400 |
+
"command_ms": int(took * 1000), "output": out}) + "\n")
|
| 1401 |
+
shown = _clip_output(out)
|
| 1402 |
+
output_note = ""
|
| 1403 |
+
if shown != out:
|
| 1404 |
+
if output_dir is None:
|
| 1405 |
+
import tempfile
|
| 1406 |
+
output_dir = Path(tempfile.mkdtemp(prefix=".hg-output-", dir=workdir))
|
| 1407 |
+
saved = output_dir / f"step-{step}.txt"
|
| 1408 |
+
saved.write_text(out)
|
| 1409 |
+
relative = saved.relative_to(workdir)
|
| 1410 |
+
output_note = (f"\nFull output: {relative} (use shell tools to inspect/filter it).\n"
|
| 1411 |
+
"The view below may omit records; omitted does not mean absent.\n")
|
| 1412 |
+
trace.write(json.dumps({"step": step, "output_clipped": len(out),
|
| 1413 |
+
"shown": len(shown), "output_file": str(relative),
|
| 1414 |
+
"output_view": shown}) + "\n")
|
| 1415 |
+
state.observe(out, cmd)
|
| 1416 |
+
# A real environment action is progress; give the model a fresh set of
|
| 1417 |
+
# push-backs if it later tries to finish early again.
|
| 1418 |
+
if mission and _ALF_DO_RE.search(cmd):
|
| 1419 |
+
premature_finishes = 0
|
| 1420 |
+
observation = f"exit={proc.returncode}{output_note}\n{shown}"
|
| 1421 |
+
hint = state.hint() if mission else ""
|
| 1422 |
+
if hint:
|
| 1423 |
+
observation += "\n\n" + hint
|
| 1424 |
+
messages.append({"role": "user", "content": observation})
|
| 1425 |
+
|
| 1426 |
+
# The environment said SOLVED. Stop immediately: the verifier replays
|
| 1427 |
+
# the actions that are already in alf_actions.jsonl, so more calls can
|
| 1428 |
+
# only add noise (and the old loop answered after this with a boolean
|
| 1429 |
+
# and burned its parse retries for nothing).
|
| 1430 |
+
if mission and state.solved:
|
| 1431 |
+
trace.write(json.dumps({"step": step, "environment_solved": True,
|
| 1432 |
+
"env_step": state.step}) + "\n")
|
| 1433 |
+
answer = json.dumps({"task_id": task.get("task_id"),
|
| 1434 |
+
"status": "solved"})
|
| 1435 |
+
break
|
| 1436 |
+
|
| 1437 |
+
# The environment's own action budget is spent; no further action can
|
| 1438 |
+
# be graded as progress, so stop instead of answering after the cap.
|
| 1439 |
+
if mission and state.step >= state.budget:
|
| 1440 |
+
trace.write(json.dumps({"step": step, "environment_exhausted": True,
|
| 1441 |
+
"env_step": state.step}) + "\n")
|
| 1442 |
+
answer = json.dumps({"task_id": task.get("task_id"),
|
| 1443 |
+
"status": "environment budget exhausted"})
|
| 1444 |
+
break
|
| 1445 |
+
|
| 1446 |
+
left = max_steps - (step + 1)
|
| 1447 |
+
# 只在进入收尾区和最后一步各说一次:每一步都重复同一句话不会更有用,
|
| 1448 |
+
# 只会把最近几轮的命令输出挤远。
|
| 1449 |
+
if left and (left == FINISH_NUDGE_STEPS or left == 1):
|
| 1450 |
+
trace.write(json.dumps({"step": step, "finish_nudge": left}) + "\n")
|
| 1451 |
+
if mission:
|
| 1452 |
+
messages[-1]["content"] += "\n" + (
|
| 1453 |
+
f"You have {left} shell step(s) left; the environment is at "
|
| 1454 |
+
f"step {state.step}/{state.budget}. Follow the Next required "
|
| 1455 |
+
"action and do not answer before the environment prints SOLVED.")
|
| 1456 |
+
else:
|
| 1457 |
+
messages[-1]["content"] += "\n" + (
|
| 1458 |
+
f"You have {left} step(s) left. Stop exploring. Create every file the "
|
| 1459 |
+
"task asks for now, then reply with exactly one JSON object: "
|
| 1460 |
+
'{"answer": "<your final answer>"}')
|
| 1461 |
+
|
| 1462 |
+
# Where the wall clock went. Separate from `usage` (which counts tokens):
|
| 1463 |
+
# a reader asking "was this killed for being slow, and slow at what" gets one
|
| 1464 |
+
# line, and a harness that is slow on its own shows up as `total` exceeding
|
| 1465 |
+
# model + commands.
|
| 1466 |
+
trace.write(json.dumps({"wall_clock_s": {
|
| 1467 |
+
"model": round(model_s, 1), "commands": round(command_s, 1),
|
| 1468 |
+
"total": round(time.time() - started, 1)}}) + "\n")
|
| 1469 |
+
|
| 1470 |
+
# What the run cost. Kept because a harness that cannot say what it spent
|
| 1471 |
+
# cannot be compared with a cheaper one at the same score -- and because
|
| 1472 |
+
# `USAGE` is the only place the model calls are counted.
|
| 1473 |
+
trace.write(json.dumps({"usage": dict(USAGE)}) + "\n")
|
| 1474 |
+
|
| 1475 |
+
(workdir / "answer.txt").write_text(answer)
|
| 1476 |
+
return answer
|
| 1477 |
+
|
| 1478 |
+
|
| 1479 |
+
def main() -> int:
|
| 1480 |
+
ap = argparse.ArgumentParser()
|
| 1481 |
+
ap.add_argument("--task", required=True)
|
| 1482 |
+
ap.add_argument("--workdir", required=True)
|
| 1483 |
+
args = ap.parse_args()
|
| 1484 |
+
|
| 1485 |
+
task = json.loads(Path(args.task).read_text())
|
| 1486 |
+
run(task, Path(args.workdir))
|
| 1487 |
+
return 0
|
| 1488 |
+
|
| 1489 |
+
|
| 1490 |
+
if __name__ == "__main__":
|
| 1491 |
+
sys.exit(main())
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-2/harness.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "loop",
|
| 3 |
+
"version": "0.2.0",
|
| 4 |
+
"path": ".",
|
| 5 |
+
"entrypoint": "agent.py",
|
| 6 |
+
"backend": "cli",
|
| 7 |
+
"install": "requirements.txt",
|
| 8 |
+
"env_kinds": [
|
| 9 |
+
"files",
|
| 10 |
+
"exec"
|
| 11 |
+
]
|
| 12 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-2/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
openai>=1.0
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-3/.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
_harnessgrad/
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.pyc
|
| 5 |
+
.state/
|
| 6 |
+
*.bak
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""The reference base harness: a minimal ReAct loop.
|
| 3 |
+
|
| 4 |
+
Deliberately the simplest thing that satisfies the contract in
|
| 5 |
+
`docs/writing_a_harness.md`. Its job is not to be strong -- it is to be:
|
| 6 |
+
|
| 7 |
+
1. a valid starting point that a method can improve, and
|
| 8 |
+
2. the proof that the contract is implementable at all.
|
| 9 |
+
|
| 10 |
+
A method may replace every file here. That is the point.
|
| 11 |
+
|
| 12 |
+
**What it ships, and why that changed.** This harness used to be a bare loop: no
|
| 13 |
+
context policy, no output bounding, no retries. That is still the design -- but
|
| 14 |
+
these mechanisms are now in it, and each is here because a measurement said the
|
| 15 |
+
bare loop could not be measured at all, not because a mechanism is nice to have:
|
| 16 |
+
|
| 17 |
+
* `PARSE_RETRIES`, `SUBMIT_RETRIES`, `FINISH_NUDGE_STEPS`, `REPEAT_NUDGE_LIMIT`
|
| 18 |
+
-- one unreadable reply, or one premature "I am done", used to end the whole
|
| 19 |
+
task. Measured: 73 of 266 runs reached the step cap with nothing submitted,
|
| 20 |
+
and one task died after exactly one model call.
|
| 21 |
+
* `OUTPUT_LIMIT`, `CONTEXT_CHAR_BUDGET` -- a command that printed a large file
|
| 22 |
+
left the next call over the model's context limit, which killed the task.
|
| 23 |
+
* line-buffered trace writes -- a block buffer meant a killed task lost its tail,
|
| 24 |
+
so "killed at step 30" and "never started" were the same record.
|
| 25 |
+
|
| 26 |
+
All of them are still named switches with an `HG_AGENT_*` override, so a method
|
| 27 |
+
may change or remove any of them; what a method adds *on top* is the measurement.
|
| 28 |
+
The values actually in force go into the trace (`harness_identity.config`, below)
|
| 29 |
+
and land on the curve point, because two runs of this same file at two different
|
| 30 |
+
step caps are two different harnesses and the file hash cannot tell them apart.
|
| 31 |
+
"""
|
| 32 |
+
from __future__ import annotations
|
| 33 |
+
|
| 34 |
+
import argparse
|
| 35 |
+
import json
|
| 36 |
+
import os
|
| 37 |
+
import re
|
| 38 |
+
import shutil
|
| 39 |
+
import subprocess
|
| 40 |
+
import sys
|
| 41 |
+
import time
|
| 42 |
+
from pathlib import Path
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
#: How many model calls one task gets. **A floor on capability, not a tuning knob.**
|
| 46 |
+
#:
|
| 47 |
+
#: Measured at 8, on Terminal-Bench, 4 rounds x 5 tasks: four of the five tasks used all
|
| 48 |
+
#: eight and produced no graded artifact at all -- `build-pmars` was still installing
|
| 49 |
+
#: packages, `bn-fit-modify` had just finished installing pandas/numpy/sklearn and
|
| 50 |
+
#: printed one correlation matrix, `chess-best-move` had opened the PNG and never wrote
|
| 51 |
+
#: `/app/move.txt`. The score was 0.0 on every task in every round, which is not a weak
|
| 52 |
+
#: harness being measured: it is a floor effect, and a floor makes every method look
|
| 53 |
+
#: identical because there is no gradient for one to move.
|
| 54 |
+
#:
|
| 55 |
+
#: Raising this does not make the harness cleverer -- `legacy/adapters/harnessgrad_domain/`
|
| 56 |
+
#: already names this lever as the trap ("helps only if the model is already using the
|
| 57 |
+
#: steps it has"). Here the trace shows it *was* using them, which is exactly when the
|
| 58 |
+
#: lever is legitimate. What it costs is bounded by the task, not by this number: the
|
| 59 |
+
#: wall clock is capped by the environment's `agent_timeout_s` (900 s for most
|
| 60 |
+
#: Terminal-Bench tasks, 3600 s for `bn-fit-modify`). A step is fast (~0.2 s model round
|
| 61 |
+
#: trip through the local gateway), so the extra ceiling mostly buys back the steps that
|
| 62 |
+
#: environment setup eats. The loop still stops the moment the model answers -- the cap
|
| 63 |
+
#: is a ceiling, not a quota.
|
| 64 |
+
MAX_STEPS = int(os.environ.get("HG_AGENT_MAX_STEPS", "32"))
|
| 65 |
+
MAX_OUTPUT_TOKENS = int(os.environ.get("HG_AGENT_MAX_OUTPUT_TOKENS", "2048"))
|
| 66 |
+
if MAX_OUTPUT_TOKENS < 1:
|
| 67 |
+
raise ValueError("HG_AGENT_MAX_OUTPUT_TOKENS must be positive")
|
| 68 |
+
|
| 69 |
+
#: Extra shell steps granted on top of the environment's **own** action budget.
|
| 70 |
+
#:
|
| 71 |
+
#: The failure this repairs is not "32 is too few": it is that the harness had a
|
| 72 |
+
#: global cap while the environment declares its own budget in the goal text
|
| 73 |
+
#: (`**50** steps`). A run could therefore spend 32 shell steps, of which only
|
| 74 |
+
#: some are environment actions, and be killed by the harness while the
|
| 75 |
+
#: environment still had most of its budget left. The cap is derived per task
|
| 76 |
+
#: from that declared number; the slack pays for the free commands (`alf look`)
|
| 77 |
+
#: and for the harness's own push-backs. It is not a tuning knob.
|
| 78 |
+
STEP_SLACK = int(os.environ.get("HG_AGENT_STEP_SLACK", "16"))
|
| 79 |
+
|
| 80 |
+
#: 模型说"我做完了"之后,允许它再被退回几次。
|
| 81 |
+
#:
|
| 82 |
+
#: 为什么需要这个:harness 以前**从不检查交付物**。模型回一句 {"answer": ...} 就被当成
|
| 83 |
+
#: 任务结束、退出循环。实测(2026-10-02,terminal_bench round 0):五道题的 agent 阶段是
|
| 84 |
+
#: 101s / 31s / 183s / **4.5s** / 105s —— 而步数上限是 32。4.5 秒等于一次模型调用就
|
| 85 |
+
#: "交卷"了,产物根本不存在;`cancel-async-tasks` 的判分因此是
|
| 86 |
+
#: `File /app/run.py does not exist`。
|
| 87 |
+
#:
|
| 88 |
+
#: 所以 0 分的机制不是"步数不够",而是"**harness 把模型说的完成当成了完成**"。
|
| 89 |
+
#: 一个会自己检查交付物、并把"文件不存在"退回给模型重试的 harness,才是这一步该有的样子。
|
| 90 |
+
SUBMIT_RETRIES = int(os.environ.get("HG_AGENT_SUBMIT_RETRIES", "2"))
|
| 91 |
+
|
| 92 |
+
#: 模型吐出一段**读不出动作**的回复之后,允许它再试几次。
|
| 93 |
+
#:
|
| 94 |
+
#: 和上面那条同源,方向相反:一条是"模型说做完了,但产物不在",一条是"模型说的话读不出
|
| 95 |
+
#: 动作"。两条以前都会让**整道题**结束。
|
| 96 |
+
#:
|
| 97 |
+
#: 为什么它必须由起点 harness 负责,而不是留给方法去发现 —— 这是数出来的,不是想出来的。
|
| 98 |
+
#: 统计所有跑道里"方法自己写了理由"的 35 个轮次:**16 个在修解析或格式容错**,而且几乎
|
| 99 |
+
#: 每条跑道的第一轮都在修它:
|
| 100 |
+
#:
|
| 101 |
+
#: `loop-terminal_bench-26452c` 五道题各只调了一次模型就死在
|
| 102 |
+
#: `parse_error: Extra data`(`calls: 1`),此后每一轮都从同一个不能用的 harness 出发;
|
| 103 |
+
#: `flash-three-1/2`、`deepseek-eigen-2`、`strong-model-1` 的第一/第二轮全都写成
|
| 104 |
+
#: "让一次读不懂的回复不再结束整道题"。
|
| 105 |
+
#:
|
| 106 |
+
#: 代价不只是浪费一轮。方法之间开始比"谁先想到修 parser":RRSI 的 leakage critic 两次把
|
| 107 |
+
#: 改 `_parse` 的候选判成 TASK-SPECIALIZATION / LEAKAGE 而拒绝,那一轮于是什么都没改。
|
| 108 |
+
#: 一个起点 harness 必须在被测量之前就活过一次跑题的回复,否则第一轮比较的不是解题能力,
|
| 109 |
+
#: 是管线运气。
|
| 110 |
+
PARSE_RETRIES = int(os.environ.get("HG_AGENT_PARSE_RETRIES", "2"))
|
| 111 |
+
|
| 112 |
+
#: 步数还剩这么多时,明确要求模型收尾。
|
| 113 |
+
#:
|
| 114 |
+
#: 数出来的,不是猜的:266 条历史轨迹里 **73 条(27%)跑满 32 步、一次都没交卷**,而那些
|
| 115 |
+
#: 轨迹的最后两步常常是同一条命令重复(抽样:`python /app/test_outputs.py 2>&1` 两次、
|
| 116 |
+
#: 同一条 `echo ... >` 两次、同一个 `cat > /app/run.py << 'EOF'` 两次)。那些任务不是
|
| 117 |
+
#: "做错了",是**没停下来交卷**:步数用完,`answer` 是空字符串,平台只能拿检查的判决当分数。
|
| 118 |
+
#: `improvers/skill.md` 早就把这条记成已知失败模式("预算用满、什么都没交"),但起点 harness
|
| 119 |
+
#: 一直没有对应动作。一个被测量的 harness 应该在预算耗尽前把话说完。
|
| 120 |
+
FINISH_NUDGE_STEPS = int(os.environ.get("HG_AGENT_FINISH_NUDGE_STEPS", "4"))
|
| 121 |
+
|
| 122 |
+
#: 同一条命令连续重复时提醒几次(每条跑道限量,免得把上下文塞满)。
|
| 123 |
+
REPEAT_NUDGE_LIMIT = int(os.environ.get("HG_AGENT_REPEAT_NUDGE_LIMIT", "2"))
|
| 124 |
+
|
| 125 |
+
#: 单条命令的输出进入消息历史时的字符上限。先压紧 JSON,再保留完整记录预览;
|
| 126 |
+
#: 纯文本留头尾。完整输出留在工作目录,模型可按需读取。
|
| 127 |
+
#:
|
| 128 |
+
#: 实测(2026-10-04,本地 9B,5 道题):**3 道题死于
|
| 129 |
+
#: `This model's maximum context length is 32768 tokens ... your prompt contains at least
|
| 130 |
+
#: 32769 input tokens`(BadRequestError 400)**。起点 harness 以前把每条命令的**完整**输出
|
| 131 |
+
#: 一直往历史里追加,永不截断:一道题里单条输出就有 11773 字符,装一次包、cat 一个大文件
|
| 132 |
+
#: 就够撞上 32k 的窗口。那不是模型的问题,是 harness 没有上下文管理。
|
| 133 |
+
OUTPUT_LIMIT = int(os.environ.get("HG_AGENT_OUTPUT_LIMIT", "4000"))
|
| 134 |
+
|
| 135 |
+
#: 消息历史(不含 system 与题面)的字符预算。按 4 字符 ≈ 1 token 粗估,60k 字符约 15k token,
|
| 136 |
+
#: 给 32k 窗口的模型留出输出空间。超了就丢**最旧的成对消息**,并在轨迹里记下丢了几条 ——
|
| 137 |
+
#: 一个悄悄改变模型所见历史的 harness,和一个被测量的 harness,不是同一件事。
|
| 138 |
+
CONTEXT_CHAR_BUDGET = int(os.environ.get("HG_AGENT_CONTEXT_CHARS", "60000"))
|
| 139 |
+
|
| 140 |
+
SYSTEM = """You are an agent solving a task in a working directory.
|
| 141 |
+
|
| 142 |
+
You have one tool: run a shell command.
|
| 143 |
+
|
| 144 |
+
Reply with EXACTLY one of:
|
| 145 |
+
{"tool": "bash", "command": "<shell command>"}
|
| 146 |
+
{"answer": "<your final answer>"}
|
| 147 |
+
|
| 148 |
+
For a structured final answer, "answer" may be a JSON object containing the task's
|
| 149 |
+
prediction fields.
|
| 150 |
+
|
| 151 |
+
Rules:
|
| 152 |
+
- One action per reply. No prose outside the JSON.
|
| 153 |
+
- Keep commands concise. Use a loop or a script instead of enumerating many calls.
|
| 154 |
+
- To inspect files use shell commands (ls, cat, grep, ...).
|
| 155 |
+
- Give the final answer only when you are confident.
|
| 156 |
+
"""
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
# ---------------------------------------------------------------- backends ---
|
| 160 |
+
|
| 161 |
+
def _backend() -> str:
|
| 162 |
+
"""Which completion backend to use.
|
| 163 |
+
|
| 164 |
+
`mock` exists so the framework can be exercised end-to-end with zero network
|
| 165 |
+
and zero cost. Any real curve must declare its backend and model on the curve
|
| 166 |
+
point (INTERFACE.md §3, `identity.agent_model`).
|
| 167 |
+
"""
|
| 168 |
+
return os.environ.get("HG_AGENT_BACKEND", "mock")
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def _call_mock(messages: list[dict]) -> str:
|
| 172 |
+
"""Deterministic stand-in: read answer.txt if present, else list the dir."""
|
| 173 |
+
task_text = messages[1]["content"] if len(messages) > 1 else ""
|
| 174 |
+
if "answer.txt exists" in task_text or "already" in task_text:
|
| 175 |
+
return json.dumps({"answer": "READ_FROM_FILE"})
|
| 176 |
+
return json.dumps({"tool": "bash", "command": "ls -a"})
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
# --------------------------------------------------------------- usage ---
|
| 180 |
+
|
| 181 |
+
#: Token usage accumulated over the run, filled by whichever backend is active.
|
| 182 |
+
#: Read into the trace at the end. Recorded because a mechanism that spends model
|
| 183 |
+
#: calls (history_summary does) is only comparable against a free one if the
|
| 184 |
+
#: spend is visible -- and because a harness whose cost is unknown cannot be
|
| 185 |
+
#: ranked against a cheaper one that scores the same.
|
| 186 |
+
#: `context_trims` 单独计数:它是"模型拒绝了这条 prompt,于是我们削短了历史"的次数。
|
| 187 |
+
#: 和 `retries`(网络/限流)不同 —— 那一种重试发的是同一条 prompt,这一种发的是**更短的**
|
| 188 |
+
#: 一条,模型看到的历史因此和上一步不同。要能分开,才能解释"那一步为什么换了做法"。
|
| 189 |
+
USAGE = {"calls": 0, "input_tokens": 0, "output_tokens": 0, "retries": 0,
|
| 190 |
+
"context_trims": 0}
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def _record_usage(usage) -> None:
|
| 194 |
+
"""Fold provider token counts into the run's total.
|
| 195 |
+
|
| 196 |
+
The call count is NOT incremented here: it is incremented by `_complete`,
|
| 197 |
+
which is the one place every model call goes through. Counting calls at the
|
| 198 |
+
provider boundary would miss the mock backend entirely -- and a mechanism that
|
| 199 |
+
spends model calls on a mock run would then report zero cost, which is exactly
|
| 200 |
+
the invisible-spend the usage block exists to prevent.
|
| 201 |
+
"""
|
| 202 |
+
if usage is None:
|
| 203 |
+
return
|
| 204 |
+
# Provider fields that are absent stay absent rather than becoming zero: a
|
| 205 |
+
# zero that means "not reported" is indistinguishable from a real zero.
|
| 206 |
+
for attr, key in (("prompt_tokens", "input_tokens"),
|
| 207 |
+
("completion_tokens", "output_tokens")):
|
| 208 |
+
v = getattr(usage, attr, None)
|
| 209 |
+
if isinstance(v, int):
|
| 210 |
+
USAGE[key] += v
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def _call_openai(messages: list[dict]) -> str:
|
| 214 |
+
"""One completion, with a deadline and bounded retries.
|
| 215 |
+
|
| 216 |
+
A harness that dies on a transient provider error loses a whole task run, and
|
| 217 |
+
an unbounded retry loop turns a provider outage into a hung experiment. Both
|
| 218 |
+
failures are silent in a batch unless the harness is defensive here.
|
| 219 |
+
"""
|
| 220 |
+
from openai import OpenAI
|
| 221 |
+
|
| 222 |
+
# **每次请求用一条新连接,不复用。** 不是性能取舍,是正确性:
|
| 223 |
+
#
|
| 224 |
+
# 实测(2026-10-02,容器内复现):vLLM 的 uvicorn 默认 5 秒关掉空闲 keep-alive,而
|
| 225 |
+
# 容器到模型之间还有平台发布的一层字节转发网关,它在上游 EOF 时会把 EOF 半关到
|
| 226 |
+
# 客户端。于是"跑一条几十秒的命令、再发起下一次模型调用"就必然复用一条死连接 ——
|
| 227 |
+
# `RemoteDisconnected` → openai 报 `APIConnectionError: Connection error`。
|
| 228 |
+
# 实测那一次,两道题(跑 pandas 的、跑 PIL 的)就是这样死的,而平台把它们记成了 0 分。
|
| 229 |
+
#
|
| 230 |
+
# keep-alive 本身是 HTTP 客户端的正常行为,所以这是网关的缺陷(见 eval/modelgate.py);
|
| 231 |
+
# 但一个 harness 不该把自己的测量押在"中间那一层是否正确处理空闲连接"上。一次本地
|
| 232 |
+
# TCP 握手的代价可以忽略。
|
| 233 |
+
#
|
| 234 |
+
# **用 `default_headers`,不要 import httpx。** 第一版写的是
|
| 235 |
+
# `http_client=httpx.Client(...)`,结果是每次调用都 `ModuleNotFoundError: No module
|
| 236 |
+
# named 'httpx'` —— 这个平台的 harness 依赖由覆盖层提供,而这里 `openai` 3.22.1 依赖的
|
| 237 |
+
# 是 `httpx2`(不是 `httpx`)。所以"顺手 import 一个我以为在的库"在这条路上是错的:
|
| 238 |
+
# 唯一可以依赖的是 `requirements.txt` 声明的那个发行包自己的接口。
|
| 239 |
+
client = OpenAI(
|
| 240 |
+
base_url=os.environ["HG_AGENT_BASE_URL"],
|
| 241 |
+
api_key=os.environ["HG_AGENT_API_KEY"],
|
| 242 |
+
timeout=float(os.environ.get("HG_AGENT_TIMEOUT_S", "180")),
|
| 243 |
+
max_retries=0, # retried here, so the count is ours to record
|
| 244 |
+
default_headers={"Connection": "close"},
|
| 245 |
+
)
|
| 246 |
+
model = os.environ["HG_AGENT_MODEL"]
|
| 247 |
+
attempts = int(os.environ.get("HG_AGENT_RETRIES", "3"))
|
| 248 |
+
last: Exception | None = None
|
| 249 |
+
|
| 250 |
+
for attempt in range(attempts):
|
| 251 |
+
try:
|
| 252 |
+
resp = client.chat.completions.create(
|
| 253 |
+
model=model, messages=messages, temperature=0.0,
|
| 254 |
+
max_tokens=MAX_OUTPUT_TOKENS,
|
| 255 |
+
)
|
| 256 |
+
_record_usage(getattr(resp, "usage", None))
|
| 257 |
+
return resp.choices[0].message.content or ""
|
| 258 |
+
except Exception as exc: # noqa: BLE001
|
| 259 |
+
last = exc
|
| 260 |
+
# **历史太长是可恢复的,以前不是。** 实测(2026-10-04):`git-leak-recovery` 和
|
| 261 |
+
# `regex-chess` 死在 `maximum context length is 32768 tokens ... at least 32769
|
| 262 |
+
# input tokens`,而两道题之前都已经跑了十几步的有效功。字符预算挡不住它
|
| 263 |
+
# (见 `_trim_history`),所以这里按模型自己的拒绝削一半历史再试一次 —— 削掉的
|
| 264 |
+
# 步数记进 `USAGE["context_trims"]`,由主循环写进 trace,不是悄悄改历史。
|
| 265 |
+
if any(marker in str(exc) for marker in _CONTEXT_ERROR_MARKERS) \
|
| 266 |
+
and len(messages) > 4 and attempt + 1 < attempts:
|
| 267 |
+
dropped = _trim_history(messages, budget=(CONTEXT_CHAR_BUDGET // 2))
|
| 268 |
+
if not dropped:
|
| 269 |
+
dropped = _trim_history(messages, budget=1)
|
| 270 |
+
USAGE["context_trims"] += 1
|
| 271 |
+
USAGE["retries"] += 1
|
| 272 |
+
continue
|
| 273 |
+
if attempt + 1 < attempts:
|
| 274 |
+
USAGE["retries"] += 1
|
| 275 |
+
time.sleep(min(2 ** attempt, 30))
|
| 276 |
+
# Out of attempts: raise, so the caller records a harness failure rather than
|
| 277 |
+
# scoring an empty answer as a wrong one.
|
| 278 |
+
raise RuntimeError(f"{attempts} attempts failed, last: {last}") from last
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def _complete(messages: list[dict]) -> str:
|
| 282 |
+
"""Every model call in this harness goes through here, so this is where the
|
| 283 |
+
count is kept. Counting anywhere else means some caller is invisible."""
|
| 284 |
+
USAGE["calls"] += 1
|
| 285 |
+
return _call_mock(messages) if _backend() == "mock" else _call_openai(messages)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
# ------------------------------------------------------------- the loop -----
|
| 289 |
+
|
| 290 |
+
class _Action(dict):
|
| 291 |
+
"""A parsed action, plus what the parser had to repair to get it.
|
| 292 |
+
|
| 293 |
+
An attribute rather than a second return value, because every caller wants the
|
| 294 |
+
dict and only one wants the repair note. `duplicates` empty means the reply was
|
| 295 |
+
well formed and nothing was guessed.
|
| 296 |
+
"""
|
| 297 |
+
duplicates: tuple[str, ...] = ()
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
def _first_key_wins(pairs):
|
| 301 |
+
"""Duplicated JSON keys: keep the **first** value, and say which keys repeated.
|
| 302 |
+
|
| 303 |
+
**This is measured, not defensive.** The local 9B (Qwen3.5-9B) writes a file like
|
| 304 |
+
this, and it is the whole reason `cancel-async-tasks` scored 0.0 in
|
| 305 |
+
`local-floor-9`:
|
| 306 |
+
|
| 307 |
+
{"tool": "bash", "command": "cat > /app/run.py << 'EOF'\n...\nEOF\n", "command": ""}
|
| 308 |
+
|
| 309 |
+
The real command is there, and then the model appends `, "command": ""`. JSON says
|
| 310 |
+
a duplicate key keeps the **last** value, so `json.loads` (and `raw_decode`) handed
|
| 311 |
+
the harness an empty command. The harness then ran the empty string -- exit 0, no
|
| 312 |
+
output -- and told the model `exit=0`. The model read that as success, answered
|
| 313 |
+
"the file /app/run.py has been created", and the verifier found no file. All 16
|
| 314 |
+
steps of that trajectory are the model writing the file, being told it worked, and
|
| 315 |
+
checking. Not one step of it wrote anything.
|
| 316 |
+
|
| 317 |
+
Taking the first value is the repair that matches intent here: the long command is
|
| 318 |
+
what the model meant, and the trailing `""` is noise from the same malformation
|
| 319 |
+
that produces its stray braces. It is recorded (`duplicate_keys` in the trace)
|
| 320 |
+
because a harness that silently rewrites the model's action and one that does not
|
| 321 |
+
are different harnesses.
|
| 322 |
+
"""
|
| 323 |
+
action = _Action()
|
| 324 |
+
repeated: list[str] = []
|
| 325 |
+
for key, value in pairs:
|
| 326 |
+
if key in action:
|
| 327 |
+
repeated.append(key)
|
| 328 |
+
continue
|
| 329 |
+
action[key] = value
|
| 330 |
+
if repeated:
|
| 331 |
+
action.duplicates = tuple(repeated)
|
| 332 |
+
return action
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
def _json_block_end(text: str, start: int) -> int:
|
| 336 |
+
"""Skip a malformed JSON block without treating its strings as actions."""
|
| 337 |
+
depth = 0
|
| 338 |
+
quoted = escaped = False
|
| 339 |
+
for i in range(start, len(text)):
|
| 340 |
+
ch = text[i]
|
| 341 |
+
if quoted:
|
| 342 |
+
if escaped:
|
| 343 |
+
escaped = False
|
| 344 |
+
elif ch == "\\":
|
| 345 |
+
escaped = True
|
| 346 |
+
elif ch == '"':
|
| 347 |
+
quoted = False
|
| 348 |
+
elif ch == '"':
|
| 349 |
+
quoted = True
|
| 350 |
+
elif ch in "{[":
|
| 351 |
+
depth += 1
|
| 352 |
+
elif ch in "}]":
|
| 353 |
+
depth -= 1
|
| 354 |
+
if depth == 0:
|
| 355 |
+
return i + 1
|
| 356 |
+
return len(text)
|
| 357 |
+
|
| 358 |
+
|
| 359 |
+
def _parse(reply: str) -> dict:
|
| 360 |
+
"""First complete action, across prose/fences and preceding structured data.
|
| 361 |
+
|
| 362 |
+
Consume whole JSON blocks, so nested data and quoted example actions cannot
|
| 363 |
+
become commands. Never close a truncated command or execute its prefix.
|
| 364 |
+
"""
|
| 365 |
+
decoder = json.JSONDecoder(object_pairs_hook=_first_key_wins)
|
| 366 |
+
i = 0
|
| 367 |
+
while i < len(reply):
|
| 368 |
+
if reply[i] not in "{[":
|
| 369 |
+
i += 1
|
| 370 |
+
continue
|
| 371 |
+
try:
|
| 372 |
+
obj, end = decoder.raw_decode(reply, i)
|
| 373 |
+
except json.JSONDecodeError:
|
| 374 |
+
i = _json_block_end(reply, i)
|
| 375 |
+
continue
|
| 376 |
+
i = end
|
| 377 |
+
if not isinstance(obj, dict) or obj.get("tool", "bash") != "bash":
|
| 378 |
+
continue
|
| 379 |
+
cmd = obj.get("command", "")
|
| 380 |
+
if isinstance(cmd, str) and cmd.strip():
|
| 381 |
+
return obj
|
| 382 |
+
if cmd == "" and "answer" in obj:
|
| 383 |
+
# An outer action can be valid JSON while its answer contains broken
|
| 384 |
+
# inner JSON. Reject it here so the ordinary parse retry can recover.
|
| 385 |
+
_answer_text(obj["answer"])
|
| 386 |
+
return obj
|
| 387 |
+
raise ValueError("no complete JSON action found in reply")
|
| 388 |
+
|
| 389 |
+
|
| 390 |
+
def _answer_text(value: object) -> str:
|
| 391 |
+
"""Transport a final answer without inventing or dropping prediction fields.
|
| 392 |
+
|
| 393 |
+
Schema validation belongs to the task's verifier. This only checks transport:
|
| 394 |
+
objects must stay JSON (str(dict) produces Python syntax), and JSON-looking
|
| 395 |
+
strings must be complete. Never close truncated JSON or reinterpret literals.
|
| 396 |
+
|
| 397 |
+
Scalars are transported as JSON too. Measured on this benchmark: after the
|
| 398 |
+
environment had already solved a task, the model answered `{"answer": true}`;
|
| 399 |
+
rejecting the boolean as "not a string or dict" burned both parse retries and
|
| 400 |
+
ended the run in a parse error. No verifier reads the answer here -- the
|
| 401 |
+
actions do -- so refusing a perfectly well-formed scalar is a harness bug.
|
| 402 |
+
"""
|
| 403 |
+
if isinstance(value, (str,)):
|
| 404 |
+
if value.lstrip().startswith("{"):
|
| 405 |
+
try:
|
| 406 |
+
json.loads(value)
|
| 407 |
+
except ValueError as exc:
|
| 408 |
+
raise ValueError(f"final answer contains malformed JSON: {exc}") from exc
|
| 409 |
+
return value
|
| 410 |
+
if isinstance(value, (dict, list, bool, int, float)) or value is None:
|
| 411 |
+
return json.dumps(value, ensure_ascii=False, allow_nan=False)
|
| 412 |
+
raise ValueError("final answer must be JSON-transportable")
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
#: goal 里形如 `/app/move.txt`、`/app/learned_dag.csv` 的路径。这是**通用**的:
|
| 416 |
+
#: 它不针对任何一道题,只看题面自己说了要写到哪个文件。
|
| 417 |
+
_PATH_RE = __import__("re").compile(r"/[A-Za-z0-9_./-]+\.[A-Za-z0-9]{1,6}\b")
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
def _missing_deliverables(task: dict, workdir: Path) -> list[str]:
|
| 421 |
+
"""题面点名要写、但现在**不存在**的文件。
|
| 422 |
+
|
| 423 |
+
这是 `loop` 自带的交卷闸门,刻意做成通用的两条:
|
| 424 |
+
|
| 425 |
+
* 只看题面(goal)里写出来的绝对路径 —— harness 没有任何途径知道判分脚本要什么
|
| 426 |
+
(`task.json` 里只有 goal),所以它只能相信题面;
|
| 427 |
+
* 只做 `exists` 检查,不执行任何东西。
|
| 428 |
+
|
| 429 |
+
题面没提路径(比如"回答一个问题")时返回空列表,闸门不生效 —— 这时判断对错是平台
|
| 430 |
+
的事,harness 不该假装知道。
|
| 431 |
+
"""
|
| 432 |
+
goal = str(task.get("goal") or "")
|
| 433 |
+
wanted = {m for m in _PATH_RE.findall(goal)}
|
| 434 |
+
missing = []
|
| 435 |
+
for raw in sorted(wanted):
|
| 436 |
+
# 容器里绝对路径就是它自己;宿主上则落在 workdir 之内。两种都查,取存在的那个。
|
| 437 |
+
candidates = [Path(raw)]
|
| 438 |
+
try:
|
| 439 |
+
candidates.append(workdir / Path(raw).relative_to("/app"))
|
| 440 |
+
except ValueError:
|
| 441 |
+
pass
|
| 442 |
+
if not any(c.exists() for c in candidates):
|
| 443 |
+
missing.append(raw)
|
| 444 |
+
return missing
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
# ------------------------------------------------- the environment's state ---
|
| 448 |
+
#
|
| 449 |
+
# The tasks in this benchmark are not file-editing tasks: they are a text
|
| 450 |
+
# environment (`python3 alf ...`) whose *own* output already carries the whole
|
| 451 |
+
# ground truth -- the step counter, whether the goal is solved, what is in every
|
| 452 |
+
# container, what the agent holds, and what has been cleaned/cooled/heated/placed.
|
| 453 |
+
# The harness used to append that output raw and throw the structure away. A 9B
|
| 454 |
+
# model then had to reconstruct "I have the bowl, I cleaned it, but I still have
|
| 455 |
+
# not put it in the fridge" from forty blocks of prose, and measured on 100 ALF
|
| 456 |
+
# tasks it did not: 47 runs were unsolved, and the failure was not ignorance --
|
| 457 |
+
# the target object had already been seen in 23 of them, and 30 of them declared
|
| 458 |
+
# `alf done` while the environment still printed `in progress`.
|
| 459 |
+
#
|
| 460 |
+
# So the loop now reads the environment's own report and gives it back compactly:
|
| 461 |
+
# the goal, the env step, what is held/processed/placed, and the one action that
|
| 462 |
+
# is next. That is context policy (skill item 3), not a new prompt constant.
|
| 463 |
+
|
| 464 |
+
_ALF_STEP_RE = re.compile(
|
| 465 |
+
r"\[alf\] step (\d+)/(\d+); (SOLVED|in progress|episode over)")
|
| 466 |
+
_ALF_OBJ_RE = re.compile(r"\b(?:a|an) ([a-z]+) (\d+)\b")
|
| 467 |
+
_ALF_DONE_RE = re.compile(r"\balf\s+done\b")
|
| 468 |
+
_ALF_DO_RE = re.compile(r"\balf\s+do\b")
|
| 469 |
+
|
| 470 |
+
#: Fixtures whose contents are only visible after an `open` action. `cart` is
|
| 471 |
+
#: deliberately NOT here: the environment shows its contents on arrival (the
|
| 472 |
+
#: traces have "go to cart 1 / On the cart 1, you see ..."), and suggesting
|
| 473 |
+
#: `open cart 1` costs an environment step for nothing.
|
| 474 |
+
_ALF_OPENABLE = frozenset({"cabinet", "drawer", "fridge", "microwave", "safe"})
|
| 475 |
+
_ALF_APPLIANCE = {"clean": "sinkbasin", "cool": "fridge",
|
| 476 |
+
"heat": "microwave", "light": "desklamp"}
|
| 477 |
+
|
| 478 |
+
#: Search order when the target has not been seen yet.
|
| 479 |
+
#:
|
| 480 |
+
#: Measured on the 100 incumbent ALF traces: 88 of the 99 targets whose first
|
| 481 |
+
#: location could be recovered were on a directly inspectable surface and only
|
| 482 |
+
#: 11 were inside an openable container. The old order was alphabetical, so it
|
| 483 |
+
#: visited every cabinet (two environment steps each: go, then open) before the
|
| 484 |
+
#: first countertop -- e.g. `pick_cool_then_place_in_recep-Potato-...` spent 40
|
| 485 |
+
#: of its 50 actions on closed cabinets before reaching the garbagecan holding
|
| 486 |
+
#: the potato, and `pick_clean_...-Apple-...` found the apple in the microwave
|
| 487 |
+
#: at env step 49 and had nothing left to clean or place it. Ordering by the
|
| 488 |
+
#: environment's own cost model (a surface costs one step, an openable container
|
| 489 |
+
#: costs two) and by how often each surface holds the goal object is the
|
| 490 |
+
#: exploration-policy repair, not a per-task hint.
|
| 491 |
+
_ALF_SURFACE_ORDER = (
|
| 492 |
+
"countertop", "diningtable", "desk", "bed", "dresser", "sidetable",
|
| 493 |
+
"shelf", "coffeemachine", "armchair", "handtowelholder", "garbagecan",
|
| 494 |
+
"toilet", "bathtubbasin", "stoveburner", "coffeetable", "sofa", "cart",
|
| 495 |
+
"toaster", "sinkbasin",
|
| 496 |
+
)
|
| 497 |
+
#: Openable containers: the one-instance appliance containers first (cheap to
|
| 498 |
+
#: exhaust, and they are plausible sources for a cool/heat goal object), then
|
| 499 |
+
#: the numerous bulk containers.
|
| 500 |
+
_ALF_OPENABLE_ORDER = ("fridge", "microwave", "safe", "cabinet", "drawer")
|
| 501 |
+
|
| 502 |
+
|
| 503 |
+
def _obj_base(obj: str) -> str:
|
| 504 |
+
return obj.split()[0].lower()
|
| 505 |
+
|
| 506 |
+
|
| 507 |
+
def _alf_mission(task: dict) -> dict | None:
|
| 508 |
+
"""Read target / destination / required state / budget from the goal prose.
|
| 509 |
+
|
| 510 |
+
ALFWorld goals have a fixed shape (`put a cool bowl in diningtable`,
|
| 511 |
+
`examine the book with the desklamp`). The words are the platform's own task
|
| 512 |
+
text, not a hard-coded object list; deriving them lets the harness repeat the
|
| 513 |
+
goal back to a small model instead of hoping it re-reads the system prompt.
|
| 514 |
+
Returns None for non-environment tasks, which leaves the generic loop alone.
|
| 515 |
+
"""
|
| 516 |
+
goal = str(task.get("goal") or "")
|
| 517 |
+
blob = goal + " " + str(task.get("initial_state") or "")
|
| 518 |
+
if "alf" not in blob.lower():
|
| 519 |
+
return None
|
| 520 |
+
m = re.search(r"Your task is to:\s*(.+?)(?:\n|\*\*|$)", goal, re.S)
|
| 521 |
+
if not m:
|
| 522 |
+
return None
|
| 523 |
+
raw = m.group(1).strip().strip("*").strip().rstrip(".").strip()
|
| 524 |
+
if not raw:
|
| 525 |
+
return None
|
| 526 |
+
low = raw.lower()
|
| 527 |
+
|
| 528 |
+
target = None
|
| 529 |
+
mt = re.search(r"\b(?:put|find)\s+(?:a|an|some|two|the)\s+"
|
| 530 |
+
r"(?:(?:clean|cool|hot|cold|warm)\s+)?([a-z]+)", low)
|
| 531 |
+
if not mt:
|
| 532 |
+
mt = re.search(r"\b(?:clean|cool|heat)\s+(?:a|an|some|two|the)\s+([a-z]+)", low)
|
| 533 |
+
if not mt:
|
| 534 |
+
mt = re.search(r"\b(?:examine|look at)\s+(?:the\s+)?([a-z]+)", low)
|
| 535 |
+
if mt:
|
| 536 |
+
target = mt.group(1)
|
| 537 |
+
if not target:
|
| 538 |
+
return None
|
| 539 |
+
|
| 540 |
+
kind = None
|
| 541 |
+
if "desklamp" in low:
|
| 542 |
+
kind, dest = "light", "desklamp"
|
| 543 |
+
else:
|
| 544 |
+
if re.search(r"\bclean\b", low):
|
| 545 |
+
kind = "clean"
|
| 546 |
+
elif re.search(r"\bcool\b|\bcold\b", low):
|
| 547 |
+
kind = "cool"
|
| 548 |
+
elif re.search(r"\bheat\b|\bhot\b", low):
|
| 549 |
+
kind = "heat"
|
| 550 |
+
md = re.search(r"\b(?:in|on|to)\s+(?:the\s+)?([a-z]+)\s*$", low)
|
| 551 |
+
dest = md.group(1) if md else None
|
| 552 |
+
if not dest:
|
| 553 |
+
return None
|
| 554 |
+
|
| 555 |
+
budget = None
|
| 556 |
+
for pat in (r"\*\*(\d+)\*\*\s+steps", r"(\d+)[- ]step budget",
|
| 557 |
+
r"budget of (\d+)", r"within the (\d+)"):
|
| 558 |
+
mb = re.search(pat, goal, re.I)
|
| 559 |
+
if mb:
|
| 560 |
+
budget = int(mb.group(1))
|
| 561 |
+
break
|
| 562 |
+
# The verifier's own `--budget` is authoritative: it is what the replay
|
| 563 |
+
# enforces, so the harness cap must be derived from it rather than guessed
|
| 564 |
+
# from prose when both are present.
|
| 565 |
+
try:
|
| 566 |
+
argv = (task.get("verifier") or {}).get("argv") or []
|
| 567 |
+
for i, arg in enumerate(argv):
|
| 568 |
+
if arg == "--budget" and i + 1 < len(argv):
|
| 569 |
+
budget = int(argv[i + 1])
|
| 570 |
+
break
|
| 571 |
+
except (TypeError, ValueError):
|
| 572 |
+
pass
|
| 573 |
+
if budget is None or budget < 1:
|
| 574 |
+
budget = 50
|
| 575 |
+
|
| 576 |
+
count = 2 if re.search(r"\btwo\b", low) else 1
|
| 577 |
+
return {"raw": raw, "target": target, "dest": dest, "kind": kind,
|
| 578 |
+
"count": count, "budget": budget}
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
class _AlfState:
|
| 582 |
+
"""Fold the environment's text into progress and the next required action."""
|
| 583 |
+
|
| 584 |
+
def __init__(self, mission: dict | None):
|
| 585 |
+
self.mission = mission
|
| 586 |
+
self.loc: str | None = None
|
| 587 |
+
self.objects: dict[str, str] = {} # object -> fixture it was last seen in
|
| 588 |
+
self.saw: dict[str, str] = {} # object -> fixture (never forgotten)
|
| 589 |
+
self.fixtures: dict[str, set[str]] = {}
|
| 590 |
+
self.held: set[str] = set()
|
| 591 |
+
self.transformed: dict[str, set[str]] = {}
|
| 592 |
+
self.moved_to: dict[str, str] = {}
|
| 593 |
+
self.placed: set[str] = set()
|
| 594 |
+
self.open: set[str] = set()
|
| 595 |
+
self.searched: set[str] = set()
|
| 596 |
+
self.visited: set[str] = set()
|
| 597 |
+
self.lamp_on = False
|
| 598 |
+
self.step = 0
|
| 599 |
+
self.budget = mission["budget"] if mission else 0
|
| 600 |
+
self.solved = False
|
| 601 |
+
self.invalid = False
|
| 602 |
+
self.last_cmd = ""
|
| 603 |
+
self.admissible: set[str] = set()
|
| 604 |
+
|
| 605 |
+
def observe(self, out: str, cmd: str = "") -> None:
|
| 606 |
+
self.last_cmd = cmd
|
| 607 |
+
self.invalid = "Nothing happens." in out if out else False
|
| 608 |
+
if not out:
|
| 609 |
+
return
|
| 610 |
+
if "SOLVED" in out:
|
| 611 |
+
self.solved = True
|
| 612 |
+
for m in _ALF_STEP_RE.finditer(out):
|
| 613 |
+
self.step = int(m.group(1))
|
| 614 |
+
self.budget = int(m.group(2))
|
| 615 |
+
if m.group(3) == "SOLVED":
|
| 616 |
+
self.solved = True
|
| 617 |
+
legal = re.search(r"Admissible actions:\s*\n(.*?)(?:\n\[alf\]|\Z)", out, re.S)
|
| 618 |
+
if legal:
|
| 619 |
+
self.admissible = {line.strip() for line in legal.group(1).splitlines()
|
| 620 |
+
if line.strip()}
|
| 621 |
+
for m in re.finditer(r"You (?:arrive at|are facing the|are at) ([a-z]+ \d+)", out):
|
| 622 |
+
self.loc = m.group(1)
|
| 623 |
+
self.visited.add(self.loc)
|
| 624 |
+
for m in re.finditer(r"The ([a-z]+ \d+) is (open|closed)", out):
|
| 625 |
+
if m.group(2) == "open":
|
| 626 |
+
self.open.add(m.group(1))
|
| 627 |
+
else:
|
| 628 |
+
self.open.discard(m.group(1))
|
| 629 |
+
for m in re.finditer(r"You open the ([a-z]+ \d+)", out):
|
| 630 |
+
self.open.add(m.group(1))
|
| 631 |
+
room = re.search(r"Looking quickly around you, you see (.*?)\.", out, re.S)
|
| 632 |
+
if room:
|
| 633 |
+
for m in re.finditer(r"\b([a-z]+) (\d+)\b", room.group(1)):
|
| 634 |
+
self.fixtures.setdefault(m.group(1), set()).add(f"{m.group(1)} {m.group(2)}")
|
| 635 |
+
for m in re.finditer(r"(?:On|In) the ([a-z]+ \d+), you see ([^.]*)\.", out):
|
| 636 |
+
self._add_objects(m.group(1), m.group(2))
|
| 637 |
+
if self.loc:
|
| 638 |
+
for m in re.finditer(r"In it, you see ([^.]*)\.", out):
|
| 639 |
+
self._add_objects(self.loc, m.group(1))
|
| 640 |
+
for m in re.finditer(r"You pick up the ([a-z]+ \d+) from the ([a-z]+ \d+)", out):
|
| 641 |
+
obj, loc = m.group(1), m.group(2)
|
| 642 |
+
self.held.add(obj)
|
| 643 |
+
self.objects.pop(obj, None)
|
| 644 |
+
self.saw[obj] = loc
|
| 645 |
+
self.searched.add(loc)
|
| 646 |
+
for m in re.finditer(r"You move the ([a-z]+ \d+) to the ([a-z]+ \d+)", out):
|
| 647 |
+
obj, loc = m.group(1), m.group(2)
|
| 648 |
+
self.held.discard(obj)
|
| 649 |
+
self.moved_to[obj] = loc
|
| 650 |
+
self.objects[obj] = loc
|
| 651 |
+
self.saw[obj] = loc
|
| 652 |
+
if self._is_dest(loc):
|
| 653 |
+
self.placed.add(obj)
|
| 654 |
+
for m in re.finditer(r"You (clean|cool|heat) the ([a-z]+ \d+) "
|
| 655 |
+
r"using the ([a-z]+ \d+)", out):
|
| 656 |
+
self.transformed.setdefault(m.group(2), set()).add(m.group(1))
|
| 657 |
+
for m in re.finditer(r"You turn on the ([a-z]+ \d+)", out):
|
| 658 |
+
if _obj_base(m.group(1)) == "desklamp":
|
| 659 |
+
self.lamp_on = True
|
| 660 |
+
if "You are not carrying anything." in out:
|
| 661 |
+
self.held.clear()
|
| 662 |
+
|
| 663 |
+
def _add_objects(self, loc: str, text: str) -> None:
|
| 664 |
+
# Seeing the contents means the fixture is open/accessible; that is how
|
| 665 |
+
# ALFWorld reports a drawer/cabinet that was never explicitly opened.
|
| 666 |
+
self.open.add(loc)
|
| 667 |
+
self.searched.add(loc)
|
| 668 |
+
for m in _ALF_OBJ_RE.finditer(text):
|
| 669 |
+
obj = f"{m.group(1)} {m.group(2)}"
|
| 670 |
+
self.objects[obj] = loc
|
| 671 |
+
self.saw[obj] = loc
|
| 672 |
+
|
| 673 |
+
def _is_dest(self, loc: str) -> bool:
|
| 674 |
+
return bool(loc and self.mission and _obj_base(loc) == self.mission["dest"])
|
| 675 |
+
|
| 676 |
+
def _completed(self) -> set[str]:
|
| 677 |
+
"""Targets actually done: placed at the destination *and* processed.
|
| 678 |
+
|
| 679 |
+
Measured: several failing runs moved an unprocessed object to the goal
|
| 680 |
+
location (an egg to the countertop without cooling it, a soapbar to the
|
| 681 |
+
cart without cleaning it). Counting a raw `move` as completion made the
|
| 682 |
+
progress helper stop guiding exactly one action early.
|
| 683 |
+
"""
|
| 684 |
+
kind = self.mission["kind"] if self.mission else None
|
| 685 |
+
return {o for o in self.placed
|
| 686 |
+
if not kind or kind in self.transformed.get(o, ())}
|
| 687 |
+
|
| 688 |
+
def _fixture(self, kind: str) -> str | None:
|
| 689 |
+
want = _ALF_APPLIANCE[kind]
|
| 690 |
+
if self.loc and _obj_base(self.loc) == want:
|
| 691 |
+
return self.loc
|
| 692 |
+
seen = set(self.fixtures.get(want) or ())
|
| 693 |
+
if not seen:
|
| 694 |
+
seen = {o for o in self.saw if _obj_base(o) == want}
|
| 695 |
+
if not seen:
|
| 696 |
+
return f"{want} 1"
|
| 697 |
+
return sorted(seen, key=lambda s: (s.split()[0], int(s.split()[1])))[0]
|
| 698 |
+
|
| 699 |
+
def _dest(self) -> str | None:
|
| 700 |
+
want = self.mission["dest"]
|
| 701 |
+
if self.loc and _obj_base(self.loc) == want:
|
| 702 |
+
return self.loc
|
| 703 |
+
seen = set(self.fixtures.get(want) or ())
|
| 704 |
+
if not seen:
|
| 705 |
+
seen = {o for o in self.saw if _obj_base(o) == want}
|
| 706 |
+
if seen:
|
| 707 |
+
return sorted(seen, key=lambda s: (s.split()[0], int(s.split()[1])))[0]
|
| 708 |
+
return f"{want} 1"
|
| 709 |
+
|
| 710 |
+
def _lamp(self) -> tuple[str | None, str | None]:
|
| 711 |
+
"""The desklamp is an object on a surface, not a navigable location."""
|
| 712 |
+
lamps = sorted(o for o in self.saw if _obj_base(o) == "desklamp")
|
| 713 |
+
for lamp in lamps:
|
| 714 |
+
if self.saw.get(lamp) == self.loc:
|
| 715 |
+
return lamp, self.loc
|
| 716 |
+
if lamps:
|
| 717 |
+
lamp = lamps[0]
|
| 718 |
+
return lamp, self.saw.get(lamp)
|
| 719 |
+
return None, None
|
| 720 |
+
|
| 721 |
+
def _legal(self, step: str) -> bool:
|
| 722 |
+
"""The environment prints the legal actions; never suggest one outside them.
|
| 723 |
+
|
| 724 |
+
The trace replays what actually ran, so an illegal suggestion costs a real
|
| 725 |
+
environment step ("Nothing happens.") for nothing. Measured over all 100
|
| 726 |
+
incumbent traces, the planner's raw suggestion was outside the printed
|
| 727 |
+
admissible list 105 times; most were `go to X` for a fixture that was
|
| 728 |
+
already accessible, or `open X` for a drawer that was already open.
|
| 729 |
+
"""
|
| 730 |
+
return not self.admissible or step in self.admissible
|
| 731 |
+
|
| 732 |
+
def _takeable_target(self) -> str | None:
|
| 733 |
+
base = self.mission["target"]
|
| 734 |
+
done = self._completed()
|
| 735 |
+
# The environment may expose a target in an already-open container
|
| 736 |
+
# without a separate `go to`; trust its own take action over our map.
|
| 737 |
+
for act in sorted(self.admissible):
|
| 738 |
+
parts = act.split()
|
| 739 |
+
if len(parts) >= 3 and parts[0] == "take" and parts[1] == base \
|
| 740 |
+
and f"{parts[1]} {parts[2]}" not in done:
|
| 741 |
+
return act
|
| 742 |
+
here = sorted(o for o, loc in self.objects.items()
|
| 743 |
+
if _obj_base(o) == base and loc == self.loc and o not in done)
|
| 744 |
+
if here:
|
| 745 |
+
step = f"take {here[0]} from {self.loc}"
|
| 746 |
+
if not self._fail(step) and self._legal(step):
|
| 747 |
+
return step
|
| 748 |
+
seen = sorted(((o, loc) for o, loc in self.saw.items()
|
| 749 |
+
if _obj_base(o) == base and o not in done
|
| 750 |
+
and o not in self.held), key=lambda x: x[1])
|
| 751 |
+
if seen:
|
| 752 |
+
obj, loc = seen[0]
|
| 753 |
+
if loc == self.loc:
|
| 754 |
+
step = f"take {obj} from {loc}"
|
| 755 |
+
return step if not self._fail(step) and self._legal(step) else None
|
| 756 |
+
step = f"go to {loc}"
|
| 757 |
+
return step if not self._fail(step) and self._legal(step) else None
|
| 758 |
+
return None
|
| 759 |
+
|
| 760 |
+
def _fail(self, step: str) -> bool:
|
| 761 |
+
"""True when this exact step just produced 'Nothing happens.'"""
|
| 762 |
+
return bool(self.invalid and step in self.last_cmd)
|
| 763 |
+
|
| 764 |
+
@staticmethod
|
| 765 |
+
def _fixture_index(inst: str) -> int:
|
| 766 |
+
try:
|
| 767 |
+
return int(inst.rsplit(" ", 1)[1])
|
| 768 |
+
except (IndexError, ValueError):
|
| 769 |
+
return 0
|
| 770 |
+
|
| 771 |
+
def _search_key(self, inst: str) -> tuple[int, int, int]:
|
| 772 |
+
"""Rank a fixture for the exploration order.
|
| 773 |
+
|
| 774 |
+
Tiers, not a magic constant: directly inspectable surfaces cost one
|
| 775 |
+
environment step, openable containers cost two, and the frequency order
|
| 776 |
+
encodes which surfaces the environment's object placements actually
|
| 777 |
+
favour. Unknown fixture types go last but are still searched.
|
| 778 |
+
"""
|
| 779 |
+
base = _obj_base(inst)
|
| 780 |
+
idx = self._fixture_index(inst)
|
| 781 |
+
if base in _ALF_SURFACE_ORDER:
|
| 782 |
+
return (0, _ALF_SURFACE_ORDER.index(base), idx)
|
| 783 |
+
if base in _ALF_OPENABLE_ORDER:
|
| 784 |
+
return (1, _ALF_OPENABLE_ORDER.index(base), idx)
|
| 785 |
+
return (2, 0, idx)
|
| 786 |
+
|
| 787 |
+
def _search_step(self) -> str | None:
|
| 788 |
+
"""A systematic next move when the target has not been seen yet."""
|
| 789 |
+
if self.loc and _obj_base(self.loc) in _ALF_OPENABLE and self.loc not in self.open:
|
| 790 |
+
step = f"open {self.loc}"
|
| 791 |
+
if not self._fail(step) and self._legal(step):
|
| 792 |
+
return step
|
| 793 |
+
unseen = [inst for typ, insts in self.fixtures.items() if typ != "desklamp"
|
| 794 |
+
for inst in insts if inst not in self.visited]
|
| 795 |
+
unseen.sort(key=self._search_key)
|
| 796 |
+
for inst in unseen:
|
| 797 |
+
step = f"go to {inst}"
|
| 798 |
+
if not self._fail(step) and self._legal(step):
|
| 799 |
+
return step
|
| 800 |
+
closed = [inst for typ in _ALF_OPENABLE
|
| 801 |
+
for inst in (self.fixtures.get(typ) or ()) if inst not in self.open]
|
| 802 |
+
closed.sort(key=self._search_key)
|
| 803 |
+
for inst in closed:
|
| 804 |
+
step = f"go to {inst}" if self.loc != inst else f"open {inst}"
|
| 805 |
+
if not self._fail(step) and self._legal(step):
|
| 806 |
+
return step
|
| 807 |
+
return None
|
| 808 |
+
|
| 809 |
+
def _held_other(self) -> list[str]:
|
| 810 |
+
"""Objects in hand that are not the goal object."""
|
| 811 |
+
if not self.mission:
|
| 812 |
+
return []
|
| 813 |
+
base = self.mission["target"]
|
| 814 |
+
return sorted(o for o in self.held if _obj_base(o) != base)
|
| 815 |
+
|
| 816 |
+
def _release_step(self) -> str | None:
|
| 817 |
+
"""Put down a wrong object so the target can be taken.
|
| 818 |
+
|
| 819 |
+
Measured (`pick_cool_then_place_in_recep-Pot-None-CounterTop-17`): the
|
| 820 |
+
model picked up a kettle on the way. `next_action` then alternated
|
| 821 |
+
forever between `go to stoveburner 1` (where the pot was visible) and
|
| 822 |
+
`go to <next unseen fixture>`, because the take was not admissible with
|
| 823 |
+
full hands, and burned the remaining 26 environment steps. The
|
| 824 |
+
environment's own admissible list already names the legal placement
|
| 825 |
+
(`move kettle 2 to cabinet 14`), so use it.
|
| 826 |
+
"""
|
| 827 |
+
others = self._held_other()
|
| 828 |
+
if not others:
|
| 829 |
+
return None
|
| 830 |
+
obj = others[0]
|
| 831 |
+
for act in sorted(self.admissible):
|
| 832 |
+
if act.startswith(f"move {obj} "):
|
| 833 |
+
return act
|
| 834 |
+
if self.loc:
|
| 835 |
+
step = f"move {obj} to {self.loc}"
|
| 836 |
+
if not self._fail(step) and self._legal(step):
|
| 837 |
+
return step
|
| 838 |
+
return None
|
| 839 |
+
|
| 840 |
+
def next_action(self) -> str | None:
|
| 841 |
+
if not self.mission or self.solved:
|
| 842 |
+
return None
|
| 843 |
+
m = self.mission
|
| 844 |
+
base = m["target"]
|
| 845 |
+
held = sorted(o for o in self.held if _obj_base(o) == base)
|
| 846 |
+
placed = sorted(o for o in self._completed() if _obj_base(o) == base)
|
| 847 |
+
|
| 848 |
+
release = self._release_step()
|
| 849 |
+
if release:
|
| 850 |
+
return release
|
| 851 |
+
|
| 852 |
+
if m["kind"] == "light":
|
| 853 |
+
lamp, lamp_loc = self._lamp()
|
| 854 |
+
if not self.lamp_on:
|
| 855 |
+
if lamp and lamp_loc == self.loc:
|
| 856 |
+
step = f"use {lamp}"
|
| 857 |
+
if not self._fail(step):
|
| 858 |
+
return step
|
| 859 |
+
# Acquire the target before a long trip to a lamp, unless the
|
| 860 |
+
# lamp is already in this room.
|
| 861 |
+
if not held:
|
| 862 |
+
step = self._takeable_target()
|
| 863 |
+
if step:
|
| 864 |
+
return step
|
| 865 |
+
if lamp_loc:
|
| 866 |
+
step = f"go to {lamp_loc}"
|
| 867 |
+
if not self._fail(step):
|
| 868 |
+
return step
|
| 869 |
+
return self._search_step()
|
| 870 |
+
if not held:
|
| 871 |
+
return self._takeable_target() or self._search_step()
|
| 872 |
+
# A held target with a lamp already on should satisfy the check; if
|
| 873 |
+
# it has not fired, examine the held object while at the lamp, which
|
| 874 |
+
# is the other admissible action for "look at X in the light".
|
| 875 |
+
if lamp and lamp_loc == self.loc:
|
| 876 |
+
return f"examine {held[0]}"
|
| 877 |
+
if lamp_loc:
|
| 878 |
+
step = f"go to {lamp_loc}"
|
| 879 |
+
if not self._fail(step):
|
| 880 |
+
return step
|
| 881 |
+
return None
|
| 882 |
+
|
| 883 |
+
if len(placed) < m["count"]:
|
| 884 |
+
if held:
|
| 885 |
+
obj = held[0]
|
| 886 |
+
if m["kind"] and m["kind"] not in self.transformed.get(obj, ()):
|
| 887 |
+
app = self._fixture(m["kind"])
|
| 888 |
+
if app and self.loc != app:
|
| 889 |
+
step = f"go to {app}"
|
| 890 |
+
if not self._fail(step):
|
| 891 |
+
return step
|
| 892 |
+
if app and app not in self.open and _obj_base(app) in _ALF_OPENABLE:
|
| 893 |
+
step = f"open {app}"
|
| 894 |
+
if not self._fail(step):
|
| 895 |
+
return step
|
| 896 |
+
if app:
|
| 897 |
+
step = f"{m['kind']} {obj} with {app}"
|
| 898 |
+
if not self._fail(step):
|
| 899 |
+
return step
|
| 900 |
+
dest = self._dest()
|
| 901 |
+
if dest and self.loc != dest:
|
| 902 |
+
step = f"go to {dest}"
|
| 903 |
+
if not self._fail(step):
|
| 904 |
+
return step
|
| 905 |
+
if dest and dest not in self.open and _obj_base(dest) in _ALF_OPENABLE:
|
| 906 |
+
step = f"open {dest}"
|
| 907 |
+
if not self._fail(step):
|
| 908 |
+
return step
|
| 909 |
+
if dest:
|
| 910 |
+
step = f"move {obj} to {dest}"
|
| 911 |
+
if not self._fail(step):
|
| 912 |
+
return step
|
| 913 |
+
else:
|
| 914 |
+
return self._takeable_target() or self._search_step()
|
| 915 |
+
return None
|
| 916 |
+
|
| 917 |
+
def _legal_fallback(self, step: str) -> str | None:
|
| 918 |
+
"""A legal action with the same purpose when the exact step is not listed."""
|
| 919 |
+
if self._legal(step):
|
| 920 |
+
return step
|
| 921 |
+
if not self.admissible or not self.mission:
|
| 922 |
+
return None
|
| 923 |
+
m = self.mission
|
| 924 |
+
base = m["target"]
|
| 925 |
+
verb = step.split()[0] if step else ""
|
| 926 |
+
held = [o for o in self.held if _obj_base(o) == base]
|
| 927 |
+
if verb == "take":
|
| 928 |
+
for act in sorted(self.admissible):
|
| 929 |
+
parts = act.split()
|
| 930 |
+
if len(parts) >= 2 and parts[0] == "take" and parts[1] == base:
|
| 931 |
+
return act
|
| 932 |
+
return None
|
| 933 |
+
if verb == "move" and held:
|
| 934 |
+
for act in sorted(self.admissible):
|
| 935 |
+
parts = act.split()
|
| 936 |
+
if len(parts) >= 5 and parts[0] == "move" \
|
| 937 |
+
and f"{parts[1]} {parts[2]}" == held[0] \
|
| 938 |
+
and parts[-2] == m["dest"]:
|
| 939 |
+
return act
|
| 940 |
+
return None
|
| 941 |
+
if verb in ("clean", "cool", "heat") and held:
|
| 942 |
+
for act in sorted(self.admissible):
|
| 943 |
+
parts = act.split()
|
| 944 |
+
if len(parts) >= 4 and parts[0] == verb \
|
| 945 |
+
and f"{parts[1]} {parts[2]}" == held[0]:
|
| 946 |
+
return act
|
| 947 |
+
return None
|
| 948 |
+
if verb == "use":
|
| 949 |
+
for act in sorted(self.admissible):
|
| 950 |
+
if act.startswith("use desklamp"):
|
| 951 |
+
return act
|
| 952 |
+
return None
|
| 953 |
+
if verb == "examine" and held:
|
| 954 |
+
for act in sorted(self.admissible):
|
| 955 |
+
if act == f"examine {held[0]}":
|
| 956 |
+
return act
|
| 957 |
+
return None
|
| 958 |
+
if verb == "open":
|
| 959 |
+
for act in sorted(self.admissible):
|
| 960 |
+
if act.startswith("open "):
|
| 961 |
+
return act
|
| 962 |
+
return None
|
| 963 |
+
if verb == "go to":
|
| 964 |
+
for act in sorted(self.admissible):
|
| 965 |
+
if act.startswith("go to "):
|
| 966 |
+
return act
|
| 967 |
+
return None
|
| 968 |
+
return None
|
| 969 |
+
|
| 970 |
+
def hint(self) -> str:
|
| 971 |
+
if not self.mission:
|
| 972 |
+
return ""
|
| 973 |
+
m = self.mission
|
| 974 |
+
lines = [f"[harness] Goal: {m['raw']}."]
|
| 975 |
+
lines.append(f"Environment step {self.step}/{self.budget} "
|
| 976 |
+
f"({'SOLVED' if self.solved else 'NOT solved'}).")
|
| 977 |
+
held = sorted(o for o in self.held if _obj_base(o) == m["target"])
|
| 978 |
+
done = self._completed()
|
| 979 |
+
placed = sorted(o for o in done if _obj_base(o) == m["target"])
|
| 980 |
+
raw_at_dest = sorted(o for o in self.placed
|
| 981 |
+
if _obj_base(o) == m["target"] and o not in done)
|
| 982 |
+
if held:
|
| 983 |
+
processed = " (processed)" if all(
|
| 984 |
+
not m["kind"] or m["kind"] in self.transformed.get(o, ())
|
| 985 |
+
for o in held) else ""
|
| 986 |
+
lines.append("Holding: " + ", ".join(held) + processed + ".")
|
| 987 |
+
others = self._held_other()
|
| 988 |
+
if others:
|
| 989 |
+
lines.append("Also holding (NOT the goal object): " + ", ".join(others)
|
| 990 |
+
+ " -- put it down first; full hands make the target untakeable.")
|
| 991 |
+
if placed:
|
| 992 |
+
lines.append(f"Already placed: {len(placed)}/{m['count']} "
|
| 993 |
+
+ ", ".join(placed) + ".")
|
| 994 |
+
if raw_at_dest:
|
| 995 |
+
lines.append("At the destination but NOT processed yet: "
|
| 996 |
+
+ ", ".join(raw_at_dest) + " (take it, process it, then place it).")
|
| 997 |
+
seen = sorted(o for o in self.saw if _obj_base(o) == m["target"]
|
| 998 |
+
and o not in done and o not in self.held
|
| 999 |
+
and o not in raw_at_dest)
|
| 1000 |
+
if seen and len(placed) + len(held) < m["count"]:
|
| 1001 |
+
lines.append("Target seen: "
|
| 1002 |
+
+ ", ".join(f"{o} at {self.saw[o]}" for o in seen[:6]) + ".")
|
| 1003 |
+
if self.invalid:
|
| 1004 |
+
lines.append("The last action did nothing and still cost an environment "
|
| 1005 |
+
"step; only use an action from the Admissible actions list.")
|
| 1006 |
+
nxt = self.next_action()
|
| 1007 |
+
if nxt and not self._legal(nxt):
|
| 1008 |
+
nxt = self._legal_fallback(nxt)
|
| 1009 |
+
if nxt and not self.solved:
|
| 1010 |
+
lines.append(f'Next required action: python3 alf do "{nxt}"')
|
| 1011 |
+
return "\n".join(lines)
|
| 1012 |
+
|
| 1013 |
+
|
| 1014 |
+
def _loop_budget(mission: dict | None) -> int:
|
| 1015 |
+
"""Shell steps for this task: the environment's budget plus free-command slack."""
|
| 1016 |
+
if mission:
|
| 1017 |
+
return min(max(MAX_STEPS, int(mission["budget"]) + STEP_SLACK), 200)
|
| 1018 |
+
return MAX_STEPS
|
| 1019 |
+
|
| 1020 |
+
|
| 1021 |
+
def _is_cycle(cmd: str, history: list[str]) -> bool:
|
| 1022 |
+
"""True when `cmd` continues a short cycle that is already in `history`.
|
| 1023 |
+
|
| 1024 |
+
The old repeat guard fired only when a command equaled the *immediately*
|
| 1025 |
+
previous one. Measured here: the model cycled `go to shelf 5`, `shelf 6`,
|
| 1026 |
+
`shelf 7` for 24 steps and no guard fired once. A cycle of period 2 or 3 is
|
| 1027 |
+
just as much a non-action as an immediate repeat, so break it before it is
|
| 1028 |
+
run (skill item 4: do not feed the repeat back as another observation).
|
| 1029 |
+
"""
|
| 1030 |
+
for period in (1, 2, 3):
|
| 1031 |
+
if period == 1:
|
| 1032 |
+
if history and history[-1] == cmd:
|
| 1033 |
+
return True
|
| 1034 |
+
continue
|
| 1035 |
+
if len(history) >= 2 * period and history[-period:] == history[-2 * period:-period] \
|
| 1036 |
+
and cmd == history[-period]:
|
| 1037 |
+
return True
|
| 1038 |
+
return False
|
| 1039 |
+
|
| 1040 |
+
|
| 1041 |
+
def _premature_finish_note(state: _AlfState, how: str) -> str:
|
| 1042 |
+
hint = state.hint()
|
| 1043 |
+
return (
|
| 1044 |
+
f"[harness] You tried to finish ({how}), but the environment has NOT printed "
|
| 1045 |
+
"SOLVED. The task is graded only by the actions replayed from "
|
| 1046 |
+
"alf_actions.jsonl, so stopping now scores zero. Do not answer or run "
|
| 1047 |
+
"`alf done` before the environment prints SOLVED.\n"
|
| 1048 |
+
+ (hint + "\n" if hint else "")
|
| 1049 |
+
+ "Continue now with exactly one action.")
|
| 1050 |
+
|
| 1051 |
+
|
| 1052 |
+
def _cycle_note(state: _AlfState) -> str:
|
| 1053 |
+
hint = state.hint()
|
| 1054 |
+
return ("[harness] That command was NOT run: the last actions form a repeating "
|
| 1055 |
+
"cycle, so running it again cannot change the environment. Choose a "
|
| 1056 |
+
"different action.\n" + (hint if hint else ""))
|
| 1057 |
+
|
| 1058 |
+
|
| 1059 |
+
def _clip_text(out: str, limit: int) -> str:
|
| 1060 |
+
if len(out) <= limit:
|
| 1061 |
+
return out
|
| 1062 |
+
marker = f"\n... [text clipped; original {len(out)} characters] ...\n"
|
| 1063 |
+
room = max(0, limit - len(marker))
|
| 1064 |
+
head = (room + 1) // 2
|
| 1065 |
+
tail = room // 2
|
| 1066 |
+
return (out[:head] + marker + (out[-tail:] if tail else ""))[:limit]
|
| 1067 |
+
|
| 1068 |
+
|
| 1069 |
+
def _json_preview(value: list | dict, limit: int) -> str | None:
|
| 1070 |
+
"""A bounded, valid JSON preview containing whole first/last entries."""
|
| 1071 |
+
mapping = isinstance(value, dict)
|
| 1072 |
+
items = list(value.items()) if mapping else value
|
| 1073 |
+
head, tail = [], []
|
| 1074 |
+
|
| 1075 |
+
def render():
|
| 1076 |
+
return json.dumps({"_harness_preview": {
|
| 1077 |
+
"total_items": len(items), "omitted_items": len(items) - len(head) - len(tail)},
|
| 1078 |
+
"head": dict(head) if mapping else head,
|
| 1079 |
+
"tail": dict(tail) if mapping else tail}, ensure_ascii=False, separators=(",", ":"))
|
| 1080 |
+
|
| 1081 |
+
shown = render()
|
| 1082 |
+
if len(shown) > limit:
|
| 1083 |
+
return None
|
| 1084 |
+
front, back = 0, len(items) - 1
|
| 1085 |
+
while front <= back:
|
| 1086 |
+
added = False
|
| 1087 |
+
head.append(items[front])
|
| 1088 |
+
candidate = render()
|
| 1089 |
+
if len(candidate) <= limit:
|
| 1090 |
+
shown = candidate
|
| 1091 |
+
front += 1
|
| 1092 |
+
added = True
|
| 1093 |
+
else:
|
| 1094 |
+
head.pop()
|
| 1095 |
+
if front <= back:
|
| 1096 |
+
tail.insert(0, items[back])
|
| 1097 |
+
candidate = render()
|
| 1098 |
+
if len(candidate) <= limit:
|
| 1099 |
+
shown = candidate
|
| 1100 |
+
back -= 1
|
| 1101 |
+
added = True
|
| 1102 |
+
else:
|
| 1103 |
+
tail.pop(0)
|
| 1104 |
+
if not added:
|
| 1105 |
+
break
|
| 1106 |
+
return shown
|
| 1107 |
+
|
| 1108 |
+
|
| 1109 |
+
def _clip_output(out: str) -> str:
|
| 1110 |
+
"""Compact leading JSON losslessly before bounding; retain whole list items.
|
| 1111 |
+
|
| 1112 |
+
Non-JSON suffixes (including shell errors) remain visible. The caller saves
|
| 1113 |
+
the original separately whenever this view differs from the output.
|
| 1114 |
+
"""
|
| 1115 |
+
if len(out) <= OUTPUT_LIMIT:
|
| 1116 |
+
return out
|
| 1117 |
+
stripped = out.lstrip()
|
| 1118 |
+
try:
|
| 1119 |
+
obj, end = json.JSONDecoder().raw_decode(stripped)
|
| 1120 |
+
except (ValueError, RecursionError):
|
| 1121 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 1122 |
+
if not isinstance(obj, (dict, list)):
|
| 1123 |
+
return _clip_text(out, OUTPUT_LIMIT)
|
| 1124 |
+
suffix = stripped[end:]
|
| 1125 |
+
compact = json.dumps(obj, ensure_ascii=False, separators=(",", ":")) + suffix
|
| 1126 |
+
if len(compact) <= OUTPUT_LIMIT:
|
| 1127 |
+
return compact
|
| 1128 |
+
preview = _json_preview(obj, OUTPUT_LIMIT - len(suffix))
|
| 1129 |
+
if preview is not None:
|
| 1130 |
+
return preview + suffix
|
| 1131 |
+
return _clip_text(compact, OUTPUT_LIMIT)
|
| 1132 |
+
|
| 1133 |
+
|
| 1134 |
+
def _shell_runtime() -> tuple[str, str]:
|
| 1135 |
+
"""Choose once before any task action; never retry side effects in another shell."""
|
| 1136 |
+
bash = shutil.which("bash")
|
| 1137 |
+
return (bash, "Bash") if bash else ("/bin/sh", "POSIX sh")
|
| 1138 |
+
|
| 1139 |
+
|
| 1140 |
+
def _trim_history(messages: list[dict], budget: int | None = None) -> int:
|
| 1141 |
+
"""丢最旧的成对消息,直到历史在 `budget`(默认 `CONTEXT_CHAR_BUDGET`)以内。返回丢掉的条数。
|
| 1142 |
+
|
| 1143 |
+
`messages[0]` 是 system,`messages[1]` 是题面,两者永不丢。之后严格成对
|
| 1144 |
+
(assistant 动作、user 结果),所以一次删两条,而不是一条 —— 删一条会让"结果"成为
|
| 1145 |
+
历史里的第一条,模型会读到一段没有对应动作的输出。
|
| 1146 |
+
|
| 1147 |
+
**为什么需要一个更小的 `budget` 参数。** 字符数不是 token 数,两者的比例随内容在
|
| 1148 |
+
2:1 到 4:1 之间浮动:代码、git 对象、base64 每 token 只有一两个字符,英文散文有
|
| 1149 |
+
四个。实测(2026-10-04,`local-screen-1`):60000 字符的历史在 `git-leak-recovery` 和
|
| 1150 |
+
`regex-chess` 上被 vLLM 判为 "at least 32769 input tokens" —— 字符预算满足了,token
|
| 1151 |
+
预算没有。所以唯一可靠的判据是**模型自己说的**那个错误:`_call_openai` 收到它就按
|
| 1152 |
+
一半预算再削一次历史并重试,而不是让整道题死掉。
|
| 1153 |
+
"""
|
| 1154 |
+
limit = CONTEXT_CHAR_BUDGET if budget is None else budget
|
| 1155 |
+
dropped = 0
|
| 1156 |
+
while len(messages) > 4 and \
|
| 1157 |
+
sum(len(m.get("content") or "") for m in messages) > limit:
|
| 1158 |
+
del messages[2:4]
|
| 1159 |
+
dropped += 2
|
| 1160 |
+
return dropped
|
| 1161 |
+
|
| 1162 |
+
|
| 1163 |
+
#: 模型拒绝一条 prompt 时的两种说法(vLLM/OpenAI 兼容端点各一种)。判据是模型自己的措辞,
|
| 1164 |
+
#: 不是我们对 token 的估算 —— 估错了会削掉本该保留的历史,或者留下一个必然失败的长度。
|
| 1165 |
+
_CONTEXT_ERROR_MARKERS = ("maximum context length", "context length is", "context_length_exceeded",
|
| 1166 |
+
"reduce the length of the input prompt")
|
| 1167 |
+
|
| 1168 |
+
|
| 1169 |
+
def run(task: dict, workdir: Path) -> str:
|
| 1170 |
+
"""Execute one task. Returns the answer string.
|
| 1171 |
+
|
| 1172 |
+
The trace written to <workdir>/trace.jsonl is what the framework collects
|
| 1173 |
+
and hands to the Trainer (INTERFACE.md §4.1).
|
| 1174 |
+
"""
|
| 1175 |
+
trace_path = workdir / "trace.jsonl"
|
| 1176 |
+
shell, dialect = _shell_runtime()
|
| 1177 |
+
mission = _alf_mission(task)
|
| 1178 |
+
state = _AlfState(mission)
|
| 1179 |
+
max_steps = _loop_budget(mission)
|
| 1180 |
+
environment_note = ""
|
| 1181 |
+
if mission:
|
| 1182 |
+
environment_note = (
|
| 1183 |
+
"\nThis task is an interactive text environment reached through `python3 alf`.\n"
|
| 1184 |
+
"- `python3 alf look` is free and prints the current room plus the exact "
|
| 1185 |
+
"admissible actions. `python3 alf do \"...\"` costs one of the environment's "
|
| 1186 |
+
f"{mission['budget']} steps.\n"
|
| 1187 |
+
"- The environment prints `SOLVED` only when the goal is actually met. Never "
|
| 1188 |
+
"answer or run `alf done` before you see `SOLVED`.\n"
|
| 1189 |
+
"- After each step the harness prints your goal progress and the next required "
|
| 1190 |
+
"action; follow it unless you have a concrete reason not to.\n")
|
| 1191 |
+
messages = [
|
| 1192 |
+
{"role": "system", "content": SYSTEM + environment_note + (
|
| 1193 |
+
f"\nShell runtime: {shell} -c ({dialect}). Each command starts a new shell.\n"
|
| 1194 |
+
+ ("Bash arrays and PIPESTATUS are supported.\n" if dialect == "Bash" else
|
| 1195 |
+
"Use POSIX syntax; Bash arrays, PIPESTATUS and [[ ]] are unavailable.\n"))},
|
| 1196 |
+
{"role": "user", "content": json.dumps(task)},
|
| 1197 |
+
]
|
| 1198 |
+
|
| 1199 |
+
answer = ""
|
| 1200 |
+
submits = 0
|
| 1201 |
+
parse_retries = 0
|
| 1202 |
+
premature_finishes = 0
|
| 1203 |
+
cycle_blocks = 0
|
| 1204 |
+
alf_history: list[str] = []
|
| 1205 |
+
cmd_history: list[str] = []
|
| 1206 |
+
output_dir = None
|
| 1207 |
+
# **行缓冲,不是默认的 8KB 块缓冲。** 实测(2026-10-04,本地模型跑 `bn-fit-modify`):
|
| 1208 |
+
# harness 已经跑了 8 分钟、正在装 pandas,而 `/app/trace.jsonl` 是 0 字节、打开的 fd
|
| 1209 |
+
# `pos: 0` —— 一行都还没落盘。代价有三条:
|
| 1210 |
+
# * 实时的轨迹看不见,面板和调试都只能等它结束;
|
| 1211 |
+
# * 被超时杀掉的题会丢掉缓冲区里的尾巴(≤8KB)。一般长跑无所谓(`adaptive-rejection-sampler`
|
| 1212 |
+
# 那次写了 1MB,尾巴只占零头),但一道死在第一个命令里的题,尾巴就是**全部**;
|
| 1213 |
+
# * `harness_failed` 的判据是"轨迹为空",于是"被杀"和"从没跑起来"在记录里同形。
|
| 1214 |
+
# 行缓冲每写一行就落盘,这三条一起消失,代价是一次 write 系统调用。
|
| 1215 |
+
with trace_path.open("w", buffering=1) as trace:
|
| 1216 |
+
# **这份 harness 自己声明它的运行时预算。**
|
| 1217 |
+
#
|
| 1218 |
+
# 平台从外面只能看见 harness 目录的哈希。可哈希相同、行为不同的两份 harness 是
|
| 1219 |
+
# 存在的:`HG_AGENT_MAX_STEPS=16` 和 `=32` 跑同一个文件,一条轨迹 16 步就停、
|
| 1220 |
+
# 另一条能跑 32 步 —— 实测(2026-10-04,本地 9B 跑 `build-pmars`)32 步需要约
|
| 1221 |
+
# 1100 秒,超过题目自带的 900 秒预算,于是它超时;16 步则跑得完。这两次测量的
|
| 1222 |
+
# 曲线点上原来没有任何一个字段不同,读者无法分辨"同一外壳跑两次"和"两个预算
|
| 1223 |
+
# 各跑一次"。
|
| 1224 |
+
#
|
| 1225 |
+
# 所以这里声明一次,由平台记到曲线点上(`harnessgrad/identity.py:harness_config`)。
|
| 1226 |
+
# 同时声明 model/backend:这个 harness 读 `HG_AGENT_MODEL`,但只有它自己知道读到
|
| 1227 |
+
# 了什么,平台的环境变量在别处会因改名而与实际不符(INTERFACE.md §3)。
|
| 1228 |
+
identity = {"harness": "loop", "config": {
|
| 1229 |
+
"max_steps": max_steps,
|
| 1230 |
+
"env_budget": mission["budget"] if mission else None,
|
| 1231 |
+
"step_slack": STEP_SLACK if mission else 0,
|
| 1232 |
+
"submit_retries": SUBMIT_RETRIES,
|
| 1233 |
+
"parse_retries": PARSE_RETRIES, "finish_nudge_steps": FINISH_NUDGE_STEPS,
|
| 1234 |
+
"repeat_nudge_limit": REPEAT_NUDGE_LIMIT, "output_limit": OUTPUT_LIMIT,
|
| 1235 |
+
"context_chars": CONTEXT_CHAR_BUDGET,
|
| 1236 |
+
"shell": shell, "shell_dialect": dialect,
|
| 1237 |
+
"max_output_tokens": MAX_OUTPUT_TOKENS}}
|
| 1238 |
+
for key, value in (("agent_model", os.environ.get("HG_AGENT_MODEL")),
|
| 1239 |
+
("agent_backend", _backend())):
|
| 1240 |
+
if value:
|
| 1241 |
+
identity[key] = value
|
| 1242 |
+
trace.write(json.dumps({"harness_identity": identity}) + "\n")
|
| 1243 |
+
# **每一步的时间去哪了。** 实测(2026-10-04):本地 9B 跑 `build-pmars`,26 步撞上
|
| 1244 |
+
# 题目自带的 900 秒预算被杀。可它是"模型慢"还是"命令慢",记录里看不出来 —— trace
|
| 1245 |
+
# 只有步数,没有任何时间字段。这两件事的平台处置完全相反:模型慢要缩步数上限或
|
| 1246 |
+
# 换模型,命令慢是这道题自己的成本(装依赖),换模型没用。
|
| 1247 |
+
#
|
| 1248 |
+
# 所以每步记两个毫秒数:等模型的时间、跑命令的时间。总和不等于墙钟时,差额就是
|
| 1249 |
+
# harness 自己的开销,那也是要看得见的东西。
|
| 1250 |
+
started = time.time()
|
| 1251 |
+
model_s = command_s = 0.0
|
| 1252 |
+
trims_before = USAGE["context_trims"]
|
| 1253 |
+
for step in range(max_steps):
|
| 1254 |
+
dropped = _trim_history(messages)
|
| 1255 |
+
if dropped:
|
| 1256 |
+
trace.write(json.dumps({"step": step, "history_dropped": dropped}) + "\n")
|
| 1257 |
+
t0 = time.time()
|
| 1258 |
+
reply = _complete(messages)
|
| 1259 |
+
took = time.time() - t0
|
| 1260 |
+
model_s += took
|
| 1261 |
+
trace.write(json.dumps({"step": step, "reply": reply,
|
| 1262 |
+
"model_ms": int(took * 1000)}) + "\n")
|
| 1263 |
+
# 这一步的 prompt 被模型拒绝过,harness 因此削短了历史再问。模型这一步看到的
|
| 1264 |
+
# 历史比上一步短 —— 不记下来的话,"它为什么换了做法"在 trace 里没有答案。
|
| 1265 |
+
if USAGE["context_trims"] > trims_before:
|
| 1266 |
+
trace.write(json.dumps({
|
| 1267 |
+
"step": step, "context_trims": USAGE["context_trims"],
|
| 1268 |
+
"history_kept": len(messages)}) + "\n")
|
| 1269 |
+
trims_before = USAGE["context_trims"]
|
| 1270 |
+
messages.append({"role": "assistant", "content": reply})
|
| 1271 |
+
|
| 1272 |
+
try:
|
| 1273 |
+
action = _parse(reply)
|
| 1274 |
+
except Exception as exc:
|
| 1275 |
+
# 退回给模型,而不是结束整道题。trace 里记下第几次重试,因为平台看不到
|
| 1276 |
+
# 容器内部:没有这条记录,一次"读不懂的回复"在记录里和一次"一步就交卷"
|
| 1277 |
+
# 长得一样。次数用完仍然是 harness 失败(它确实读不出动作),但那时记录
|
| 1278 |
+
# 里已经有 N 次尝试,而不是一次。
|
| 1279 |
+
trace.write(json.dumps({"step": step, "parse_error": str(exc),
|
| 1280 |
+
"parse_retry": parse_retries}) + "\n")
|
| 1281 |
+
if parse_retries >= PARSE_RETRIES:
|
| 1282 |
+
break
|
| 1283 |
+
parse_retries += 1
|
| 1284 |
+
# Keep the full failed reply in the trace, not as an example for
|
| 1285 |
+
# the next completion to copy. In particular, token-cut commands
|
| 1286 |
+
# should be shortened by the model, never completed by the parser.
|
| 1287 |
+
messages[-1]["content"] = "[Unparseable reply omitted; see trace.jsonl.]"
|
| 1288 |
+
messages.append({"role": "user", "content": (
|
| 1289 |
+
f"Your reply could not be read as an action: {exc}\n"
|
| 1290 |
+
"Nothing was executed. It may have been cut off by the output token limit.\n"
|
| 1291 |
+
"Send one short command; use a loop/script instead of enumerating calls.\n"
|
| 1292 |
+
f"You have {max_steps - step - 1} step(s) left.\n"
|
| 1293 |
+
"Reply with EXACTLY ONE JSON object and nothing else, one of:\n"
|
| 1294 |
+
' {"tool": "bash", "command": "<shell command>"}\n'
|
| 1295 |
+
' {"answer": "<your final answer>"}\n'
|
| 1296 |
+
'For structured predictions, put the complete JSON object in "answer"; '
|
| 1297 |
+
'preserve the task\'s prediction schema.')})
|
| 1298 |
+
continue
|
| 1299 |
+
|
| 1300 |
+
parse_retries = 0
|
| 1301 |
+
# Prose or echoed data before a recovered action is not part of the
|
| 1302 |
+
# executed command. Store only the parsed action in model history.
|
| 1303 |
+
messages[-1]["content"] = json.dumps(action)
|
| 1304 |
+
|
| 1305 |
+
# **修过的地方要留痕。** 重复键的回复被解析成"第一个值放前面"之后,模型看到的
|
| 1306 |
+
# 命令和它写的不完全一样(它写了两遍,harness 取了第一遍)。一次被静默改写的
|
| 1307 |
+
# 动作和一次原样执行的动作不是同一件事,记录里必须分开。
|
| 1308 |
+
repaired = getattr(action, "duplicates", ())
|
| 1309 |
+
if repaired:
|
| 1310 |
+
trace.write(json.dumps({"step": step,
|
| 1311 |
+
"duplicate_keys": list(repaired)}) + "\n")
|
| 1312 |
+
|
| 1313 |
+
# **交卷闸门。** 顺序按"它想干什么"判断,而不是按哪个键先出现:
|
| 1314 |
+
# 一条回复里同时带 command 和 answer 时,以前"先看 answer"会让那条命令
|
| 1315 |
+
# 永远不执行(实测:`{"tool":"bash","command":"cat > /app/run.py …"}` 被当成
|
| 1316 |
+
# 空答案,文件从未创建)。所以:有命令就先执行命令;只有**没有**命令时才算交卷。
|
| 1317 |
+
cmd = action.get("command", "")
|
| 1318 |
+
if not cmd and "answer" in action:
|
| 1319 |
+
# The environment, not the model, decides whether this task is done.
|
| 1320 |
+
# Measured: 30 of 47 unsolved ALF runs ran `alf done` and submitted a
|
| 1321 |
+
# confident answer while the environment still printed `in progress`.
|
| 1322 |
+
# Accepting that answer throws away the remaining environment budget;
|
| 1323 |
+
# pushing back with the goal state gives the model the step it needed.
|
| 1324 |
+
if mission and not state.solved \
|
| 1325 |
+
and state.step < state.budget \
|
| 1326 |
+
and premature_finishes < SUBMIT_RETRIES + 1:
|
| 1327 |
+
premature_finishes += 1
|
| 1328 |
+
trace.write(json.dumps({"step": step, "premature_finish": "answer",
|
| 1329 |
+
"env_step": state.step}) + "\n")
|
| 1330 |
+
messages.append({"role": "user",
|
| 1331 |
+
"content": _premature_finish_note(state, "answer")})
|
| 1332 |
+
continue
|
| 1333 |
+
missing = _missing_deliverables(task, workdir)
|
| 1334 |
+
if missing and submits < SUBMIT_RETRIES:
|
| 1335 |
+
submits += 1
|
| 1336 |
+
note = ("You answered but these paths the task asks for do not exist: "
|
| 1337 |
+
+ ", ".join(missing)
|
| 1338 |
+
+ ". Create them first, then answer again.")
|
| 1339 |
+
trace.write(json.dumps({"step": step, "submit_rejected": missing}) + "\n")
|
| 1340 |
+
messages.append({"role": "user", "content": note})
|
| 1341 |
+
continue
|
| 1342 |
+
trace.write(json.dumps({"step": step, "submitted": True,
|
| 1343 |
+
"missing": missing}) + "\n")
|
| 1344 |
+
answer = _answer_text(action["answer"])
|
| 1345 |
+
break
|
| 1346 |
+
|
| 1347 |
+
# `alf done` is the model declaring completion, not the environment
|
| 1348 |
+
# reporting it. The verifier replays only the actions, so a premature
|
| 1349 |
+
# done is pure loss; refuse it and show what is still missing.
|
| 1350 |
+
if mission and not state.solved and _ALF_DONE_RE.search(cmd) \
|
| 1351 |
+
and not _ALF_DO_RE.search(cmd) \
|
| 1352 |
+
and state.step < state.budget \
|
| 1353 |
+
and premature_finishes < SUBMIT_RETRIES + 1:
|
| 1354 |
+
premature_finishes += 1
|
| 1355 |
+
trace.write(json.dumps({"step": step, "premature_finish": "alf done",
|
| 1356 |
+
"env_step": state.step}) + "\n")
|
| 1357 |
+
messages.append({"role": "user",
|
| 1358 |
+
"content": _premature_finish_note(state, "alf done")})
|
| 1359 |
+
continue
|
| 1360 |
+
|
| 1361 |
+
# Break a cycle *before* it executes: feeding the same observation back
|
| 1362 |
+
# is what let one run spend 24 steps walking shelf 5 -> 6 -> 7 -> 5.
|
| 1363 |
+
# Environment actions are compared among themselves (a free `alf look`
|
| 1364 |
+
# must not hide a cycle); every other command is compared against the
|
| 1365 |
+
# full command history, which preserves the old immediate-repeat guard.
|
| 1366 |
+
is_alf_action = bool(mission and _ALF_DO_RE.search(cmd))
|
| 1367 |
+
history = alf_history if is_alf_action else cmd_history
|
| 1368 |
+
if _is_cycle(cmd, history) and cycle_blocks < REPEAT_NUDGE_LIMIT * 3:
|
| 1369 |
+
cycle_blocks += 1
|
| 1370 |
+
trace.write(json.dumps({"step": step, "repeat_blocked": cmd[:160],
|
| 1371 |
+
"env_step": state.step}) + "\n")
|
| 1372 |
+
messages.append({"role": "user", "content": (
|
| 1373 |
+
_cycle_note(state) if mission else
|
| 1374 |
+
"[harness] That command was NOT run because it repeats a command "
|
| 1375 |
+
"that is already in the conversation; running it again cannot "
|
| 1376 |
+
"change the result. Choose a different action.")})
|
| 1377 |
+
continue
|
| 1378 |
+
if is_alf_action:
|
| 1379 |
+
alf_history.append(cmd.strip())
|
| 1380 |
+
if len(alf_history) > 12:
|
| 1381 |
+
del alf_history[:-12]
|
| 1382 |
+
cmd_history.append(cmd.strip())
|
| 1383 |
+
if len(cmd_history) > 12:
|
| 1384 |
+
del cmd_history[:-12]
|
| 1385 |
+
|
| 1386 |
+
t0 = time.time()
|
| 1387 |
+
proc = subprocess.run(
|
| 1388 |
+
# `errors="replace"`: a command may emit arbitrary bytes, and a strict decode
|
| 1389 |
+
# raises UnicodeDecodeError inside the harness, which ends the episode and is
|
| 1390 |
+
# recorded as a zero for a task nobody finished. Measured 2026-10-15.
|
| 1391 |
+
[shell, "-c", cmd], cwd=workdir, capture_output=True, text=True,
|
| 1392 |
+
errors="replace"
|
| 1393 |
+
)
|
| 1394 |
+
took = time.time() - t0
|
| 1395 |
+
command_s += took
|
| 1396 |
+
out = proc.stdout + proc.stderr
|
| 1397 |
+
trace.write(json.dumps({"step": step, "command": cmd,
|
| 1398 |
+
"exit": proc.returncode,
|
| 1399 |
+
"shell": shell,
|
| 1400 |
+
"command_ms": int(took * 1000), "output": out}) + "\n")
|
| 1401 |
+
shown = _clip_output(out)
|
| 1402 |
+
output_note = ""
|
| 1403 |
+
if shown != out:
|
| 1404 |
+
if output_dir is None:
|
| 1405 |
+
import tempfile
|
| 1406 |
+
output_dir = Path(tempfile.mkdtemp(prefix=".hg-output-", dir=workdir))
|
| 1407 |
+
saved = output_dir / f"step-{step}.txt"
|
| 1408 |
+
saved.write_text(out)
|
| 1409 |
+
relative = saved.relative_to(workdir)
|
| 1410 |
+
output_note = (f"\nFull output: {relative} (use shell tools to inspect/filter it).\n"
|
| 1411 |
+
"The view below may omit records; omitted does not mean absent.\n")
|
| 1412 |
+
trace.write(json.dumps({"step": step, "output_clipped": len(out),
|
| 1413 |
+
"shown": len(shown), "output_file": str(relative),
|
| 1414 |
+
"output_view": shown}) + "\n")
|
| 1415 |
+
state.observe(out, cmd)
|
| 1416 |
+
# A real environment action is progress; give the model a fresh set of
|
| 1417 |
+
# push-backs if it later tries to finish early again.
|
| 1418 |
+
if mission and _ALF_DO_RE.search(cmd):
|
| 1419 |
+
premature_finishes = 0
|
| 1420 |
+
observation = f"exit={proc.returncode}{output_note}\n{shown}"
|
| 1421 |
+
hint = state.hint() if mission else ""
|
| 1422 |
+
if hint:
|
| 1423 |
+
observation += "\n\n" + hint
|
| 1424 |
+
messages.append({"role": "user", "content": observation})
|
| 1425 |
+
|
| 1426 |
+
# The environment said SOLVED. Stop immediately: the verifier replays
|
| 1427 |
+
# the actions that are already in alf_actions.jsonl, so more calls can
|
| 1428 |
+
# only add noise (and the old loop answered after this with a boolean
|
| 1429 |
+
# and burned its parse retries for nothing).
|
| 1430 |
+
if mission and state.solved:
|
| 1431 |
+
trace.write(json.dumps({"step": step, "environment_solved": True,
|
| 1432 |
+
"env_step": state.step}) + "\n")
|
| 1433 |
+
answer = json.dumps({"task_id": task.get("task_id"),
|
| 1434 |
+
"status": "solved"})
|
| 1435 |
+
break
|
| 1436 |
+
|
| 1437 |
+
# The environment's own action budget is spent; no further action can
|
| 1438 |
+
# be graded as progress, so stop instead of answering after the cap.
|
| 1439 |
+
if mission and state.step >= state.budget:
|
| 1440 |
+
trace.write(json.dumps({"step": step, "environment_exhausted": True,
|
| 1441 |
+
"env_step": state.step}) + "\n")
|
| 1442 |
+
answer = json.dumps({"task_id": task.get("task_id"),
|
| 1443 |
+
"status": "environment budget exhausted"})
|
| 1444 |
+
break
|
| 1445 |
+
|
| 1446 |
+
left = max_steps - (step + 1)
|
| 1447 |
+
# 只在进入收尾区和最后一步各说一次:每一步都重复同一句话不会更有用,
|
| 1448 |
+
# 只会把最近几轮的命令输出挤远。
|
| 1449 |
+
if left and (left == FINISH_NUDGE_STEPS or left == 1):
|
| 1450 |
+
trace.write(json.dumps({"step": step, "finish_nudge": left}) + "\n")
|
| 1451 |
+
if mission:
|
| 1452 |
+
messages[-1]["content"] += "\n" + (
|
| 1453 |
+
f"You have {left} shell step(s) left; the environment is at "
|
| 1454 |
+
f"step {state.step}/{state.budget}. Follow the Next required "
|
| 1455 |
+
"action and do not answer before the environment prints SOLVED.")
|
| 1456 |
+
else:
|
| 1457 |
+
messages[-1]["content"] += "\n" + (
|
| 1458 |
+
f"You have {left} step(s) left. Stop exploring. Create every file the "
|
| 1459 |
+
"task asks for now, then reply with exactly one JSON object: "
|
| 1460 |
+
'{"answer": "<your final answer>"}')
|
| 1461 |
+
|
| 1462 |
+
# Where the wall clock went. Separate from `usage` (which counts tokens):
|
| 1463 |
+
# a reader asking "was this killed for being slow, and slow at what" gets one
|
| 1464 |
+
# line, and a harness that is slow on its own shows up as `total` exceeding
|
| 1465 |
+
# model + commands.
|
| 1466 |
+
trace.write(json.dumps({"wall_clock_s": {
|
| 1467 |
+
"model": round(model_s, 1), "commands": round(command_s, 1),
|
| 1468 |
+
"total": round(time.time() - started, 1)}}) + "\n")
|
| 1469 |
+
|
| 1470 |
+
# What the run cost. Kept because a harness that cannot say what it spent
|
| 1471 |
+
# cannot be compared with a cheaper one at the same score -- and because
|
| 1472 |
+
# `USAGE` is the only place the model calls are counted.
|
| 1473 |
+
trace.write(json.dumps({"usage": dict(USAGE)}) + "\n")
|
| 1474 |
+
|
| 1475 |
+
(workdir / "answer.txt").write_text(answer)
|
| 1476 |
+
return answer
|
| 1477 |
+
|
| 1478 |
+
|
| 1479 |
+
def main() -> int:
|
| 1480 |
+
ap = argparse.ArgumentParser()
|
| 1481 |
+
ap.add_argument("--task", required=True)
|
| 1482 |
+
ap.add_argument("--workdir", required=True)
|
| 1483 |
+
args = ap.parse_args()
|
| 1484 |
+
|
| 1485 |
+
task = json.loads(Path(args.task).read_text())
|
| 1486 |
+
run(task, Path(args.workdir))
|
| 1487 |
+
return 0
|
| 1488 |
+
|
| 1489 |
+
|
| 1490 |
+
if __name__ == "__main__":
|
| 1491 |
+
sys.exit(main())
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-3/harness.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "loop",
|
| 3 |
+
"version": "0.2.0",
|
| 4 |
+
"path": ".",
|
| 5 |
+
"entrypoint": "agent.py",
|
| 6 |
+
"backend": "cli",
|
| 7 |
+
"install": "requirements.txt",
|
| 8 |
+
"env_kinds": [
|
| 9 |
+
"files",
|
| 10 |
+
"exec"
|
| 11 |
+
]
|
| 12 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/harness/round-3/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
openai>=1.0
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/meta/round-1.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31303f7d460abf54ebed264277e1bbdde972d0e02213b3187e1e9704f70c3d70
|
| 3 |
+
size 128414
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/meta/round-2.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:593ee9e115ebed68b80896fc0238bb27f1d2d6d65074f25ce8502a21794768b4
|
| 3 |
+
size 130754
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-1.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"round": 1,
|
| 3 |
+
"from": "7a40f6ddd0cef5c7210c1be3dc6529cc19c03775",
|
| 4 |
+
"to": "f12a20d8bbf45c990c0da5b7a6fcdf244571e2a1",
|
| 5 |
+
"files": [
|
| 6 |
+
{
|
| 7 |
+
"path": "agent.py",
|
| 8 |
+
"added": 668,
|
| 9 |
+
"removed": 36
|
| 10 |
+
}
|
| 11 |
+
],
|
| 12 |
+
"added": 668,
|
| 13 |
+
"removed": 36
|
| 14 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-1.patch
ADDED
|
@@ -0,0 +1,799 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
| 1 |
+
diff --git a/agent.py b/agent.py
|
| 2 |
+
index 45522cd..0528d9e 100644
|
| 3 |
+
--- a/agent.py
|
| 4 |
+
+++ b/agent.py
|
| 5 |
+
@@ -34,6 +34,7 @@ from __future__ import annotations
|
| 6 |
+
import argparse
|
| 7 |
+
import json
|
| 8 |
+
import os
|
| 9 |
+
+import re
|
| 10 |
+
import shutil
|
| 11 |
+
import subprocess
|
| 12 |
+
import sys
|
| 13 |
+
@@ -65,6 +66,17 @@ MAX_OUTPUT_TOKENS = int(os.environ.get("HG_AGENT_MAX_OUTPUT_TOKENS", "2048"))
|
| 14 |
+
if MAX_OUTPUT_TOKENS < 1:
|
| 15 |
+
raise ValueError("HG_AGENT_MAX_OUTPUT_TOKENS must be positive")
|
| 16 |
+
|
| 17 |
+
+#: Extra shell steps granted on top of the environment's **own** action budget.
|
| 18 |
+
+#:
|
| 19 |
+
+#: The failure this repairs is not "32 is too few": it is that the harness had a
|
| 20 |
+
+#: global cap while the environment declares its own budget in the goal text
|
| 21 |
+
+#: (`**50** steps`). A run could therefore spend 32 shell steps, of which only
|
| 22 |
+
+#: some are environment actions, and be killed by the harness while the
|
| 23 |
+
+#: environment still had most of its budget left. The cap is derived per task
|
| 24 |
+
+#: from that declared number; the slack pays for the free commands (`alf look`)
|
| 25 |
+
+#: and for the harness's own push-backs. It is not a tuning knob.
|
| 26 |
+
+STEP_SLACK = int(os.environ.get("HG_AGENT_STEP_SLACK", "16"))
|
| 27 |
+
+
|
| 28 |
+
#: 模型说"我做完了"之后,允许它再被退回几次。
|
| 29 |
+
#:
|
| 30 |
+
#: 为什么需要这个:harness 以前**从不检查交付物**。模型回一句 {"answer": ...} 就被当成
|
| 31 |
+
@@ -381,17 +393,23 @@ def _answer_text(value: object) -> str:
|
| 32 |
+
Schema validation belongs to the task's verifier. This only checks transport:
|
| 33 |
+
objects must stay JSON (str(dict) produces Python syntax), and JSON-looking
|
| 34 |
+
strings must be complete. Never close truncated JSON or reinterpret literals.
|
| 35 |
+
+
|
| 36 |
+
+ Scalars are transported as JSON too. Measured on this benchmark: after the
|
| 37 |
+
+ environment had already solved a task, the model answered `{"answer": true}`;
|
| 38 |
+
+ rejecting the boolean as "not a string or dict" burned both parse retries and
|
| 39 |
+
+ ended the run in a parse error. No verifier reads the answer here -- the
|
| 40 |
+
+ actions do -- so refusing a perfectly well-formed scalar is a harness bug.
|
| 41 |
+
"""
|
| 42 |
+
- if isinstance(value, dict):
|
| 43 |
+
+ if isinstance(value, (str,)):
|
| 44 |
+
+ if value.lstrip().startswith("{"):
|
| 45 |
+
+ try:
|
| 46 |
+
+ json.loads(value)
|
| 47 |
+
+ except ValueError as exc:
|
| 48 |
+
+ raise ValueError(f"final answer contains malformed JSON: {exc}") from exc
|
| 49 |
+
+ return value
|
| 50 |
+
+ if isinstance(value, (dict, list, bool, int, float)) or value is None:
|
| 51 |
+
return json.dumps(value, ensure_ascii=False, allow_nan=False)
|
| 52 |
+
- if not isinstance(value, str):
|
| 53 |
+
- raise ValueError("final answer must be a string or a JSON object")
|
| 54 |
+
- if value.lstrip().startswith("{"):
|
| 55 |
+
- try:
|
| 56 |
+
- json.loads(value)
|
| 57 |
+
- except ValueError as exc:
|
| 58 |
+
- raise ValueError(f"final answer contains malformed JSON: {exc}") from exc
|
| 59 |
+
- return value
|
| 60 |
+
+ raise ValueError("final answer must be JSON-transportable")
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
#: goal 里形如 `/app/move.txt`、`/app/learned_dag.csv` 的路径。这是**通用**的:
|
| 64 |
+
@@ -426,6 +444,526 @@ def _missing_deliverables(task: dict, workdir: Path) -> list[str]:
|
| 65 |
+
return missing
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
+# ------------------------------------------------- the environment's state ---
|
| 69 |
+
+#
|
| 70 |
+
+# The tasks in this benchmark are not file-editing tasks: they are a text
|
| 71 |
+
+# environment (`python3 alf ...`) whose *own* output already carries the whole
|
| 72 |
+
+# ground truth -- the step counter, whether the goal is solved, what is in every
|
| 73 |
+
+# container, what the agent holds, and what has been cleaned/cooled/heated/placed.
|
| 74 |
+
+# The harness used to append that output raw and throw the structure away. A 9B
|
| 75 |
+
+# model then had to reconstruct "I have the bowl, I cleaned it, but I still have
|
| 76 |
+
+# not put it in the fridge" from forty blocks of prose, and measured on 100 ALF
|
| 77 |
+
+# tasks it did not: 47 runs were unsolved, and the failure was not ignorance --
|
| 78 |
+
+# the target object had already been seen in 23 of them, and 30 of them declared
|
| 79 |
+
+# `alf done` while the environment still printed `in progress`.
|
| 80 |
+
+#
|
| 81 |
+
+# So the loop now reads the environment's own report and gives it back compactly:
|
| 82 |
+
+# the goal, the env step, what is held/processed/placed, and the one action that
|
| 83 |
+
+# is next. That is context policy (skill item 3), not a new prompt constant.
|
| 84 |
+
+
|
| 85 |
+
+_ALF_STEP_RE = re.compile(r"\[alf\] step (\d+)/(\d+); (SOLVED|in progress)")
|
| 86 |
+
+_ALF_OBJ_RE = re.compile(r"\b(?:a|an) ([a-z]+) (\d+)\b")
|
| 87 |
+
+_ALF_DONE_RE = re.compile(r"\balf\s+done\b")
|
| 88 |
+
+_ALF_DO_RE = re.compile(r"\balf\s+do\b")
|
| 89 |
+
+_ALF_CONTAINERS = frozenset({"cabinet", "drawer", "fridge", "microwave", "safe", "cart"})
|
| 90 |
+
+_ALF_APPLIANCE = {"clean": "sinkbasin", "cool": "fridge",
|
| 91 |
+
+ "heat": "microwave", "light": "desklamp"}
|
| 92 |
+
+
|
| 93 |
+
+
|
| 94 |
+
+def _obj_base(obj: str) -> str:
|
| 95 |
+
+ return obj.split()[0].lower()
|
| 96 |
+
+
|
| 97 |
+
+
|
| 98 |
+
+def _alf_mission(task: dict) -> dict | None:
|
| 99 |
+
+ """Read target / destination / required state / budget from the goal prose.
|
| 100 |
+
+
|
| 101 |
+
+ ALFWorld goals have a fixed shape (`put a cool bowl in diningtable`,
|
| 102 |
+
+ `examine the book with the desklamp`). The words are the platform's own task
|
| 103 |
+
+ text, not a hard-coded object list; deriving them lets the harness repeat the
|
| 104 |
+
+ goal back to a small model instead of hoping it re-reads the system prompt.
|
| 105 |
+
+ Returns None for non-environment tasks, which leaves the generic loop alone.
|
| 106 |
+
+ """
|
| 107 |
+
+ goal = str(task.get("goal") or "")
|
| 108 |
+
+ blob = goal + " " + str(task.get("initial_state") or "")
|
| 109 |
+
+ if "alf" not in blob.lower():
|
| 110 |
+
+ return None
|
| 111 |
+
+ m = re.search(r"Your task is to:\s*(.+?)(?:\n|\*\*|$)", goal, re.S)
|
| 112 |
+
+ if not m:
|
| 113 |
+
+ return None
|
| 114 |
+
+ raw = m.group(1).strip().strip("*").strip().rstrip(".").strip()
|
| 115 |
+
+ if not raw:
|
| 116 |
+
+ return None
|
| 117 |
+
+ low = raw.lower()
|
| 118 |
+
+
|
| 119 |
+
+ target = None
|
| 120 |
+
+ mt = re.search(r"\b(?:put|find)\s+(?:a|an|some|two|the)\s+"
|
| 121 |
+
+ r"(?:(?:clean|cool|hot|cold|warm)\s+)?([a-z]+)", low)
|
| 122 |
+
+ if not mt:
|
| 123 |
+
+ mt = re.search(r"\b(?:clean|cool|heat)\s+(?:a|an|some|two|the)\s+([a-z]+)", low)
|
| 124 |
+
+ if not mt:
|
| 125 |
+
+ mt = re.search(r"\b(?:examine|look at)\s+(?:the\s+)?([a-z]+)", low)
|
| 126 |
+
+ if mt:
|
| 127 |
+
+ target = mt.group(1)
|
| 128 |
+
+ if not target:
|
| 129 |
+
+ return None
|
| 130 |
+
+
|
| 131 |
+
+ kind = None
|
| 132 |
+
+ if "desklamp" in low:
|
| 133 |
+
+ kind, dest = "light", "desklamp"
|
| 134 |
+
+ else:
|
| 135 |
+
+ if re.search(r"\bclean\b", low):
|
| 136 |
+
+ kind = "clean"
|
| 137 |
+
+ elif re.search(r"\bcool\b|\bcold\b", low):
|
| 138 |
+
+ kind = "cool"
|
| 139 |
+
+ elif re.search(r"\bheat\b|\bhot\b", low):
|
| 140 |
+
+ kind = "heat"
|
| 141 |
+
+ md = re.search(r"\b(?:in|on|to)\s+(?:the\s+)?([a-z]+)\s*$", low)
|
| 142 |
+
+ dest = md.group(1) if md else None
|
| 143 |
+
+ if not dest:
|
| 144 |
+
+ return None
|
| 145 |
+
+
|
| 146 |
+
+ budget = None
|
| 147 |
+
+ for pat in (r"\*\*(\d+)\*\*\s+steps", r"(\d+)[- ]step budget",
|
| 148 |
+
+ r"budget of (\d+)", r"within the (\d+)"):
|
| 149 |
+
+ mb = re.search(pat, goal, re.I)
|
| 150 |
+
+ if mb:
|
| 151 |
+
+ budget = int(mb.group(1))
|
| 152 |
+
+ break
|
| 153 |
+
+ # The verifier's own `--budget` is authoritative: it is what the replay
|
| 154 |
+
+ # enforces, so the harness cap must be derived from it rather than guessed
|
| 155 |
+
+ # from prose when both are present.
|
| 156 |
+
+ try:
|
| 157 |
+
+ argv = (task.get("verifier") or {}).get("argv") or []
|
| 158 |
+
+ for i, arg in enumerate(argv):
|
| 159 |
+
+ if arg == "--budget" and i + 1 < len(argv):
|
| 160 |
+
+ budget = int(argv[i + 1])
|
| 161 |
+
+ break
|
| 162 |
+
+ except (TypeError, ValueError):
|
| 163 |
+
+ pass
|
| 164 |
+
+ if budget is None or budget < 1:
|
| 165 |
+
+ budget = 50
|
| 166 |
+
+
|
| 167 |
+
+ count = 2 if re.search(r"\btwo\b", low) else 1
|
| 168 |
+
+ return {"raw": raw, "target": target, "dest": dest, "kind": kind,
|
| 169 |
+
+ "count": count, "budget": budget}
|
| 170 |
+
+
|
| 171 |
+
+
|
| 172 |
+
+class _AlfState:
|
| 173 |
+
+ """Fold the environment's text into progress and the next required action."""
|
| 174 |
+
+
|
| 175 |
+
+ def __init__(self, mission: dict | None):
|
| 176 |
+
+ self.mission = mission
|
| 177 |
+
+ self.loc: str | None = None
|
| 178 |
+
+ self.objects: dict[str, str] = {} # object -> fixture it was last seen in
|
| 179 |
+
+ self.saw: dict[str, str] = {} # object -> fixture (never forgotten)
|
| 180 |
+
+ self.fixtures: dict[str, set[str]] = {}
|
| 181 |
+
+ self.held: set[str] = set()
|
| 182 |
+
+ self.transformed: dict[str, set[str]] = {}
|
| 183 |
+
+ self.moved_to: dict[str, str] = {}
|
| 184 |
+
+ self.placed: set[str] = set()
|
| 185 |
+
+ self.open: set[str] = set()
|
| 186 |
+
+ self.searched: set[str] = set()
|
| 187 |
+
+ self.visited: set[str] = set()
|
| 188 |
+
+ self.lamp_on = False
|
| 189 |
+
+ self.step = 0
|
| 190 |
+
+ self.budget = mission["budget"] if mission else 0
|
| 191 |
+
+ self.solved = False
|
| 192 |
+
+ self.invalid = False
|
| 193 |
+
+ self.last_cmd = ""
|
| 194 |
+
+ self.admissible: set[str] = set()
|
| 195 |
+
+
|
| 196 |
+
+ def observe(self, out: str, cmd: str = "") -> None:
|
| 197 |
+
+ self.last_cmd = cmd
|
| 198 |
+
+ self.invalid = "Nothing happens." in out if out else False
|
| 199 |
+
+ if not out:
|
| 200 |
+
+ return
|
| 201 |
+
+ if "SOLVED" in out:
|
| 202 |
+
+ self.solved = True
|
| 203 |
+
+ for m in _ALF_STEP_RE.finditer(out):
|
| 204 |
+
+ self.step = int(m.group(1))
|
| 205 |
+
+ self.budget = int(m.group(2))
|
| 206 |
+
+ if m.group(3) == "SOLVED":
|
| 207 |
+
+ self.solved = True
|
| 208 |
+
+ legal = re.search(r"Admissible actions:\s*\n(.*?)(?:\n\[alf\]|\Z)", out, re.S)
|
| 209 |
+
+ if legal:
|
| 210 |
+
+ self.admissible = {line.strip() for line in legal.group(1).splitlines()
|
| 211 |
+
+ if line.strip()}
|
| 212 |
+
+ for m in re.finditer(r"You (?:arrive at|are facing the|are at) ([a-z]+ \d+)", out):
|
| 213 |
+
+ self.loc = m.group(1)
|
| 214 |
+
+ self.visited.add(self.loc)
|
| 215 |
+
+ for m in re.finditer(r"The ([a-z]+ \d+) is (open|closed)", out):
|
| 216 |
+
+ if m.group(2) == "open":
|
| 217 |
+
+ self.open.add(m.group(1))
|
| 218 |
+
+ else:
|
| 219 |
+
+ self.open.discard(m.group(1))
|
| 220 |
+
+ for m in re.finditer(r"You open the ([a-z]+ \d+)", out):
|
| 221 |
+
+ self.open.add(m.group(1))
|
| 222 |
+
+ room = re.search(r"Looking quickly around you, you see (.*?)\.", out, re.S)
|
| 223 |
+
+ if room:
|
| 224 |
+
+ for m in re.finditer(r"\b([a-z]+) (\d+)\b", room.group(1)):
|
| 225 |
+
+ self.fixtures.setdefault(m.group(1), set()).add(f"{m.group(1)} {m.group(2)}")
|
| 226 |
+
+ for m in re.finditer(r"(?:On|In) the ([a-z]+ \d+), you see ([^.]*)\.", out):
|
| 227 |
+
+ self._add_objects(m.group(1), m.group(2))
|
| 228 |
+
+ if self.loc:
|
| 229 |
+
+ for m in re.finditer(r"In it, you see ([^.]*)\.", out):
|
| 230 |
+
+ self._add_objects(self.loc, m.group(1))
|
| 231 |
+
+ for m in re.finditer(r"You pick up the ([a-z]+ \d+) from the ([a-z]+ \d+)", out):
|
| 232 |
+
+ obj, loc = m.group(1), m.group(2)
|
| 233 |
+
+ self.held.add(obj)
|
| 234 |
+
+ self.objects.pop(obj, None)
|
| 235 |
+
+ self.saw[obj] = loc
|
| 236 |
+
+ self.searched.add(loc)
|
| 237 |
+
+ for m in re.finditer(r"You move the ([a-z]+ \d+) to the ([a-z]+ \d+)", out):
|
| 238 |
+
+ obj, loc = m.group(1), m.group(2)
|
| 239 |
+
+ self.held.discard(obj)
|
| 240 |
+
+ self.moved_to[obj] = loc
|
| 241 |
+
+ self.objects[obj] = loc
|
| 242 |
+
+ self.saw[obj] = loc
|
| 243 |
+
+ if self._is_dest(loc):
|
| 244 |
+
+ self.placed.add(obj)
|
| 245 |
+
+ for m in re.finditer(r"You (clean|cool|heat) the ([a-z]+ \d+) "
|
| 246 |
+
+ r"using the ([a-z]+ \d+)", out):
|
| 247 |
+
+ self.transformed.setdefault(m.group(2), set()).add(m.group(1))
|
| 248 |
+
+ for m in re.finditer(r"You turn on the ([a-z]+ \d+)", out):
|
| 249 |
+
+ if _obj_base(m.group(1)) == "desklamp":
|
| 250 |
+
+ self.lamp_on = True
|
| 251 |
+
+ if "You are not carrying anything." in out:
|
| 252 |
+
+ self.held.clear()
|
| 253 |
+
+
|
| 254 |
+
+ def _add_objects(self, loc: str, text: str) -> None:
|
| 255 |
+
+ # Seeing the contents means the fixture is open/accessible; that is how
|
| 256 |
+
+ # ALFWorld reports a drawer/cabinet that was never explicitly opened.
|
| 257 |
+
+ self.open.add(loc)
|
| 258 |
+
+ self.searched.add(loc)
|
| 259 |
+
+ for m in _ALF_OBJ_RE.finditer(text):
|
| 260 |
+
+ obj = f"{m.group(1)} {m.group(2)}"
|
| 261 |
+
+ self.objects[obj] = loc
|
| 262 |
+
+ self.saw[obj] = loc
|
| 263 |
+
+
|
| 264 |
+
+ def _is_dest(self, loc: str) -> bool:
|
| 265 |
+
+ return bool(loc and self.mission and _obj_base(loc) == self.mission["dest"])
|
| 266 |
+
+
|
| 267 |
+
+ def _completed(self) -> set[str]:
|
| 268 |
+
+ """Targets actually done: placed at the destination *and* processed.
|
| 269 |
+
+
|
| 270 |
+
+ Measured: several failing runs moved an unprocessed object to the goal
|
| 271 |
+
+ location (an egg to the countertop without cooling it, a soapbar to the
|
| 272 |
+
+ cart without cleaning it). Counting a raw `move` as completion made the
|
| 273 |
+
+ progress helper stop guiding exactly one action early.
|
| 274 |
+
+ """
|
| 275 |
+
+ kind = self.mission["kind"] if self.mission else None
|
| 276 |
+
+ return {o for o in self.placed
|
| 277 |
+
+ if not kind or kind in self.transformed.get(o, ())}
|
| 278 |
+
+
|
| 279 |
+
+ def _fixture(self, kind: str) -> str | None:
|
| 280 |
+
+ want = _ALF_APPLIANCE[kind]
|
| 281 |
+
+ if self.loc and _obj_base(self.loc) == want:
|
| 282 |
+
+ return self.loc
|
| 283 |
+
+ seen = set(self.fixtures.get(want) or ())
|
| 284 |
+
+ if not seen:
|
| 285 |
+
+ seen = {o for o in self.saw if _obj_base(o) == want}
|
| 286 |
+
+ if not seen:
|
| 287 |
+
+ return f"{want} 1"
|
| 288 |
+
+ return sorted(seen, key=lambda s: (s.split()[0], int(s.split()[1])))[0]
|
| 289 |
+
+
|
| 290 |
+
+ def _dest(self) -> str | None:
|
| 291 |
+
+ want = self.mission["dest"]
|
| 292 |
+
+ if self.loc and _obj_base(self.loc) == want:
|
| 293 |
+
+ return self.loc
|
| 294 |
+
+ seen = set(self.fixtures.get(want) or ())
|
| 295 |
+
+ if not seen:
|
| 296 |
+
+ seen = {o for o in self.saw if _obj_base(o) == want}
|
| 297 |
+
+ if seen:
|
| 298 |
+
+ return sorted(seen, key=lambda s: (s.split()[0], int(s.split()[1])))[0]
|
| 299 |
+
+ return f"{want} 1"
|
| 300 |
+
+
|
| 301 |
+
+ def _lamp(self) -> tuple[str | None, str | None]:
|
| 302 |
+
+ """The desklamp is an object on a surface, not a navigable location."""
|
| 303 |
+
+ lamps = sorted(o for o in self.saw if _obj_base(o) == "desklamp")
|
| 304 |
+
+ for lamp in lamps:
|
| 305 |
+
+ if self.saw.get(lamp) == self.loc:
|
| 306 |
+
+ return lamp, self.loc
|
| 307 |
+
+ if lamps:
|
| 308 |
+
+ lamp = lamps[0]
|
| 309 |
+
+ return lamp, self.saw.get(lamp)
|
| 310 |
+
+ return None, None
|
| 311 |
+
+
|
| 312 |
+
+ def _legal(self, step: str) -> bool:
|
| 313 |
+
+ """The environment prints the legal actions; never suggest one outside them.
|
| 314 |
+
+
|
| 315 |
+
+ The trace replays what actually ran, so an illegal suggestion costs a real
|
| 316 |
+
+ environment step ("Nothing happens.") for nothing. Measured over all 100
|
| 317 |
+
+ incumbent traces, the planner's raw suggestion was outside the printed
|
| 318 |
+
+ admissible list 105 times; most were `go to X` for a fixture that was
|
| 319 |
+
+ already accessible, or `open X` for a drawer that was already open.
|
| 320 |
+
+ """
|
| 321 |
+
+ return not self.admissible or step in self.admissible
|
| 322 |
+
+
|
| 323 |
+
+ def _takeable_target(self) -> str | None:
|
| 324 |
+
+ base = self.mission["target"]
|
| 325 |
+
+ done = self._completed()
|
| 326 |
+
+ # The environment may expose a target in an already-open container
|
| 327 |
+
+ # without a separate `go to`; trust its own take action over our map.
|
| 328 |
+
+ for act in sorted(self.admissible):
|
| 329 |
+
+ parts = act.split()
|
| 330 |
+
+ if len(parts) >= 3 and parts[0] == "take" and parts[1] == base \
|
| 331 |
+
+ and f"{parts[1]} {parts[2]}" not in done:
|
| 332 |
+
+ return act
|
| 333 |
+
+ here = sorted(o for o, loc in self.objects.items()
|
| 334 |
+
+ if _obj_base(o) == base and loc == self.loc and o not in done)
|
| 335 |
+
+ if here:
|
| 336 |
+
+ step = f"take {here[0]} from {self.loc}"
|
| 337 |
+
+ if not self._fail(step) and self._legal(step):
|
| 338 |
+
+ return step
|
| 339 |
+
+ seen = sorted(((o, loc) for o, loc in self.saw.items()
|
| 340 |
+
+ if _obj_base(o) == base and o not in done
|
| 341 |
+
+ and o not in self.held), key=lambda x: x[1])
|
| 342 |
+
+ if seen:
|
| 343 |
+
+ obj, loc = seen[0]
|
| 344 |
+
+ if loc == self.loc:
|
| 345 |
+
+ step = f"take {obj} from {loc}"
|
| 346 |
+
+ return step if not self._fail(step) and self._legal(step) else None
|
| 347 |
+
+ step = f"go to {loc}"
|
| 348 |
+
+ return step if not self._fail(step) and self._legal(step) else None
|
| 349 |
+
+ return None
|
| 350 |
+
+
|
| 351 |
+
+ def _fail(self, step: str) -> bool:
|
| 352 |
+
+ """True when this exact step just produced 'Nothing happens.'"""
|
| 353 |
+
+ return bool(self.invalid and step in self.last_cmd)
|
| 354 |
+
+
|
| 355 |
+
+ def _search_step(self) -> str | None:
|
| 356 |
+
+ """A systematic next move when the target has not been seen yet."""
|
| 357 |
+
+ if self.loc and _obj_base(self.loc) in _ALF_CONTAINERS and self.loc not in self.open:
|
| 358 |
+
+ step = f"open {self.loc}"
|
| 359 |
+
+ if not self._fail(step) and self._legal(step):
|
| 360 |
+
+ return step
|
| 361 |
+
+ unseen = [inst for typ, insts in self.fixtures.items() if typ != "desklamp"
|
| 362 |
+
+ for inst in insts if inst not in self.visited]
|
| 363 |
+
+ unseen.sort(key=lambda s: (s.split()[0], int(s.split()[1])))
|
| 364 |
+
+ for inst in unseen:
|
| 365 |
+
+ step = f"go to {inst}"
|
| 366 |
+
+ if not self._fail(step) and self._legal(step):
|
| 367 |
+
+ return step
|
| 368 |
+
+ closed = [inst for typ in _ALF_CONTAINERS
|
| 369 |
+
+ for inst in (self.fixtures.get(typ) or ()) if inst not in self.open]
|
| 370 |
+
+ closed.sort(key=lambda s: (s.split()[0], int(s.split()[1])))
|
| 371 |
+
+ for inst in closed:
|
| 372 |
+
+ step = f"go to {inst}" if self.loc != inst else f"open {inst}"
|
| 373 |
+
+ if not self._fail(step) and self._legal(step):
|
| 374 |
+
+ return step
|
| 375 |
+
+ return None
|
| 376 |
+
+
|
| 377 |
+
+ def next_action(self) -> str | None:
|
| 378 |
+
+ if not self.mission or self.solved:
|
| 379 |
+
+ return None
|
| 380 |
+
+ m = self.mission
|
| 381 |
+
+ base = m["target"]
|
| 382 |
+
+ held = sorted(o for o in self.held if _obj_base(o) == base)
|
| 383 |
+
+ placed = sorted(o for o in self._completed() if _obj_base(o) == base)
|
| 384 |
+
+
|
| 385 |
+
+ if m["kind"] == "light":
|
| 386 |
+
+ lamp, lamp_loc = self._lamp()
|
| 387 |
+
+ if not self.lamp_on:
|
| 388 |
+
+ if lamp and lamp_loc == self.loc:
|
| 389 |
+
+ step = f"use {lamp}"
|
| 390 |
+
+ if not self._fail(step):
|
| 391 |
+
+ return step
|
| 392 |
+
+ # Acquire the target before a long trip to a lamp, unless the
|
| 393 |
+
+ # lamp is already in this room.
|
| 394 |
+
+ if not held:
|
| 395 |
+
+ step = self._takeable_target()
|
| 396 |
+
+ if step:
|
| 397 |
+
+ return step
|
| 398 |
+
+ if lamp_loc:
|
| 399 |
+
+ step = f"go to {lamp_loc}"
|
| 400 |
+
+ if not self._fail(step):
|
| 401 |
+
+ return step
|
| 402 |
+
+ return self._search_step()
|
| 403 |
+
+ if not held:
|
| 404 |
+
+ return self._takeable_target() or self._search_step()
|
| 405 |
+
+ # A held target with a lamp already on should satisfy the check; if
|
| 406 |
+
+ # it has not fired, examine the held object while at the lamp, which
|
| 407 |
+
+ # is the other admissible action for "look at X in the light".
|
| 408 |
+
+ if lamp and lamp_loc == self.loc:
|
| 409 |
+
+ return f"examine {held[0]}"
|
| 410 |
+
+ if lamp_loc:
|
| 411 |
+
+ step = f"go to {lamp_loc}"
|
| 412 |
+
+ if not self._fail(step):
|
| 413 |
+
+ return step
|
| 414 |
+
+ return None
|
| 415 |
+
+
|
| 416 |
+
+ if len(placed) < m["count"]:
|
| 417 |
+
+ if held:
|
| 418 |
+
+ obj = held[0]
|
| 419 |
+
+ if m["kind"] and m["kind"] not in self.transformed.get(obj, ()):
|
| 420 |
+
+ app = self._fixture(m["kind"])
|
| 421 |
+
+ if app and self.loc != app:
|
| 422 |
+
+ step = f"go to {app}"
|
| 423 |
+
+ if not self._fail(step):
|
| 424 |
+
+ return step
|
| 425 |
+
+ if app and app not in self.open and _obj_base(app) in _ALF_CONTAINERS:
|
| 426 |
+
+ step = f"open {app}"
|
| 427 |
+
+ if not self._fail(step):
|
| 428 |
+
+ return step
|
| 429 |
+
+ if app:
|
| 430 |
+
+ step = f"{m['kind']} {obj} with {app}"
|
| 431 |
+
+ if not self._fail(step):
|
| 432 |
+
+ return step
|
| 433 |
+
+ dest = self._dest()
|
| 434 |
+
+ if dest and self.loc != dest:
|
| 435 |
+
+ step = f"go to {dest}"
|
| 436 |
+
+ if not self._fail(step):
|
| 437 |
+
+ return step
|
| 438 |
+
+ if dest and dest not in self.open and _obj_base(dest) in _ALF_CONTAINERS:
|
| 439 |
+
+ step = f"open {dest}"
|
| 440 |
+
+ if not self._fail(step):
|
| 441 |
+
+ return step
|
| 442 |
+
+ if dest:
|
| 443 |
+
+ step = f"move {obj} to {dest}"
|
| 444 |
+
+ if not self._fail(step):
|
| 445 |
+
+ return step
|
| 446 |
+
+ else:
|
| 447 |
+
+ return self._takeable_target() or self._search_step()
|
| 448 |
+
+ return None
|
| 449 |
+
+
|
| 450 |
+
+ def _legal_fallback(self, step: str) -> str | None:
|
| 451 |
+
+ """A legal action with the same purpose when the exact step is not listed."""
|
| 452 |
+
+ if self._legal(step):
|
| 453 |
+
+ return step
|
| 454 |
+
+ if not self.admissible or not self.mission:
|
| 455 |
+
+ return None
|
| 456 |
+
+ m = self.mission
|
| 457 |
+
+ base = m["target"]
|
| 458 |
+
+ verb = step.split()[0] if step else ""
|
| 459 |
+
+ held = [o for o in self.held if _obj_base(o) == base]
|
| 460 |
+
+ if verb == "take":
|
| 461 |
+
+ for act in sorted(self.admissible):
|
| 462 |
+
+ parts = act.split()
|
| 463 |
+
+ if len(parts) >= 2 and parts[0] == "take" and parts[1] == base:
|
| 464 |
+
+ return act
|
| 465 |
+
+ return None
|
| 466 |
+
+ if verb == "move" and held:
|
| 467 |
+
+ for act in sorted(self.admissible):
|
| 468 |
+
+ parts = act.split()
|
| 469 |
+
+ if len(parts) >= 5 and parts[0] == "move" \
|
| 470 |
+
+ and f"{parts[1]} {parts[2]}" == held[0] \
|
| 471 |
+
+ and parts[-2] == m["dest"]:
|
| 472 |
+
+ return act
|
| 473 |
+
+ return None
|
| 474 |
+
+ if verb in ("clean", "cool", "heat") and held:
|
| 475 |
+
+ for act in sorted(self.admissible):
|
| 476 |
+
+ parts = act.split()
|
| 477 |
+
+ if len(parts) >= 4 and parts[0] == verb \
|
| 478 |
+
+ and f"{parts[1]} {parts[2]}" == held[0]:
|
| 479 |
+
+ return act
|
| 480 |
+
+ return None
|
| 481 |
+
+ if verb == "use":
|
| 482 |
+
+ for act in sorted(self.admissible):
|
| 483 |
+
+ if act.startswith("use desklamp"):
|
| 484 |
+
+ return act
|
| 485 |
+
+ return None
|
| 486 |
+
+ if verb == "examine" and held:
|
| 487 |
+
+ for act in sorted(self.admissible):
|
| 488 |
+
+ if act == f"examine {held[0]}":
|
| 489 |
+
+ return act
|
| 490 |
+
+ return None
|
| 491 |
+
+ if verb == "open":
|
| 492 |
+
+ for act in sorted(self.admissible):
|
| 493 |
+
+ if act.startswith("open "):
|
| 494 |
+
+ return act
|
| 495 |
+
+ return None
|
| 496 |
+
+ if verb == "go to":
|
| 497 |
+
+ for act in sorted(self.admissible):
|
| 498 |
+
+ if act.startswith("go to "):
|
| 499 |
+
+ return act
|
| 500 |
+
+ return None
|
| 501 |
+
+ return None
|
| 502 |
+
+
|
| 503 |
+
+ def hint(self) -> str:
|
| 504 |
+
+ if not self.mission:
|
| 505 |
+
+ return ""
|
| 506 |
+
+ m = self.mission
|
| 507 |
+
+ lines = [f"[harness] Goal: {m['raw']}."]
|
| 508 |
+
+ lines.append(f"Environment step {self.step}/{self.budget} "
|
| 509 |
+
+ f"({'SOLVED' if self.solved else 'NOT solved'}).")
|
| 510 |
+
+ held = sorted(o for o in self.held if _obj_base(o) == m["target"])
|
| 511 |
+
+ done = self._completed()
|
| 512 |
+
+ placed = sorted(o for o in done if _obj_base(o) == m["target"])
|
| 513 |
+
+ raw_at_dest = sorted(o for o in self.placed
|
| 514 |
+
+ if _obj_base(o) == m["target"] and o not in done)
|
| 515 |
+
+ if held:
|
| 516 |
+
+ processed = " (processed)" if all(
|
| 517 |
+
+ not m["kind"] or m["kind"] in self.transformed.get(o, ())
|
| 518 |
+
+ for o in held) else ""
|
| 519 |
+
+ lines.append("Holding: " + ", ".join(held) + processed + ".")
|
| 520 |
+
+ if placed:
|
| 521 |
+
+ lines.append(f"Already placed: {len(placed)}/{m['count']} "
|
| 522 |
+
+ + ", ".join(placed) + ".")
|
| 523 |
+
+ if raw_at_dest:
|
| 524 |
+
+ lines.append("At the destination but NOT processed yet: "
|
| 525 |
+
+ + ", ".join(raw_at_dest) + " (take it, process it, then place it).")
|
| 526 |
+
+ seen = sorted(o for o in self.saw if _obj_base(o) == m["target"]
|
| 527 |
+
+ and o not in done and o not in self.held
|
| 528 |
+
+ and o not in raw_at_dest)
|
| 529 |
+
+ if seen and len(placed) + len(held) < m["count"]:
|
| 530 |
+
+ lines.append("Target seen: "
|
| 531 |
+
+ + ", ".join(f"{o} at {self.saw[o]}" for o in seen[:6]) + ".")
|
| 532 |
+
+ if self.invalid:
|
| 533 |
+
+ lines.append("The last action did nothing and still cost an environment "
|
| 534 |
+
+ "step; only use an action from the Admissible actions list.")
|
| 535 |
+
+ nxt = self.next_action()
|
| 536 |
+
+ if nxt and not self._legal(nxt):
|
| 537 |
+
+ nxt = self._legal_fallback(nxt)
|
| 538 |
+
+ if nxt and not self.solved:
|
| 539 |
+
+ lines.append(f'Next required action: python3 alf do "{nxt}"')
|
| 540 |
+
+ return "\n".join(lines)
|
| 541 |
+
+
|
| 542 |
+
+
|
| 543 |
+
+def _loop_budget(mission: dict | None) -> int:
|
| 544 |
+
+ """Shell steps for this task: the environment's budget plus free-command slack."""
|
| 545 |
+
+ if mission:
|
| 546 |
+
+ return min(max(MAX_STEPS, int(mission["budget"]) + STEP_SLACK), 200)
|
| 547 |
+
+ return MAX_STEPS
|
| 548 |
+
+
|
| 549 |
+
+
|
| 550 |
+
+def _is_cycle(cmd: str, history: list[str]) -> bool:
|
| 551 |
+
+ """True when `cmd` continues a short cycle that is already in `history`.
|
| 552 |
+
+
|
| 553 |
+
+ The old repeat guard fired only when a command equaled the *immediately*
|
| 554 |
+
+ previous one. Measured here: the model cycled `go to shelf 5`, `shelf 6`,
|
| 555 |
+
+ `shelf 7` for 24 steps and no guard fired once. A cycle of period 2 or 3 is
|
| 556 |
+
+ just as much a non-action as an immediate repeat, so break it before it is
|
| 557 |
+
+ run (skill item 4: do not feed the repeat back as another observation).
|
| 558 |
+
+ """
|
| 559 |
+
+ for period in (1, 2, 3):
|
| 560 |
+
+ if period == 1:
|
| 561 |
+
+ if history and history[-1] == cmd:
|
| 562 |
+
+ return True
|
| 563 |
+
+ continue
|
| 564 |
+
+ if len(history) >= 2 * period and history[-period:] == history[-2 * period:-period] \
|
| 565 |
+
+ and cmd == history[-period]:
|
| 566 |
+
+ return True
|
| 567 |
+
+ return False
|
| 568 |
+
+
|
| 569 |
+
+
|
| 570 |
+
+def _premature_finish_note(state: _AlfState, how: str) -> str:
|
| 571 |
+
+ hint = state.hint()
|
| 572 |
+
+ return (
|
| 573 |
+
+ f"[harness] You tried to finish ({how}), but the environment has NOT printed "
|
| 574 |
+
+ "SOLVED. The task is graded only by the actions replayed from "
|
| 575 |
+
+ "alf_actions.jsonl, so stopping now scores zero. Do not answer or run "
|
| 576 |
+
+ "`alf done` before the environment prints SOLVED.\n"
|
| 577 |
+
+ + (hint + "\n" if hint else "")
|
| 578 |
+
+ + "Continue now with exactly one action.")
|
| 579 |
+
+
|
| 580 |
+
+
|
| 581 |
+
+def _cycle_note(state: _AlfState) -> str:
|
| 582 |
+
+ hint = state.hint()
|
| 583 |
+
+ return ("[harness] That command was NOT run: the last actions form a repeating "
|
| 584 |
+
+ "cycle, so running it again cannot change the environment. Choose a "
|
| 585 |
+
+ "different action.\n" + (hint if hint else ""))
|
| 586 |
+
+
|
| 587 |
+
+
|
| 588 |
+
def _clip_text(out: str, limit: int) -> str:
|
| 589 |
+
if len(out) <= limit:
|
| 590 |
+
return out
|
| 591 |
+
@@ -544,8 +1082,22 @@ def run(task: dict, workdir: Path) -> str:
|
| 592 |
+
"""
|
| 593 |
+
trace_path = workdir / "trace.jsonl"
|
| 594 |
+
shell, dialect = _shell_runtime()
|
| 595 |
+
+ mission = _alf_mission(task)
|
| 596 |
+
+ state = _AlfState(mission)
|
| 597 |
+
+ max_steps = _loop_budget(mission)
|
| 598 |
+
+ environment_note = ""
|
| 599 |
+
+ if mission:
|
| 600 |
+
+ environment_note = (
|
| 601 |
+
+ "\nThis task is an interactive text environment reached through `python3 alf`.\n"
|
| 602 |
+
+ "- `python3 alf look` is free and prints the current room plus the exact "
|
| 603 |
+
+ "admissible actions. `python3 alf do \"...\"` costs one of the environment's "
|
| 604 |
+
+ f"{mission['budget']} steps.\n"
|
| 605 |
+
+ "- The environment prints `SOLVED` only when the goal is actually met. Never "
|
| 606 |
+
+ "answer or run `alf done` before you see `SOLVED`.\n"
|
| 607 |
+
+ "- After each step the harness prints your goal progress and the next required "
|
| 608 |
+
+ "action; follow it unless you have a concrete reason not to.\n")
|
| 609 |
+
messages = [
|
| 610 |
+
- {"role": "system", "content": SYSTEM + (
|
| 611 |
+
+ {"role": "system", "content": SYSTEM + environment_note + (
|
| 612 |
+
f"\nShell runtime: {shell} -c ({dialect}). Each command starts a new shell.\n"
|
| 613 |
+
+ ("Bash arrays and PIPESTATUS are supported.\n" if dialect == "Bash" else
|
| 614 |
+
"Use POSIX syntax; Bash arrays, PIPESTATUS and [[ ]] are unavailable.\n"))},
|
| 615 |
+
@@ -555,8 +1107,10 @@ def run(task: dict, workdir: Path) -> str:
|
| 616 |
+
answer = ""
|
| 617 |
+
submits = 0
|
| 618 |
+
parse_retries = 0
|
| 619 |
+
- repeats = 0
|
| 620 |
+
- last_cmd = ""
|
| 621 |
+
+ premature_finishes = 0
|
| 622 |
+
+ cycle_blocks = 0
|
| 623 |
+
+ alf_history: list[str] = []
|
| 624 |
+
+ cmd_history: list[str] = []
|
| 625 |
+
output_dir = None
|
| 626 |
+
# **行缓冲,不是默认的 8KB 块缓冲。** 实测(2026-10-04,本地模型跑 `bn-fit-modify`):
|
| 627 |
+
# harness 已经跑了 8 分钟、正在装 pandas,而 `/app/trace.jsonl` 是 0 字节、打开的 fd
|
| 628 |
+
@@ -580,7 +1134,10 @@ def run(task: dict, workdir: Path) -> str:
|
| 629 |
+
# 同时声明 model/backend:这个 harness 读 `HG_AGENT_MODEL`,但只有它自己知道读到
|
| 630 |
+
# 了什么,平台的环境变量在别处会因改名而与实际不符(INTERFACE.md §3)。
|
| 631 |
+
identity = {"harness": "loop", "config": {
|
| 632 |
+
- "max_steps": MAX_STEPS, "submit_retries": SUBMIT_RETRIES,
|
| 633 |
+
+ "max_steps": max_steps,
|
| 634 |
+
+ "env_budget": mission["budget"] if mission else None,
|
| 635 |
+
+ "step_slack": STEP_SLACK if mission else 0,
|
| 636 |
+
+ "submit_retries": SUBMIT_RETRIES,
|
| 637 |
+
"parse_retries": PARSE_RETRIES, "finish_nudge_steps": FINISH_NUDGE_STEPS,
|
| 638 |
+
"repeat_nudge_limit": REPEAT_NUDGE_LIMIT, "output_limit": OUTPUT_LIMIT,
|
| 639 |
+
"context_chars": CONTEXT_CHAR_BUDGET,
|
| 640 |
+
@@ -601,7 +1158,7 @@ def run(task: dict, workdir: Path) -> str:
|
| 641 |
+
started = time.time()
|
| 642 |
+
model_s = command_s = 0.0
|
| 643 |
+
trims_before = USAGE["context_trims"]
|
| 644 |
+
- for step in range(MAX_STEPS):
|
| 645 |
+
+ for step in range(max_steps):
|
| 646 |
+
dropped = _trim_history(messages)
|
| 647 |
+
if dropped:
|
| 648 |
+
trace.write(json.dumps({"step": step, "history_dropped": dropped}) + "\n")
|
| 649 |
+
@@ -640,7 +1197,7 @@ def run(task: dict, workdir: Path) -> str:
|
| 650 |
+
f"Your reply could not be read as an action: {exc}\n"
|
| 651 |
+
"Nothing was executed. It may have been cut off by the output token limit.\n"
|
| 652 |
+
"Send one short command; use a loop/script instead of enumerating calls.\n"
|
| 653 |
+
- f"You have {MAX_STEPS - step - 1} step(s) left.\n"
|
| 654 |
+
+ f"You have {max_steps - step - 1} step(s) left.\n"
|
| 655 |
+
"Reply with EXACTLY ONE JSON object and nothing else, one of:\n"
|
| 656 |
+
' {"tool": "bash", "command": "<shell command>"}\n'
|
| 657 |
+
' {"answer": "<your final answer>"}\n'
|
| 658 |
+
@@ -667,6 +1224,20 @@ def run(task: dict, workdir: Path) -> str:
|
| 659 |
+
# 空答案,文件从未创建)。所以:有命令就先执行命令;只有**没有**命令时才算交卷。
|
| 660 |
+
cmd = action.get("command", "")
|
| 661 |
+
if not cmd and "answer" in action:
|
| 662 |
+
+ # The environment, not the model, decides whether this task is done.
|
| 663 |
+
+ # Measured: 30 of 47 unsolved ALF runs ran `alf done` and submitted a
|
| 664 |
+
+ # confident answer while the environment still printed `in progress`.
|
| 665 |
+
+ # Accepting that answer throws away the remaining environment budget;
|
| 666 |
+
+ # pushing back with the goal state gives the model the step it needed.
|
| 667 |
+
+ if mission and not state.solved \
|
| 668 |
+
+ and state.step < state.budget \
|
| 669 |
+
+ and premature_finishes < SUBMIT_RETRIES + 1:
|
| 670 |
+
+ premature_finishes += 1
|
| 671 |
+
+ trace.write(json.dumps({"step": step, "premature_finish": "answer",
|
| 672 |
+
+ "env_step": state.step}) + "\n")
|
| 673 |
+
+ messages.append({"role": "user",
|
| 674 |
+
+ "content": _premature_finish_note(state, "answer")})
|
| 675 |
+
+ continue
|
| 676 |
+
missing = _missing_deliverables(task, workdir)
|
| 677 |
+
if missing and submits < SUBMIT_RETRIES:
|
| 678 |
+
submits += 1
|
| 679 |
+
@@ -680,6 +1251,46 @@ def run(task: dict, workdir: Path) -> str:
|
| 680 |
+
"missing": missing}) + "\n")
|
| 681 |
+
answer = _answer_text(action["answer"])
|
| 682 |
+
break
|
| 683 |
+
+
|
| 684 |
+
+ # `alf done` is the model declaring completion, not the environment
|
| 685 |
+
+ # reporting it. The verifier replays only the actions, so a premature
|
| 686 |
+
+ # done is pure loss; refuse it and show what is still missing.
|
| 687 |
+
+ if mission and not state.solved and _ALF_DONE_RE.search(cmd) \
|
| 688 |
+
+ and not _ALF_DO_RE.search(cmd) \
|
| 689 |
+
+ and state.step < state.budget \
|
| 690 |
+
+ and premature_finishes < SUBMIT_RETRIES + 1:
|
| 691 |
+
+ premature_finishes += 1
|
| 692 |
+
+ trace.write(json.dumps({"step": step, "premature_finish": "alf done",
|
| 693 |
+
+ "env_step": state.step}) + "\n")
|
| 694 |
+
+ messages.append({"role": "user",
|
| 695 |
+
+ "content": _premature_finish_note(state, "alf done")})
|
| 696 |
+
+ continue
|
| 697 |
+
+
|
| 698 |
+
+ # Break a cycle *before* it executes: feeding the same observation back
|
| 699 |
+
+ # is what let one run spend 24 steps walking shelf 5 -> 6 -> 7 -> 5.
|
| 700 |
+
+ # Environment actions are compared among themselves (a free `alf look`
|
| 701 |
+
+ # must not hide a cycle); every other command is compared against the
|
| 702 |
+
+ # full command history, which preserves the old immediate-repeat guard.
|
| 703 |
+
+ is_alf_action = bool(mission and _ALF_DO_RE.search(cmd))
|
| 704 |
+
+ history = alf_history if is_alf_action else cmd_history
|
| 705 |
+
+ if _is_cycle(cmd, history) and cycle_blocks < REPEAT_NUDGE_LIMIT * 3:
|
| 706 |
+
+ cycle_blocks += 1
|
| 707 |
+
+ trace.write(json.dumps({"step": step, "repeat_blocked": cmd[:160],
|
| 708 |
+
+ "env_step": state.step}) + "\n")
|
| 709 |
+
+ messages.append({"role": "user", "content": (
|
| 710 |
+
+ _cycle_note(state) if mission else
|
| 711 |
+
+ "[harness] That command was NOT run because it repeats a command "
|
| 712 |
+
+ "that is already in the conversation; running it again cannot "
|
| 713 |
+
+ "change the result. Choose a different action.")})
|
| 714 |
+
+ continue
|
| 715 |
+
+ if is_alf_action:
|
| 716 |
+
+ alf_history.append(cmd.strip())
|
| 717 |
+
+ if len(alf_history) > 12:
|
| 718 |
+
+ del alf_history[:-12]
|
| 719 |
+
+ cmd_history.append(cmd.strip())
|
| 720 |
+
+ if len(cmd_history) > 12:
|
| 721 |
+
+ del cmd_history[:-12]
|
| 722 |
+
+
|
| 723 |
+
t0 = time.time()
|
| 724 |
+
proc = subprocess.run(
|
| 725 |
+
# `errors="replace"`: a command may emit arbitrary bytes, and a strict decode
|
| 726 |
+
@@ -709,31 +1320,52 @@ def run(task: dict, workdir: Path) -> str:
|
| 727 |
+
trace.write(json.dumps({"step": step, "output_clipped": len(out),
|
| 728 |
+
"shown": len(shown), "output_file": str(relative),
|
| 729 |
+
"output_view": shown}) + "\n")
|
| 730 |
+
- messages.append({"role": "user", "content":
|
| 731 |
+
- f"exit={proc.returncode}{output_note}\n{shown}"})
|
| 732 |
+
-
|
| 733 |
+
- # **两条提醒,都放在命令跑完之后**,因为它们改变的是"下一步做什么"。
|
| 734 |
+
- #
|
| 735 |
+
- # 先记进 trace 再发出去:平台看不到容器内部,没有这两条记录,"模型在原地打转"
|
| 736 |
+
- # 在一次 32 步的运行里和"模型在认真工作"长得一模一样。
|
| 737 |
+
- if cmd and cmd == last_cmd and repeats < REPEAT_NUDGE_LIMIT:
|
| 738 |
+
- repeats += 1
|
| 739 |
+
- trace.write(json.dumps({"step": step, "repeat_nudge": cmd[:120]}) + "\n")
|
| 740 |
+
- messages[-1]["content"] += "\n" + (
|
| 741 |
+
- "That is the same command as the previous step and its output has not "
|
| 742 |
+
- "changed. Do something different, or finish now with "
|
| 743 |
+
- '{"answer": "<your final answer>"} if the work is already done.')
|
| 744 |
+
- last_cmd = cmd
|
| 745 |
+
-
|
| 746 |
+
- left = MAX_STEPS - (step + 1)
|
| 747 |
+
+ state.observe(out, cmd)
|
| 748 |
+
+ # A real environment action is progress; give the model a fresh set of
|
| 749 |
+
+ # push-backs if it later tries to finish early again.
|
| 750 |
+
+ if mission and _ALF_DO_RE.search(cmd):
|
| 751 |
+
+ premature_finishes = 0
|
| 752 |
+
+ observation = f"exit={proc.returncode}{output_note}\n{shown}"
|
| 753 |
+
+ hint = state.hint() if mission else ""
|
| 754 |
+
+ if hint:
|
| 755 |
+
+ observation += "\n\n" + hint
|
| 756 |
+
+ messages.append({"role": "user", "content": observation})
|
| 757 |
+
+
|
| 758 |
+
+ # The environment said SOLVED. Stop immediately: the verifier replays
|
| 759 |
+
+ # the actions that are already in alf_actions.jsonl, so more calls can
|
| 760 |
+
+ # only add noise (and the old loop answered after this with a boolean
|
| 761 |
+
+ # and burned its parse retries for nothing).
|
| 762 |
+
+ if mission and state.solved:
|
| 763 |
+
+ trace.write(json.dumps({"step": step, "environment_solved": True,
|
| 764 |
+
+ "env_step": state.step}) + "\n")
|
| 765 |
+
+ answer = json.dumps({"task_id": task.get("task_id"),
|
| 766 |
+
+ "status": "solved"})
|
| 767 |
+
+ break
|
| 768 |
+
+
|
| 769 |
+
+ # The environment's own action budget is spent; no further action can
|
| 770 |
+
+ # be graded as progress, so stop instead of answering after the cap.
|
| 771 |
+
+ if mission and state.step >= state.budget:
|
| 772 |
+
+ trace.write(json.dumps({"step": step, "environment_exhausted": True,
|
| 773 |
+
+ "env_step": state.step}) + "\n")
|
| 774 |
+
+ answer = json.dumps({"task_id": task.get("task_id"),
|
| 775 |
+
+ "status": "environment budget exhausted"})
|
| 776 |
+
+ break
|
| 777 |
+
+
|
| 778 |
+
+ left = max_steps - (step + 1)
|
| 779 |
+
# 只在进入收尾区和最后一步各说一次:每一步都重复同一句话不会更有用,
|
| 780 |
+
# 只会把最近几轮的命令输出挤远。
|
| 781 |
+
if left and (left == FINISH_NUDGE_STEPS or left == 1):
|
| 782 |
+
trace.write(json.dumps({"step": step, "finish_nudge": left}) + "\n")
|
| 783 |
+
- messages[-1]["content"] += "\n" + (
|
| 784 |
+
- f"You have {left} step(s) left. Stop exploring. Create every file the "
|
| 785 |
+
- "task asks for now, then reply with exactly one JSON object: "
|
| 786 |
+
- '{"answer": "<your final answer>"}')
|
| 787 |
+
+ if mission:
|
| 788 |
+
+ messages[-1]["content"] += "\n" + (
|
| 789 |
+
+ f"You have {left} shell step(s) left; the environment is at "
|
| 790 |
+
+ f"step {state.step}/{state.budget}. Follow the Next required "
|
| 791 |
+
+ "action and do not answer before the environment prints SOLVED.")
|
| 792 |
+
+ else:
|
| 793 |
+
+ messages[-1]["content"] += "\n" + (
|
| 794 |
+
+ f"You have {left} step(s) left. Stop exploring. Create every file the "
|
| 795 |
+
+ "task asks for now, then reply with exactly one JSON object: "
|
| 796 |
+
+ '{"answer": "<your final answer>"}')
|
| 797 |
+
|
| 798 |
+
# Where the wall clock went. Separate from `usage` (which counts tokens):
|
| 799 |
+
# a reader asking "was this killed for being slow, and slow at what" gets one
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-2.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"round": 2,
|
| 3 |
+
"from": "f12a20d8bbf45c990c0da5b7a6fcdf244571e2a1",
|
| 4 |
+
"to": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 5 |
+
"files": [
|
| 6 |
+
{
|
| 7 |
+
"path": "agent.py",
|
| 8 |
+
"added": 100,
|
| 9 |
+
"removed": 8
|
| 10 |
+
}
|
| 11 |
+
],
|
| 12 |
+
"added": 100,
|
| 13 |
+
"removed": 8
|
| 14 |
+
}
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-2.patch
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/agent.py b/agent.py
|
| 2 |
+
index 0528d9e..a017e69 100644
|
| 3 |
+
--- a/agent.py
|
| 4 |
+
+++ b/agent.py
|
| 5 |
+
@@ -461,14 +461,44 @@ def _missing_deliverables(task: dict, workdir: Path) -> list[str]:
|
| 6 |
+
# the goal, the env step, what is held/processed/placed, and the one action that
|
| 7 |
+
# is next. That is context policy (skill item 3), not a new prompt constant.
|
| 8 |
+
|
| 9 |
+
-_ALF_STEP_RE = re.compile(r"\[alf\] step (\d+)/(\d+); (SOLVED|in progress)")
|
| 10 |
+
+_ALF_STEP_RE = re.compile(
|
| 11 |
+
+ r"\[alf\] step (\d+)/(\d+); (SOLVED|in progress|episode over)")
|
| 12 |
+
_ALF_OBJ_RE = re.compile(r"\b(?:a|an) ([a-z]+) (\d+)\b")
|
| 13 |
+
_ALF_DONE_RE = re.compile(r"\balf\s+done\b")
|
| 14 |
+
_ALF_DO_RE = re.compile(r"\balf\s+do\b")
|
| 15 |
+
-_ALF_CONTAINERS = frozenset({"cabinet", "drawer", "fridge", "microwave", "safe", "cart"})
|
| 16 |
+
+
|
| 17 |
+
+#: Fixtures whose contents are only visible after an `open` action. `cart` is
|
| 18 |
+
+#: deliberately NOT here: the environment shows its contents on arrival (the
|
| 19 |
+
+#: traces have "go to cart 1 / On the cart 1, you see ..."), and suggesting
|
| 20 |
+
+#: `open cart 1` costs an environment step for nothing.
|
| 21 |
+
+_ALF_OPENABLE = frozenset({"cabinet", "drawer", "fridge", "microwave", "safe"})
|
| 22 |
+
_ALF_APPLIANCE = {"clean": "sinkbasin", "cool": "fridge",
|
| 23 |
+
"heat": "microwave", "light": "desklamp"}
|
| 24 |
+
|
| 25 |
+
+#: Search order when the target has not been seen yet.
|
| 26 |
+
+#:
|
| 27 |
+
+#: Measured on the 100 incumbent ALF traces: 88 of the 99 targets whose first
|
| 28 |
+
+#: location could be recovered were on a directly inspectable surface and only
|
| 29 |
+
+#: 11 were inside an openable container. The old order was alphabetical, so it
|
| 30 |
+
+#: visited every cabinet (two environment steps each: go, then open) before the
|
| 31 |
+
+#: first countertop -- e.g. `pick_cool_then_place_in_recep-Potato-...` spent 40
|
| 32 |
+
+#: of its 50 actions on closed cabinets before reaching the garbagecan holding
|
| 33 |
+
+#: the potato, and `pick_clean_...-Apple-...` found the apple in the microwave
|
| 34 |
+
+#: at env step 49 and had nothing left to clean or place it. Ordering by the
|
| 35 |
+
+#: environment's own cost model (a surface costs one step, an openable container
|
| 36 |
+
+#: costs two) and by how often each surface holds the goal object is the
|
| 37 |
+
+#: exploration-policy repair, not a per-task hint.
|
| 38 |
+
+_ALF_SURFACE_ORDER = (
|
| 39 |
+
+ "countertop", "diningtable", "desk", "bed", "dresser", "sidetable",
|
| 40 |
+
+ "shelf", "coffeemachine", "armchair", "handtowelholder", "garbagecan",
|
| 41 |
+
+ "toilet", "bathtubbasin", "stoveburner", "coffeetable", "sofa", "cart",
|
| 42 |
+
+ "toaster", "sinkbasin",
|
| 43 |
+
+)
|
| 44 |
+
+#: Openable containers: the one-instance appliance containers first (cheap to
|
| 45 |
+
+#: exhaust, and they are plausible sources for a cool/heat goal object), then
|
| 46 |
+
+#: the numerous bulk containers.
|
| 47 |
+
+_ALF_OPENABLE_ORDER = ("fridge", "microwave", "safe", "cabinet", "drawer")
|
| 48 |
+
+
|
| 49 |
+
|
| 50 |
+
def _obj_base(obj: str) -> str:
|
| 51 |
+
return obj.split()[0].lower()
|
| 52 |
+
@@ -731,28 +761,82 @@ class _AlfState:
|
| 53 |
+
"""True when this exact step just produced 'Nothing happens.'"""
|
| 54 |
+
return bool(self.invalid and step in self.last_cmd)
|
| 55 |
+
|
| 56 |
+
+ @staticmethod
|
| 57 |
+
+ def _fixture_index(inst: str) -> int:
|
| 58 |
+
+ try:
|
| 59 |
+
+ return int(inst.rsplit(" ", 1)[1])
|
| 60 |
+
+ except (IndexError, ValueError):
|
| 61 |
+
+ return 0
|
| 62 |
+
+
|
| 63 |
+
+ def _search_key(self, inst: str) -> tuple[int, int, int]:
|
| 64 |
+
+ """Rank a fixture for the exploration order.
|
| 65 |
+
+
|
| 66 |
+
+ Tiers, not a magic constant: directly inspectable surfaces cost one
|
| 67 |
+
+ environment step, openable containers cost two, and the frequency order
|
| 68 |
+
+ encodes which surfaces the environment's object placements actually
|
| 69 |
+
+ favour. Unknown fixture types go last but are still searched.
|
| 70 |
+
+ """
|
| 71 |
+
+ base = _obj_base(inst)
|
| 72 |
+
+ idx = self._fixture_index(inst)
|
| 73 |
+
+ if base in _ALF_SURFACE_ORDER:
|
| 74 |
+
+ return (0, _ALF_SURFACE_ORDER.index(base), idx)
|
| 75 |
+
+ if base in _ALF_OPENABLE_ORDER:
|
| 76 |
+
+ return (1, _ALF_OPENABLE_ORDER.index(base), idx)
|
| 77 |
+
+ return (2, 0, idx)
|
| 78 |
+
+
|
| 79 |
+
def _search_step(self) -> str | None:
|
| 80 |
+
"""A systematic next move when the target has not been seen yet."""
|
| 81 |
+
- if self.loc and _obj_base(self.loc) in _ALF_CONTAINERS and self.loc not in self.open:
|
| 82 |
+
+ if self.loc and _obj_base(self.loc) in _ALF_OPENABLE and self.loc not in self.open:
|
| 83 |
+
step = f"open {self.loc}"
|
| 84 |
+
if not self._fail(step) and self._legal(step):
|
| 85 |
+
return step
|
| 86 |
+
unseen = [inst for typ, insts in self.fixtures.items() if typ != "desklamp"
|
| 87 |
+
for inst in insts if inst not in self.visited]
|
| 88 |
+
- unseen.sort(key=lambda s: (s.split()[0], int(s.split()[1])))
|
| 89 |
+
+ unseen.sort(key=self._search_key)
|
| 90 |
+
for inst in unseen:
|
| 91 |
+
step = f"go to {inst}"
|
| 92 |
+
if not self._fail(step) and self._legal(step):
|
| 93 |
+
return step
|
| 94 |
+
- closed = [inst for typ in _ALF_CONTAINERS
|
| 95 |
+
+ closed = [inst for typ in _ALF_OPENABLE
|
| 96 |
+
for inst in (self.fixtures.get(typ) or ()) if inst not in self.open]
|
| 97 |
+
- closed.sort(key=lambda s: (s.split()[0], int(s.split()[1])))
|
| 98 |
+
+ closed.sort(key=self._search_key)
|
| 99 |
+
for inst in closed:
|
| 100 |
+
step = f"go to {inst}" if self.loc != inst else f"open {inst}"
|
| 101 |
+
if not self._fail(step) and self._legal(step):
|
| 102 |
+
return step
|
| 103 |
+
return None
|
| 104 |
+
|
| 105 |
+
+ def _held_other(self) -> list[str]:
|
| 106 |
+
+ """Objects in hand that are not the goal object."""
|
| 107 |
+
+ if not self.mission:
|
| 108 |
+
+ return []
|
| 109 |
+
+ base = self.mission["target"]
|
| 110 |
+
+ return sorted(o for o in self.held if _obj_base(o) != base)
|
| 111 |
+
+
|
| 112 |
+
+ def _release_step(self) -> str | None:
|
| 113 |
+
+ """Put down a wrong object so the target can be taken.
|
| 114 |
+
+
|
| 115 |
+
+ Measured (`pick_cool_then_place_in_recep-Pot-None-CounterTop-17`): the
|
| 116 |
+
+ model picked up a kettle on the way. `next_action` then alternated
|
| 117 |
+
+ forever between `go to stoveburner 1` (where the pot was visible) and
|
| 118 |
+
+ `go to <next unseen fixture>`, because the take was not admissible with
|
| 119 |
+
+ full hands, and burned the remaining 26 environment steps. The
|
| 120 |
+
+ environment's own admissible list already names the legal placement
|
| 121 |
+
+ (`move kettle 2 to cabinet 14`), so use it.
|
| 122 |
+
+ """
|
| 123 |
+
+ others = self._held_other()
|
| 124 |
+
+ if not others:
|
| 125 |
+
+ return None
|
| 126 |
+
+ obj = others[0]
|
| 127 |
+
+ for act in sorted(self.admissible):
|
| 128 |
+
+ if act.startswith(f"move {obj} "):
|
| 129 |
+
+ return act
|
| 130 |
+
+ if self.loc:
|
| 131 |
+
+ step = f"move {obj} to {self.loc}"
|
| 132 |
+
+ if not self._fail(step) and self._legal(step):
|
| 133 |
+
+ return step
|
| 134 |
+
+ return None
|
| 135 |
+
+
|
| 136 |
+
def next_action(self) -> str | None:
|
| 137 |
+
if not self.mission or self.solved:
|
| 138 |
+
return None
|
| 139 |
+
@@ -761,6 +845,10 @@ class _AlfState:
|
| 140 |
+
held = sorted(o for o in self.held if _obj_base(o) == base)
|
| 141 |
+
placed = sorted(o for o in self._completed() if _obj_base(o) == base)
|
| 142 |
+
|
| 143 |
+
+ release = self._release_step()
|
| 144 |
+
+ if release:
|
| 145 |
+
+ return release
|
| 146 |
+
+
|
| 147 |
+
if m["kind"] == "light":
|
| 148 |
+
lamp, lamp_loc = self._lamp()
|
| 149 |
+
if not self.lamp_on:
|
| 150 |
+
@@ -801,7 +889,7 @@ class _AlfState:
|
| 151 |
+
step = f"go to {app}"
|
| 152 |
+
if not self._fail(step):
|
| 153 |
+
return step
|
| 154 |
+
- if app and app not in self.open and _obj_base(app) in _ALF_CONTAINERS:
|
| 155 |
+
+ if app and app not in self.open and _obj_base(app) in _ALF_OPENABLE:
|
| 156 |
+
step = f"open {app}"
|
| 157 |
+
if not self._fail(step):
|
| 158 |
+
return step
|
| 159 |
+
@@ -814,7 +902,7 @@ class _AlfState:
|
| 160 |
+
step = f"go to {dest}"
|
| 161 |
+
if not self._fail(step):
|
| 162 |
+
return step
|
| 163 |
+
- if dest and dest not in self.open and _obj_base(dest) in _ALF_CONTAINERS:
|
| 164 |
+
+ if dest and dest not in self.open and _obj_base(dest) in _ALF_OPENABLE:
|
| 165 |
+
step = f"open {dest}"
|
| 166 |
+
if not self._fail(step):
|
| 167 |
+
return step
|
| 168 |
+
@@ -896,6 +984,10 @@ class _AlfState:
|
| 169 |
+
not m["kind"] or m["kind"] in self.transformed.get(o, ())
|
| 170 |
+
for o in held) else ""
|
| 171 |
+
lines.append("Holding: " + ", ".join(held) + processed + ".")
|
| 172 |
+
+ others = self._held_other()
|
| 173 |
+
+ if others:
|
| 174 |
+
+ lines.append("Also holding (NOT the goal object): " + ", ".join(others)
|
| 175 |
+
+ + " -- put it down first; full hands make the target untakeable.")
|
| 176 |
+
if placed:
|
| 177 |
+
lines.append(f"Already placed: {len(placed)}/{m['count']} "
|
| 178 |
+
+ ", ".join(placed) + ".")
|
Experiments/ALFWorld/qwen3.5-9b_loop/dsh-deepseek-flash/ahe/patches/round-3.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"round": 3,
|
| 3 |
+
"from": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 4 |
+
"to": "4fc9a6021732b153e34f9c3947055719daa411c6",
|
| 5 |
+
"files": [],
|
| 6 |
+
"added": 0,
|
| 7 |
+
"removed": 0
|
| 8 |
+
}
|