Tool turn: character reads seeded manifest via her terminal
Browse files- tests/e2e_roleplay.py +21 -1
tests/e2e_roleplay.py
CHANGED
|
@@ -40,6 +40,8 @@ os.environ["FREESTREAM_WHISPER_THREADS"] = "1"
|
|
| 40 |
os.environ["FREESTREAM_AGENT"] = "llm"
|
| 41 |
os.environ["FREESTREAM_CONTENT_POLICY"] = "mature" # operator opt-in (CONSENT.md §6)
|
| 42 |
os.environ["FREESTREAM_CHARACTER_CARD"] = "identity/characters/vera-steel.json"
|
|
|
|
|
|
|
| 43 |
os.environ["PYTHONPATH"] = str(ROOT)
|
| 44 |
sys.path.insert(0, str(ROOT))
|
| 45 |
os.environ.setdefault("FREESTREAM_LIVEKIT_URL", "ws://localhost:7880")
|
|
@@ -98,6 +100,16 @@ check("policy gate: mature prompt removes sanitizer", "mature mode" in mature_sy
|
|
| 98 |
first_line = CharacterAgent(bot_name="x").first_utterance()
|
| 99 |
check("policy gate: AI disclosure survives every policy", "AI assistant" in first_line)
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
# ---- server -------------------------------------------------------------------
|
| 102 |
if not (ROOT / "livekit-server").exists():
|
| 103 |
req = urllib.request.Request(GH_LATEST, headers={"Accept": "application/vnd.github+json"})
|
|
@@ -173,6 +185,9 @@ QUESTIONS = [
|
|
| 173 |
("Captain, who am I talking to?", ("vera", "steel", "captain")),
|
| 174 |
("What's our cargo, and where are we headed?", ("cargo", "ceres", "freight", "haul", "credits")),
|
| 175 |
("Talk to me — what's the fastest route to Ceres?", ("ceres", "course", "day", "hour", "burn", "route")),
|
|
|
|
|
|
|
|
|
|
| 176 |
]
|
| 177 |
DISCLOSURE_KEYWORDS = ("ai", "automated")
|
| 178 |
|
|
@@ -268,6 +283,10 @@ bot_log = EventLog(sdir / "bot-events.jsonl").events()
|
|
| 268 |
actions = [e for e in bot_log if e["type"] == "agent.action"]
|
| 269 |
check("character *actions* logged as events", len(actions) >= 1,
|
| 270 |
"; ".join(a["payload"]["text"] for a in actions)[:160])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
# ---- leave + logs ----------------------------------------------------------------
|
| 273 |
r = run_cli("leave", "--session-id", sid)
|
|
@@ -289,7 +308,8 @@ for i, t in enumerate(turns, start=1):
|
|
| 289 |
print(f"turn {i} t_perceived: {t['t_perceived']:.2f}s '{t['text'][:90]}'")
|
| 290 |
|
| 291 |
failed = [n for n, ok in results if not ok]
|
| 292 |
-
slow = [t[
|
|
|
|
| 293 |
print(f"\n{len(results) - len(failed)}/{len(results)} checks passed")
|
| 294 |
if failed or slow:
|
| 295 |
print("FAILED: " + ", ".join(failed + (["turn > 12s"] if slow else [])))
|
|
|
|
| 40 |
os.environ["FREESTREAM_AGENT"] = "llm"
|
| 41 |
os.environ["FREESTREAM_CONTENT_POLICY"] = "mature" # operator opt-in (CONSENT.md §6)
|
| 42 |
os.environ["FREESTREAM_CHARACTER_CARD"] = "identity/characters/vera-steel.json"
|
| 43 |
+
os.environ["FREESTREAM_TOOLS"] = "fs,shell" # operator grants the character a terminal
|
| 44 |
+
os.environ["FREESTREAM_WORKSPACE"] = str(ROOT / "workspace")
|
| 45 |
os.environ["PYTHONPATH"] = str(ROOT)
|
| 46 |
sys.path.insert(0, str(ROOT))
|
| 47 |
os.environ.setdefault("FREESTREAM_LIVEKIT_URL", "ws://localhost:7880")
|
|
|
|
| 100 |
first_line = CharacterAgent(bot_name="x").first_utterance()
|
| 101 |
check("policy gate: AI disclosure survives every policy", "AI assistant" in first_line)
|
| 102 |
|
| 103 |
+
# ---- seed the ship's workspace (the character's tool sandbox) ----------------
|
| 104 |
+
workspace = ROOT / "workspace"
|
| 105 |
+
workspace.mkdir(parents=True, exist_ok=True)
|
| 106 |
+
(workspace / "manifest.txt").write_text(
|
| 107 |
+
"LONG DAWN — CARGO MANIFEST, REV 7\n"
|
| 108 |
+
"1. cryo-seed vaults x12 (ArborGen charter) — bay 2\n"
|
| 109 |
+
"2. fusion torch liners x40 — bay 1\n"
|
| 110 |
+
"3. patient-nanite kits x900 (sealed) — bay 3\n"
|
| 111 |
+
"DESTINATION: Ceres Station, high dock. ETA 11 days at burn-0.3g.\n")
|
| 112 |
+
|
| 113 |
# ---- server -------------------------------------------------------------------
|
| 114 |
if not (ROOT / "livekit-server").exists():
|
| 115 |
req = urllib.request.Request(GH_LATEST, headers={"Accept": "application/vnd.github+json"})
|
|
|
|
| 185 |
("Captain, who am I talking to?", ("vera", "steel", "captain")),
|
| 186 |
("What's our cargo, and where are we headed?", ("cargo", "ceres", "freight", "haul", "credits")),
|
| 187 |
("Talk to me — what's the fastest route to Ceres?", ("ceres", "course", "day", "hour", "burn", "route")),
|
| 188 |
+
# tool turn: the answer must come from the REAL file via the character's terminal
|
| 189 |
+
("Run a scan of the manifest on the bridge console and tell me exactly what we're carrying.",
|
| 190 |
+
("cryo", "seed", "manifest", "grain")),
|
| 191 |
]
|
| 192 |
DISCLOSURE_KEYWORDS = ("ai", "automated")
|
| 193 |
|
|
|
|
| 283 |
actions = [e for e in bot_log if e["type"] == "agent.action"]
|
| 284 |
check("character *actions* logged as events", len(actions) >= 1,
|
| 285 |
"; ".join(a["payload"]["text"] for a in actions)[:160])
|
| 286 |
+
tools = [e for e in bot_log if e["type"] == "agent.tool"]
|
| 287 |
+
shell_calls = [e for e in tools if e["payload"]["tool"] == "shell"]
|
| 288 |
+
check("character used the terminal (agent.tool: shell)", len(shell_calls) >= 1,
|
| 289 |
+
" | ".join(e["payload"].get("args", "")[:80] for e in tools)[:200])
|
| 290 |
|
| 291 |
# ---- leave + logs ----------------------------------------------------------------
|
| 292 |
r = run_cli("leave", "--session-id", sid)
|
|
|
|
| 308 |
print(f"turn {i} t_perceived: {t['t_perceived']:.2f}s '{t['text'][:90]}'")
|
| 309 |
|
| 310 |
failed = [n for n, ok in results if not ok]
|
| 311 |
+
slow = [f"turn {i}: {t['t_perceived']:.1f}s" for i, t in enumerate(turns, 1)
|
| 312 |
+
if t and t["t_perceived"] > (30.0 if i == len(turns) else 12.0)]
|
| 313 |
print(f"\n{len(results) - len(failed)}/{len(results)} checks passed")
|
| 314 |
if failed or slow:
|
| 315 |
print("FAILED: " + ", ".join(failed + (["turn > 12s"] if slow else [])))
|