Skip to content

Commit 4addc27

Browse files
committed
fix to seq number
1 parent f2ea9b9 commit 4addc27

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

sentience/cloud_tracing.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ def _generate_index(self) -> None:
270270
try:
271271
from .trace_indexing import write_trace_index
272272

273-
write_trace_index(str(self._path))
273+
# Use frontend format to ensure 'step' field is present (1-based)
274+
# Frontend derives sequence from step.step - 1, so step must be valid
275+
index_path = Path(str(self._path).replace(".jsonl", ".index.json"))
276+
write_trace_index(str(self._path), str(index_path), frontend_format=True)
274277
except Exception as e:
275278
# Non-fatal: log but don't crash
276279
print(f"⚠️ Failed to generate trace index: {e}")
@@ -323,14 +326,15 @@ def _upload_index(self) -> None:
323326
return
324327

325328
# Read index file and update trace_file.path to cloud storage path
326-
with open(index_path, "r", encoding="utf-8") as f:
329+
with open(index_path, encoding="utf-8") as f:
327330
index_json = json.load(f)
328331

329332
# Extract cloud storage path from trace upload URL
330333
# upload_url format: https://...digitaloceanspaces.com/traces/{run_id}.jsonl.gz
331334
# Extract path: traces/{run_id}.jsonl.gz
332335
try:
333336
from urllib.parse import urlparse
337+
334338
parsed_url = urlparse(self.upload_url)
335339
# Extract path after domain (e.g., /traces/run-123.jsonl.gz -> traces/run-123.jsonl.gz)
336340
cloud_trace_path = parsed_url.path.lstrip("/")

sentience/trace_indexing/indexer.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,17 @@ def _compute_snapshot_digest(snapshot_data: dict[str, Any]) -> str:
6060
for elem in elements:
6161
# Extract is_primary and is_clickable from visual_cues if present
6262
visual_cues = elem.get("visual_cues", {})
63-
is_primary = visual_cues.get("is_primary", False) if isinstance(visual_cues, dict) else elem.get("is_primary", False)
64-
is_clickable = visual_cues.get("is_clickable", False) if isinstance(visual_cues, dict) else elem.get("is_clickable", False)
65-
63+
is_primary = (
64+
visual_cues.get("is_primary", False)
65+
if isinstance(visual_cues, dict)
66+
else elem.get("is_primary", False)
67+
)
68+
is_clickable = (
69+
visual_cues.get("is_clickable", False)
70+
if isinstance(visual_cues, dict)
71+
else elem.get("is_clickable", False)
72+
)
73+
6674
canonical_elem = {
6775
"id": elem.get("id"),
6876
"role": elem.get("role", ""),

0 commit comments

Comments
 (0)