2026-09-13 16:38:32 +00:00
|
|
|
|
"""Small opt-in test using the existing model config and a disposable workspace."""
|
|
|
|
|
|
import json
|
|
|
|
|
|
import os
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
import subprocess
|
|
|
|
|
|
import tempfile
|
|
|
|
|
|
|
2026-09-15 05:20:44 +00:00
|
|
|
|
BINARY=Path(__file__).resolve().parents[1]/'target/debug/lazyboy'
|
2026-09-13 16:38:32 +00:00
|
|
|
|
def main():
|
2026-09-15 05:20:44 +00:00
|
|
|
|
with tempfile.TemporaryDirectory(prefix='lazyboy-live-') as root:
|
2026-09-13 16:38:32 +00:00
|
|
|
|
Path(root,'items.txt').write_text('banana\napple\nbanana\npear\n')
|
2026-09-15 05:20:44 +00:00
|
|
|
|
env={**os.environ,'LAZYBOY_MAX_ROUNDS_TOTAL':'12','LAZYBOY_MAX_ROUNDS':'4',
|
|
|
|
|
|
'LAZYBOY_SESSIONS_DIR':str(Path(root,'sessions')),'LAZYBOY_PROGRESS':'1'}
|
2026-09-13 16:38:32 +00:00
|
|
|
|
prompt='幫我整理目前目錄的 items.txt:去除重複、依字母排序,另存 clean.txt,每行一筆;再產生 report.txt,用數字記錄原本幾筆、整理後幾筆。請實際讀回兩個產物確認內容,最後告訴我結果。只需要操作目前目錄,不需要上網。'
|
|
|
|
|
|
result=subprocess.run([str(BINARY),'run',prompt],cwd=root,env=env,stdin=subprocess.DEVNULL,
|
|
|
|
|
|
capture_output=True,text=True,timeout=240)
|
|
|
|
|
|
print(result.stderr[-5000:])
|
|
|
|
|
|
print(result.stdout)
|
|
|
|
|
|
assert result.returncode==0, result.returncode
|
|
|
|
|
|
assert Path(root,'clean.txt').read_text().splitlines()==['apple','banana','pear']
|
|
|
|
|
|
report=Path(root,'report.txt').read_text()
|
|
|
|
|
|
assert '4' in report and '3' in report,report
|
|
|
|
|
|
assert '〔進度〕' in result.stderr or '〔計畫〕' in result.stderr
|
|
|
|
|
|
session=json.loads(next(Path(root,'sessions').glob('*.json')).read_text())
|
|
|
|
|
|
assert session['last_verdict'] in ('done','answer')
|
|
|
|
|
|
print('PASS live model: opening/progress, tools, two verified artifacts and final answer')
|
|
|
|
|
|
if __name__=='__main__':main()
|