Skip to content

Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.

fix(trajectory): read JSONL captures containing Unicode line separators (#326)

Rudy Mizrahi Celekli5cf626bb00ab
diff --git a/ifixai/tests/trajectory/test_import_replay_cli.py b/ifixai/tests/trajectory/test_import_replay_cli.py
index 8f6c29a..80215b8 100644
--- a/ifixai/tests/trajectory/test_import_replay_cli.py
+++ b/ifixai/tests/trajectory/test_import_replay_cli.py
@@ -37,6 +37,17 @@ def test_jsonl_and_explicit_otlp_export_preserve_semantic_audit(native_example,
assert store.calls == 2 and store.refunded_units == 120
[email protected]("separator", ["\u2028", "\u2029", "\x85"])
+def test_jsonl_export_round_trips_unicode_line_separators(separator, tmp_path):
+ from ifixai.trajectory.recorder import TraceRecorder
+
+ trace = TraceRecorder("tenant", "collector", label=f"line one{separator}line two", clock_ns=lambda: 10)
+ capture = trace.write_jsonl(tmp_path / "trace.jsonl")
+ imported = load_jsonl_capture(tmp_path / "trace.jsonl")
+ assert imported.events == capture.events
+ assert imported.events[0].payload.label == f"line one{separator}line two"
+
+
@pytest.mark.parametrize("change", [
lambda d: d["resourceSpans"][0]["scopeSpans"][0]["spans"][1].update(droppedEventsCount=1),
lambda d: d["resourceSpans"][0]["scopeSpans"][0]["spans"][1].update(droppedLinksCount=1),
diff --git a/ifixai/trajectory/importers.py b/ifixai/trajectory/importers.py
index 13e64b4..a298c95 100644
--- a/ifixai/trajectory/importers.py
+++ b/ifixai/trajectory/importers.py
@@ -49,7 +49,8 @@ class CaptureHeader(StrictModel):
def load_jsonl_capture(path: str | Path) -> TraceCapture:
- lines = [line for line in read_input(path).splitlines() if line.strip()]
+ # JSON strings may contain raw U+2028, U+2029 and U+0085; only newline separates rows.
+ lines = [line for line in read_input(path).split("\n") if line.strip()]
if not lines or len(lines) > MAX_EVENTS + 1:
raise ValueError("JSONL requires a header and at most 100000 events")
header = CaptureHeader.model_validate(strict_json(lines[0]))