Replay your coding agent sessions as a map and a timeline
Python agent-observabilityai-agentsclaudeclaude-codecodexcoding-agentscursordeveloper-toolsdevtoolsgithub-copilotkirollmobservabilityopencodeprivacypythonsession-replaytypescriptvisualization
fix: validate --at first, bump facts version, lock threads on Windows
aiswaryasankartestd3258ba7b787
diff --git a/python/src/agentplay/cli.py b/python/src/agentplay/cli.pyindex 20b8285..8163034 100644--- a/python/src/agentplay/cli.py+++ b/python/src/agentplay/cli.py@@ -333,12 +333,16 @@ def _health_fixes(st: Store, days: int = 30) -> list[dict]:def _pick_fix(st: Store, items: list[dict], target: str) -> dict | None:"""A fix by its 1-based number in ``items`` or by id (the viewer shows ids, over any window)."""- if target.isdigit():- n = int(target)- return items[n - 1] if 1 <= n <= len(items) else Noneif not target:return None- return next((f for f in items if f["id"] == target), None) or next(+ # An exact id first: ids are hex, so one can be all digits.+ exact = next((f for f in items if f["id"] == target), None)+ if exact is not None:+ return exact+ if target.isdigit() and len(target) < 12:+ n = int(target)+ return items[n - 1] if 1 <= n <= len(items) else None+ return next((f for f in _health_fixes(st, days=36500) if f["id"] == target), None)@@ -408,6 +412,10 @@ def cmd_autotune(args: argparse.Namespace) -> int:st = Store()try:if args.action == "on":+ # Checked before anything changes: a typo must not leave Autotune without a schedule.+ if args.at and not re.fullmatch(r"([01]?\d|2[0-3]):[0-5]\d", args.at):+ print("agentplay: --at takes a 24-hour time, like 09:00.", file=sys.stderr)+ return 1for repo in args.repo or [r["name"] for r in fixes.status(st.base)["repos"] if r["granted"]]:autotune.set_repo(st.base, repo, enabled=True)cfg = autotune.config(st.base)diff --git a/python/src/agentplay/facts.py b/python/src/agentplay/facts.pyindex 857db19..1d241ea 100644--- a/python/src/agentplay/facts.py+++ b/python/src/agentplay/facts.py@@ -18,7 +18,7 @@ from typing import Anyfrom .builder import _NON_CALL_KINDS, _error_source, estimate_cost_usd-FACTS_VERSION = 3+FACTS_VERSION = 4# Outcomes whose whole cost counts as abandoned spend. `interrupted` is left# out on purpose: stopping an agent is often the right call.diff --git a/python/src/agentplay/fixes.py b/python/src/agentplay/fixes.pyindex 6ef85d9..22fd0f5 100644--- a/python/src/agentplay/fixes.py+++ b/python/src/agentplay/fixes.py@@ -50,6 +50,9 @@ class FixError(Exception):# ------------------------------------------------------------------ locking_held = threading.local()+# Threads of one process: flock already separates them (one open file each), but+# msvcrt locks belong to the process, so Windows needs this too.+_process_lock = threading.Lock()@contextmanager@@ -68,7 +71,7 @@ def write_lock(base: Path) -> Iterator[None]:_held.depth -= 1returnbase.mkdir(parents=True, exist_ok=True)- with open(base / "write.lock", "a+b") as fh:+ with _process_lock, open(base / "write.lock", "a+b") as fh:_lock_file(fh, True)_held.depth = 1try:diff --git a/python/tests/test_search_health_fixes.py b/python/tests/test_search_health_fixes.pyindex fe782d1..c6a0fe7 100644--- a/python/tests/test_search_health_fixes.py+++ b/python/tests/test_search_health_fixes.py@@ -368,6 +368,7 @@ def test_cache_miss_requests_are_charged_once():{"seq": 3, "kind": "read", "agent": "main", "targets": [{"file": 1, "touch": "read"}]},{"seq": 4, "kind": "llm", "agent": "main", "cost": 1.0, "in": 1_000_000, "model": "claude-sonnet-4"},]+ assert facts._cache_miss_usd("claude-sonnet-4", 1_000_000) > 0 # there is an estimate to movewaste = facts._waste({"agents": []}, evs, "completed")# Request 4 is a re-read's: its full cost goes there, and its cache-miss estimate leaves cacheMiss.assert waste["reread"] == 1.0 and waste["cacheMiss"] == 0@@ -390,3 +391,26 @@ def test_resolver_roots_keep_the_latest_checkout(tmp_path):r.resolve(str(a))name = next(iter(r.roots()))assert r.roots()[name] == str(a)+++def test_an_all_digit_fix_id_is_matched_before_a_list_number(tmp_path):+ from agentplay import cli++ items = [{"id": "aaaaaaaaaaaa"}, {"id": "123456789012"}]+ assert cli._pick_fix(None, items, "123456789012")["id"] == "123456789012"+ assert cli._pick_fix(None, items, "1")["id"] == "aaaaaaaaaaaa"+ assert cli._pick_fix(None, items, "0") is None+++def test_bad_cron_time_leaves_the_hook_alone(monkeypatch, capsys):+ from agentplay import cli++ called = []+ monkeypatch.setattr(autotune, "uninstall_hook", lambda: called.append(1))+ monkeypatch.setattr(cli, "Store", lambda: None)+ monkeypatch.setattr(fixes, "status", lambda _b: {"repos": []})++ class A:+ action, at, repo = "on", "9am", []++ assert cli.cmd_autotune(A()) == 1 and not calleddiff --git a/viewer/public/demo/index.json b/viewer/public/demo/index.jsonindex 2f6503c..e825798 100644--- a/viewer/public/demo/index.json+++ b/viewer/public/demo/index.json@@ -234,7 +234,7 @@"reworkEdits": 0,"stepsToFirstEdit": 5},- "factsVersion": 3+ "factsVersion": 4},{"sessionId": "local:codex:0199a3b2-demo-4f0c-8e55-000000000002",@@ -389,7 +389,7 @@"reworkEdits": 0,"stepsToFirstEdit": 7},- "factsVersion": 3+ "factsVersion": 4},{"sessionId": "local:cursor:c1d2e3f4-demo-4a5b-9c8d-000000000003",@@ -486,7 +486,7 @@"reworkEdits": 0,"stepsToFirstEdit": 2},- "factsVersion": 3+ "factsVersion": 4}]}