Replay your coding agent sessions as a map and a timeline
Python agent-observabilityai-agentsclaudeclaude-codecodexcoding-agentscursordeveloper-toolsdevtoolsgithub-copilotkirollmobservabilityopencodeprivacypythonsession-replaytypescriptvisualization
fix(antigravity): session bounds, URI recursion, consistent summaries copy
shubhook8e1b0886244f
diff --git a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/antigravity.py b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/antigravity.pyindex be65ee6..0c90254 100644--- a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/antigravity.py+++ b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/antigravity.py@@ -209,6 +209,11 @@ def parse_antigravity(if turn is not None and ts is not None and ts > turn["end"]:turn["end"] = ts_close_turn()+ # A tool can finish after the step that recorded it. `Completed At` is+ # that end, and it can be later than every step's created_at.+ for span in all_spans:+ if "tool.name" in span.attributes and span.end_time > session_end:+ session_end = span.end_timeroot_span = SpanData(span_id=root_id,diff --git a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/source.py b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/source.pyindex fd22463..ba2f0b9 100644--- a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/source.py+++ b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/source.py@@ -1234,6 +1234,43 @@ _ANTIGRAVITY_SUMMARY_SQL = ()+def _summary_file_stamp(path: Path) -> tuple[str, int | None, int | None]:+ """`(name, size, mtime_ns)` for one summaries file, or `(name, None, None)` when absent."""+ if not path.is_file():+ return (path.name, None, None)+ st = path.stat()+ return (path.name, st.st_size, st.st_mtime_ns)+++def _antigravity_summary_files(db: Path) -> list[Path]:+ return [db.with_name(db.name + suffix) for suffix in ("", "-wal", "-shm")]+++def _copy_antigravity_summaries(db: Path, tmp_dir: Path) -> None:+ """Copy the db and its sidecars without opening the original.++ `agy` may be writing the WAL while we copy. Stat size and mtime of the db,+ `-wal`, and `-shm` before and after each attempt, and retry up to 3 times+ when any of them changed (including a sidecar appearing or disappearing).+ A snapshot that is still moving after that is used as-is.+ """+ files = _antigravity_summary_files(db)+ for _ in range(3):+ before = tuple(_summary_file_stamp(path) for path in files)+ for src in files:+ dest = tmp_dir / src.name+ if src.is_file():+ shutil.copyfile(src, dest)+ elif dest.exists():+ dest.unlink()+ after = tuple(_summary_file_stamp(path) for path in files)+ if before == after:+ return+ logger.debug(+ "antigravity-cli: conversation summaries changed while copying; using the last copy"+ )++def _antigravity_summaries(home: Path) -> dict[str, _AntigravitySummary]:"""cwd and parent conversation per conversation id, from `conversation_summaries.db`.@@ -1249,10 +1286,7 @@ def _antigravity_summaries(home: Path) -> dict[str, _AntigravitySummary]:try:with tempfile.TemporaryDirectory(prefix="agentplay-antigravity-") as tmp:tmp_dir = Path(tmp)- for suffix in ("", "-wal", "-shm"):- src = db.with_name(db.name + suffix)- if src.is_file():- shutil.copyfile(src, tmp_dir / src.name)+ _copy_antigravity_summaries(db, tmp_dir)conn = sqlite3.connect(f"{(tmp_dir / db.name).as_uri()}?mode=ro", uri=True)try:rows = conn.execute(_ANTIGRAVITY_SUMMARY_SQL).fetchall()@@ -1268,7 +1302,7 @@ def _antigravity_summaries(home: Path) -> dict[str, _AntigravitySummary]:continuetry:uris = json.loads(workspace_uris) if isinstance(workspace_uris, str) else None- except ValueError:+ except (ValueError, RecursionError):uris = Nonecwd = Nonetry:diff --git a/python/tests/core/test_antigravity_parser.py b/python/tests/core/test_antigravity_parser.pyindex 75137e1..e38d1ef 100644--- a/python/tests/core/test_antigravity_parser.py+++ b/python/tests/core/test_antigravity_parser.py@@ -26,6 +26,7 @@ tests build one from the real column schema with made-up rows.from __future__ import annotationsimport json+import loggingimport sqlite3from datetime import UTC, datetimefrom pathlib import Path@@ -33,6 +34,7 @@ from pathlib import Pathimport pytestfrom agentplay import builder, discover+from agentplay._core.ingestion.coding_agent._sources.local import source as local_sourcefrom agentplay._core.ingestion.coding_agent._sources.local.parsers import (AgentType,detect_agent,@@ -179,6 +181,18 @@ def test_read_session_keeps_only_the_prompt_and_the_path():assert spans[0].attributes["llm.model_name"] == ""+def test_session_end_reaches_a_later_tool_completion():+ data = _log(+ _prompt(),+ _planner(_call("read_file", Path="/p/a.py")),+ _result("Created At: 2026-10-23T10:00:02Z\nCompleted At: 2026-10-23T10:05:00Z\nok"),+ )+ trace, spans = parse_antigravity(data, "t")+ end = datetime(2026, 10, 23, 10, 5, tzinfo=UTC)+ assert trace.end_time == end+ assert spans[0].end_time == end++def test_edit_and_run_normalizes_args():read, edit, _, run = _tools(_parse("edit_and_run"))assert set(_args(edit)) == {"file_path", "old_string", "new_string"}@@ -654,6 +668,73 @@ def test_malformed_workspace_uri_skips_that_row_only(tmp_path):assert source.get_spans_by_session(child)[0].attributes["harness.parent_session_id"].endswith(IDS["subagent_parent"])+def test_deeply_nested_workspace_uris_do_not_abort_discovery(tmp_path, monkeypatch):+ nested = '{"a":' * 1200 + "0" + "}" * 1200+ try:+ json.loads(nested)+ except RecursionError:+ pass+ else:+ real_loads = local_source.json.loads++ def loads(raw, *args, **kwargs):+ text = raw if isinstance(raw, str) else bytes(raw).decode("utf-8", "replace")+ if isinstance(text, str) and text.startswith('{"a":' * 40):+ raise RecursionError("maximum recursion depth exceeded")+ return real_loads(raw, *args, **kwargs)++ monkeypatch.setattr(local_source.json, "loads", loads)++ home = _antigravity_home(tmp_path, names=("read_explain", "failed_edit"))+ (home / "conversation_summaries.db").unlink()+ _write_summaries(+ home,+ [+ (IDS["read_explain"], nested, "", 0),+ (IDS["failed_edit"], json.dumps(["file:///Users/dev/project"]), "", 0),+ ],+ )+ source = LocalSource(claude_code_homes=[], codex_homes=[], antigravity_homes=[home])+ index = source._build_index()+ assert len(index) == 2+ bad = f"local:antigravity-cli:{IDS['read_explain']}"+ good = f"local:antigravity-cli:{IDS['failed_edit']}"+ assert source.get_cwd(bad) is None+ assert source.get_cwd(good) == "/Users/dev/project"+++def test_summaries_copy_stops_after_three_changing_snapshots(tmp_path, monkeypatch, caplog):+ home = _antigravity_home(tmp_path, names=("read_explain",))+ db = home / "conversation_summaries.db"+ original = db.read_bytes()+ wal = db.with_name(db.name + "-wal")+ shm = db.with_name(db.name + "-shm")+ wal.write_bytes(b"wal")+ shm.write_bytes(b"shm")+ copies: list[str] = []+ real_copy = local_source.shutil.copyfile++ def copyfile(src, dst, *args, **kwargs):+ real_copy(src, dst, *args, **kwargs)+ name = Path(src).name+ copies.append(name)+ # A writer grows the wal on every copy, so the before/after stamps+ # never match. The scan must stop at three attempts and keep the copy.+ if name == db.name:+ wal.write_bytes(b"wal" + b"x" * copies.count(name))++ monkeypatch.setattr(local_source.shutil, "copyfile", copyfile)+ caplog.set_level(logging.DEBUG, logger=local_source.logger.name)+ source = LocalSource(claude_code_homes=[], codex_homes=[], antigravity_homes=[home])+ source._build_index()+ assert source.get_cwd(f"local:antigravity-cli:{IDS['read_explain']}") == "/Users/dev/project"+ assert copies.count(db.name) == 3+ assert copies.count(wal.name) == 3+ assert copies.count(shm.name) == 3+ assert "using the last copy" in caplog.text+ assert db.read_bytes() == original++def test_missing_or_unusable_summaries_leave_cwd_empty(tmp_path):home = _antigravity_home(tmp_path, names=("read_explain", "failed_edit"))(home / "conversation_summaries.db").unlink()