diff --git a/test/manual/agent_density.py b/test/manual/agent_density.py index c6e1dab53..2e549df14 100644 --- a/test/manual/agent_density.py +++ b/test/manual/agent_density.py @@ -24,7 +24,7 @@ import time ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT / "test/e2e")) import harness # noqa: E402 -from harness import Albedo, Daemon, Provider, latest_user, python, text # noqa: E402 +from harness import Albedo, Daemon, Provider, python, text # noqa: E402 from inspect_support import Inspection # noqa: E402 DEFINE = """import fractions @@ -136,8 +136,19 @@ def main(): gate = daemon.root / "cell-gate" def script(request): - prompt = latest_user(request).split("")[0] - if request["input"][-1].get("role") == "user": + # Notes (a restored namespace, hook context) arrive as their own user + # items; neither is the prompt nor starts a fresh turn. + users = [ + item.get("content", "") + for item in request["input"] + if item.get("role") == "user" + and not str(item.get("content", "")).startswith("") + ] + prompt = (users[-1] if users else "").split("")[0] + last = request["input"][-1] + if last.get("role") == "user" and not str(last.get("content", "")).startswith( + "" + ): if prompt.startswith("define:"): return python(DEFINE) if prompt.startswith("recall:"):