Skip to content

The agent that grows with you

test: resize E2E dumps provider request count, agent/errors log tails and a CLI thread dump on a missed wait

teknium1e233005ca561
diff --git a/tests/e2e/core/cli_tmux/test_resize_scrollback.py b/tests/e2e/core/cli_tmux/test_resize_scrollback.py
index 8631a6ecb59..534b862ef82 100644
--- a/tests/e2e/core/cli_tmux/test_resize_scrollback.py
+++ b/tests/e2e/core/cli_tmux/test_resize_scrollback.py
@@ -15,6 +15,7 @@ from __future__ import annotations
import os
import re
import shutil
+import signal
import subprocess
import sys
import time
@@ -48,10 +49,31 @@ def test_resizes_keep_each_transcript_line_once_in_tmux_scrollback(tmp_path: Pat
def transcript() -> str:
return tmux("capture-pane", "-p", "-J", "-t", "p", "-S", "-", "-E", "-")
+ script = [Text(_reply(t), chunk_chars=10, delay_per_chunk=0.03) for t in WORDS]
+ llm = FakeLLMServer(script, aux=lambda _r: Text("Scripted session title"))
+
+ def diagnostics() -> str:
+ # What a red needs to be actionable: did the turn reach the provider, what did the CLI log,
+ # and where is every thread of the CLI parked (faulthandler dump on SIGABRT, into the pane).
+ kinds = Counter(r["kind"] for r in llm.requests)
+ out = [f"fake provider requests: main={kinds['main']} aux={kinds['aux']}"]
+ for name in ("agent.log", "errors.log"):
+ log = home / ".hermes" / "logs" / name
+ tail = log.read_text(errors="replace").splitlines()[-40:] if log.exists() else ["<missing>"]
+ out += [f"--- {name} (tail) ---", *tail]
+ pid = tmux("display-message", "-p", "-t", "p", "#{pane_pid}").strip()
+ if pid.isdigit():
+ os.kill(int(pid), signal.SIGABRT)
+ time.sleep(2.0)
+ out += ["--- CLI thread dump ---", transcript()[-6000:]]
+ return "\n".join(out)
+
def wait_for(needle: str, timeout: float = 60.0) -> None:
end = time.monotonic() + timeout
while needle not in transcript():
- assert time.monotonic() < end, f"{needle!r} never appeared:\n{transcript()[-3000:]}"
+ if time.monotonic() >= end:
+ screen = transcript()[-3000:]
+ pytest.fail(f"{needle!r} never appeared:\n{screen}\n{diagnostics()}")
time.sleep(0.1)
def resize(cols: int) -> None:
@@ -72,12 +94,11 @@ def test_resizes_keep_each_transcript_line_once_in_tmux_scrollback(tmp_path: Pat
wait_for(f"t{turn}w{WORDS[turn] - 1:03d}")
time.sleep(2.0)
- script = [Text(_reply(t), chunk_chars=10, delay_per_chunk=0.03) for t in WORDS]
- with FakeLLMServer(script, aux=lambda _r: Text("Scripted session title")) as llm:
+ with llm:
write_hermes_home(home / ".hermes", llm.base_url)
env = {k: v for k, v in os.environ.items() if not k.startswith(("HERMES_", "TMUX"))}
env.update(HOME=str(home), HERMES_HOME=str(home / ".hermes"), PYTHONPATH=str(REPO_ROOT),
- TERM="xterm-256color")
+ TERM="xterm-256color", PYTHONFAULTHANDLER="1")
argv = [sys.executable, "-m", "hermes_cli.main", "chat", "--cli", "--yolo"]
subprocess.run(["tmux", "-L", sock, "-f", os.devnull, "new-session", "-d", "-s", "p", "-x", "120",
"-y", "24", "-c", str(tmp_path / "work"), *argv], env=env, check=True, timeout=30)