@@ -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 ("/" )
0 commit comments