Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .github/workflows/games.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@ jobs:
- run: python -m pip install -e .
- run: harbor run --game-suite minihack-balrog --standard --list
- run: python game_first_exam/tests/test_game_harbor.py
collab-overcooked:
runs-on: ubuntu-latest
timeout-minutes: 35
steps:
- uses: actions/checkout@v4
with: {persist-credentials: false}
- uses: actions/setup-python@v5
with: {python-version: '3.12'}
- uses: actions/checkout@v4
with:
repository: YusaeMeow/Collab-Overcooked
ref: d7ae1aa5e63d8ec076e96ee437fcbbd095278ef4
path: .local/reference
persist-credentials: false
- run: python -m pip install -e .
- run: harbor run --game-suite collab-overcooked --offline-smoke --job-name collab-smoke -y
- run: python ci_checks/check-collab-overcooked.py jobs/collab-smoke .local/reference
- if: always()
uses: actions/upload-artifact@v4
with:
name: collab-overcooked-harbor
path: jobs/
retention-days: 7
fresh-clone-smoke:
runs-on: ubuntu-latest
timeout-minutes: 30
Expand Down Expand Up @@ -78,7 +101,7 @@ jobs:
path: jobs/
retention-days: 7
invariants:
needs: [static, adapters, harbor, fresh-clone-smoke]
needs: [static, adapters, harbor, fresh-clone-smoke, collab-overcooked]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
Expand All @@ -87,4 +110,5 @@ jobs:
ADAPTERS: ${{ needs.adapters.result }}
HARBOR: ${{ needs.harbor.result }}
SMOKE: ${{ needs.fresh-clone-smoke.result }}
run: test "$STATIC" = success && test "$ADAPTERS" = success && test "$HARBOR" = success && test "$SMOKE" = success
COLLAB: ${{ needs.collab-overcooked.result }}
run: test "$STATIC" = success && test "$ADAPTERS" = success && test "$HARBOR" = success && test "$SMOKE" = success && test "$COLLAB" = success
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Game Exam 基于 [Embodied First Exam](https://github.com/mll-lab-nu/embodied-first-exam) 的任务封装和 [Harbor](https://github.com/laude-institute/harbor) 执行方式构建。本仓库只包含游戏任务、游戏适配器和它们依赖的公共工具,不包含机器人 benchmark、网站源码、个人配置或历史评测日志。

模型通过 Harbor 原生 coding agent 阅读任务的 `instruction.md`,在容器内编写并执行 Python 等程序,通过客户端操作游戏。游戏环境负责推进状态,独立 verifier 根据可信记录评分。这里没有另建直接 LLM 对话式动作入口或 RL 训练入口。
冻结任务通过 Harbor 原生 coding agent 阅读 `instruction.md`,在容器内编写并执行程序,通过客户端操作游戏。Collab-Overcooked 使用作者的双角色协议。游戏环境负责推进状态,独立 verifier 根据可信记录评分。

> 当前是开发与接入验证版本。冻结任务是已确定环境、实例、seed、观测方式和预算的可复现配置,不等于 benchmark 的全部任务,也不是新的官方排行榜。网站源码在单独的私人仓库维护。

Expand All @@ -24,7 +24,7 @@ Game Exam 基于 [Embodied First Exam](https://github.com/mll-lab-nu/embodied-fi

## 已接入的游戏

当前共有 **5 个 benchmark、42 个 standard 任务配置,另外有 1 个 privileged 和 1 个 realtime 配置,共 44 个任务目录**。同一原生任务的不同模式单独计数。
当前接入 **6 个 benchmark**。其中 5 个提供冻结任务,共 42 个 standard、1 个 privileged 和 1 个 realtime 配置。Collab-Overcooked 另提供论文的 30 道菜,可用 `harbor run --game-suite collab-overcooked --list` 查看。

| Benchmark | standard | 其他模式 | 主要内容 | 说明 |
|---|---:|---|---|---|
Expand All @@ -33,8 +33,9 @@ Game Exam 基于 [Embodied First Exam](https://github.com/mll-lab-nu/embodied-fi
| TextWorld | 9 | — | 文字探索、寻宝、烹饪 | 冻结 `.z8` 游戏,通过原生引擎执行 |
| Baba Is AI | 2 | — | 移动文字、改变规则、解谜 | 基础关卡与复合关卡的最小 smoke 验证 |
| MiniHack | 10 | 1 privileged | Room、River、导航、战斗、Quest、Boxoban | 原生 MiniHack/NLE 环境;Room 另有 privileged 版本 |
| Collab-Overcooked | — | 原生双角色 | Chef 和 Assistant 合作完成 6 档食谱 | [运行与隔离说明](game_first_exam/benchmarks/collab_overcooked/README.md) |

套件由 [configs/game_suites/](configs/game_suites/) 定义,可以重叠,数量不能直接相加:
以下冻结任务套件可以重叠,完整清单见 [configs/game_suites/](configs/game_suites/)。

| `--game-suite` | 配置数 | 用途 |
|---|---:|---|
Expand Down
93 changes: 93 additions & 0 deletions ci_checks/check-collab-overcooked.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
"""Compare the Harbor split to a direct run of the unedited upstream benchmark."""
import ast
import hashlib
import json
from pathlib import Path
import subprocess
import sys
import tempfile
import tomllib

ROOT = Path(__file__).resolve().parents[1]


def check_live_isolation(catalog):
import yaml
sys.path.insert(0, str(ROOT / "scripts"))
from collab_overcooked import prepare

images = {"sim": "sim", "role": "role", "grader": "grader"}
with tempfile.TemporaryDirectory() as tmp:
dest = Path(tmp)
source = ROOT / "game_first_exam/benchmarks/collab_overcooked"
prepare(source, dest, ["boiled_egg"], catalog, "gpt-4o", False, images)
task = dest / "collab-boiled-egg"
config = yaml.safe_load((task / "environment/docker-compose.yaml").read_text())
services = config["services"]
for role in ("chef", "assistant"):
assert services[role]["volumes"] == [role + ":/role:ro"]
assert services[role]["secrets"] == ["model_key"]
assert services[role]["read_only"] and services[role]["cap_drop"] == ["ALL"]
assert "COLLAB_PROBE" not in services[role]["environment"]
assert not set(services["chef"]["networks"]).intersection(services["assistant"]["networks"])
assert all(services[name]["network_mode"] == "none" and "secrets" not in services[name]
for name in ("sim", "main"))
assert int(services["sim"]["environment"]["REPEATS"]) == 10
assert (task / "solution/solve.sh").stat().st_mode & 0o001


def main(job, upstream):
catalog = tomllib.loads((ROOT / "configs/native_benchmarks/collab-overcooked.toml").read_text())
head = subprocess.check_output(["git", "-C", upstream, "rev-parse", "HEAD"], text=True).strip()
assert head == catalog["revision"]
levels = {node.targets[0].id: ast.literal_eval(node.value)
for node in ast.parse((upstream / "src/convert_result.py").read_text()).body
if isinstance(node, ast.Assign) and isinstance(node.targets[0], ast.Name)
and node.targets[0].id.startswith("level_")}
assert levels == catalog["levels"]
check_live_isolation(catalog)
[trial_result] = job.glob("*/result.json")
trial = trial_result.parent
result = json.loads(trial_result.read_text())
assert result["exception_info"] is None, result["exception_info"]
assert not (trial / "agent/exit-code.txt").exists(), (trial / "agent/oracle.txt").read_text()
data = trial / "artifacts"
manifest = json.loads((data / "manifest.json").read_text())
assert any(a["source"] == "/evidence" and a["service"] == "sim" and a["status"] == "ok" for a in manifest)
timeline = (trial / "trial.log").read_text()
assert timeline.index("Main service stopped") < timeline.index("Collect hook in service 'sim' completed")
[evaluated] = (data / "evidence").rglob("experiment_*.json")
rewards = json.loads((trial / "verifier/reward.json").read_text())
assert rewards == {"SR": 1.0, "PC": 1.0, "IC": 1.0, "RC": 1.0}, rewards
assert result["verifier_result"]["rewards"] == rewards
[config] = (job.parent / "prepared").glob("collab-*/job.json")
task = Path(json.loads(config.read_text())["tasks"][0]["path"])
import yaml
services = yaml.safe_load((task / "environment/docker-compose.yaml").read_text())["services"]
sim = services["sim"]["image"]
for name in ("chef", "assistant"):
assert services[name]["network_mode"] == "none" and services[name]["read_only"]
assert services[name]["volumes"] == [name + ":/role:ro"]
for name in ("sim", "chef", "assistant", "main"):
assert services[name]["network_mode"] == "none"
checks = {"main.py": "src/main.py", "collab/collab.py": "src/collab/collab.py",
"collab/modules.py": "src/collab/modules.py",
"/bench/lib/overcooked_ai_py/mdp/overcooked_mdp.py": "lib/overcooked_ai/overcooked_ai_py/mdp/overcooked_mdp.py"}
grader = (task / "tests/Dockerfile").read_text().splitlines()[0].split()[1]
for image, files in ((sim, checks), (grader, {"eval_utils.py": "src/eval_utils.py", "time_step.py": "src/time_step.py"})):
hashes = subprocess.check_output(["docker", "run", "--rm", "--network", "none", image,
"sha256sum", *files], text=True).splitlines()
for line, path in zip(hashes, files.values(), strict=True):
assert line.split()[0] == hashlib.sha256((upstream / path).read_bytes()).hexdigest(), path
direct = subprocess.check_output([
"docker", "run", "--rm", "--network", "none",
"-v", f"{ROOT}/game_first_exam/tests/collab_native_probe.py:/integration/direct.py:ro",
"-v", f"{ROOT}/game_first_exam/benchmarks/collab_overcooked/fixture_policy.py:/integration/fixture_policy.py:ro",
sim, "sh", "-ec", "python /integration/direct.py /tmp/golden >&2 && cat /tmp/golden/*/*/experiment_*.json",
])
assert json.loads(evaluated.read_text()) == json.loads(direct), "Native trajectories differ"
print("PASS: sealed Harbor trajectory matches direct native run; SR=PC=IC=RC=1")


if __name__ == "__main__":
main(Path(sys.argv[1]).resolve(), Path(sys.argv[2]).resolve())
11 changes: 11 additions & 0 deletions configs/native_benchmarks/collab-overcooked.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source = "https://github.com/YusaeMeow/Collab-Overcooked.git"
revision = "d7ae1aa5e63d8ec076e96ee437fcbbd095278ef4"
repetitions = 10

[levels]
level_1 = ["baked_bell_pepper", "baked_sweet_potato", "boiled_egg", "boiled_mushroom", "boiled_sweet_potato"]
level_2 = ["baked_potato_slices", "baked_pumpkin_slices", "boiled_corn_slices", "boiled_green_bean_slices", "boiled_potato_slices"]
level_3 = ["baked_bell_pepper_soup", "baked_carrot_soup", "baked_mushroom_soup", "baked_potato_soup", "baked_pumpkin_soup"]
level_4 = ["sliced_bell_pepper_and_corn_stew", "sliced_bell_pepper_and_lentil_stew", "sliced_eggplant_and_chickpea_stew", "sliced_pumpkin_and_chickpea_stew", "sliced_zucchini_and_chickpea_stew"]
level_5 = ["mashed_broccoli_and_bean_patty", "mashed_carrot_and_chickpea_patty", "mashed_cauliflower_and_lentil_patty", "mashed_potato_and_pea_patty", "mashed_sweet_potato_and_bean_patty"]
level_6 = ["potato_carrot_and_onion_patty", "romaine_lettuce_pea_and_tomato_patty", "sweet_potato_spinach_and_mushroom_patty", "taro_bean_and_bell_pepper_patty", "zucchini_green_pea_and_onion_patty"]
44 changes: 44 additions & 0 deletions game_first_exam/benchmarks/collab_overcooked/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# syntax=docker/dockerfile:1.7
FROM python:3.10-slim-bookworm AS base
WORKDIR /bench/src
ENV PYTHONUTF8=1 PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=/bench/src:/bench/lib:/integration
COPY --from=upstream /LICENSE /licenses/Collab-Overcooked
COPY --from=upstream /lib/overcooked_ai/LICENSE /licenses/Overcooked-AI

FROM base AS dependencies
COPY requirements.txt /requirements.txt
RUN pip install --no-cache-dir -r /requirements.txt

FROM dependencies AS role
COPY --from=upstream /src/collab/modules.py /src/collab/utils.py /src/collab/web_util.py ./collab/
COPY --from=upstream /lib/overcooked_ai/overcooked_ai_py/mdp/actions.py /bench/lib/overcooked_ai_py/mdp/actions.py
COPY --from=upstream /lib/llama_tokenizer /bench/lib/llama_tokenizer
ENV TIKTOKEN_CACHE_DIR=/opt/tokens
RUN python -c "import tiktoken; tiktoken.encoding_for_model('gpt-4')"
COPY role.py wire.py /integration/
RUN touch openai_key.txt
USER 65534:65534
CMD ["python","/integration/role.py"]

FROM role AS probe
COPY fixture_policy.py /integration/

FROM dependencies AS engine
COPY --from=upstream /lib/overcooked_ai/overcooked_ai_py /bench/lib/overcooked_ai_py
COPY --from=upstream /lib/overcooked_ai/setup.py /bench/lib/setup.py
RUN pip install --no-deps -e ../lib

FROM engine AS sim
COPY --from=upstream /src/collab ./collab
COPY --from=upstream /src/main.py /src/utils.py ./
COPY --from=upstream /src/prompts/gpt ./prompts/gpt
COPY --from=upstream /src/prompts/recipe ./prompts/recipe
COPY adapter.py wire.py /integration/
RUN touch openai_key.txt && mkdir -p /channels/Chef /channels/Assistant /status /evidence && chown -R 65534:65534 /channels /status /evidence /bench/lib/overcooked_ai_py/data/planners && chmod 777 /channels/* /status
USER 65534:65534
CMD ["python","/integration/adapter.py"]

FROM engine AS grader
COPY --from=upstream /src/eval_utils.py /src/time_step.py ./
COPY --from=upstream /src/prompts/reference ./prompts/reference
COPY grade.py /integration/
27 changes: 27 additions & 0 deletions game_first_exam/benchmarks/collab_overcooked/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Collab-Overcooked

这是 Game Exam 的原生双角色套件,入口为 `harbor run --game-suite collab-overcooked`。论文将同一模型放在 Chef(Bob)和 Assistant(Alice)两个位置。双方共享厨房状态,各有可执行动作,只有 Chef 收到完整食谱。两者通过作者定义的语言对话和 `request(...)` 协作。[论文 §3–5](https://aclanthology.org/2025.emnlp-main.249.pdf) · [固定版本的作者实现](https://github.com/YusaeMeow/Collab-Overcooked/tree/d7ae1aa5e63d8ec076e96ee437fcbbd095278ef4)

在已按项目首页安装 Game Exam 的机器上执行。列目录只需要项目的 Python 环境。运行需要 Linux 容器、Docker Compose v2 和支持命名构建上下文的 BuildKit。

```bash
harbor run --game-suite collab-overcooked --list
harbor run --game-suite collab-overcooked --family level_3 --list
harbor run --game-suite collab-overcooked --offline-smoke --job-name collab-smoke -y
```

真实模型运行前,在宿主环境配置 `COLLAB_API_KEY`。默认模型为作者公开实现支持的 `gpt-4o`。运行时使用当前服务提供的模型版本。可通过 `OPENAI_BASE_URL` 指定角色容器能够访问的服务地址,该服务需要兼容所选模型的上游 chat 接口和重复对话检测用的 `text-embedding-3-small` 接口。上游的通用 vLLM 分支使用其自带的占位 API key,适用于允许该配置的自托管服务。

```bash
harbor run --game-suite collab-overcooked -i boiled_egg -m gpt-4o --job-name collab-egg -y
harbor run --game-suite collab-overcooked -m gpt-4o --job-name collab-full -y
```

每个 Harbor trial 对应一道菜,独立启动作者的 `main.py` 十次。完整套件为六档、每档五道菜,共 300 局。每局使用 `new_env`、两个 `LLMPair`、`fix_task` 和上游默认 120 步上限。独立 verifier 对完整轨迹执行作者的 `time_step.py`(γ=1.5)和 `Evaluation.evaluate`,以整道菜的十局为一组计算 SR、PC、IC、RC。PC 取两名角色 TES 的均值。每道菜的四项指标写入 trial 的 `verifier/reward.json`,作者的详细结果在 `verifier/evaluation_result.json`,原始轨迹在 `artifacts/evidence/raw/`。Harbor 的 agent 名称为 `oracle`,职责仅为等待模拟器结束。实际决策模型及角色策略记录在任务元数据里。

## 隔离与上游差异

- 作者的厨房引擎、调度、角色提示、动作解析、轨迹、参考动作模板与评分代码均从注册清单指定的 Git 提交构建。接入层把原本在进程内执行的规划查询和重复发言相似度调用送入对应角色容器。真实模型使用作者的 `Module.query` 和相似度实现。
- 两个只读、非 root 的角色容器各自只能连接自己的 Unix socket。每个容器收到自己的提示和公共对话,镜像中没有食谱库、参考动作模板、轨迹或 verifier。真实模式中每个角色拥有单独的桥接网络以访问推理服务;这些网络允许出站,并未按域名限制。推理凭据通过只挂载到角色容器的 Compose secret 提供。
- 模拟器、Harbor 主容器和独立 verifier 均关闭网络。模拟器持有食谱并记录轨迹,主容器只读运行状态。Harbor 停止主容器后从模拟器收集可信轨迹,verifier 在独立环境加载参考模板。主容器、角色与模拟器均没有 Docker socket。
- `--offline-smoke` 针对 `boiled_egg` 运行一局,角色容器也关闭网络。固定回答和重复发言测试替身只用于 CI。CI 检查角色提示可见性、镜像中的上游文件哈希、收集来源、verifier 奖励,以及同一固定策略直接运行作者入口所产生的完整轨迹。
Loading