litellm/tests/unit/proxy/engine/test_trace_store.py
moe-berri 6d7d183a80
feat(lens): investigate sampled traces and retain batch results (#43942)
* fix(lens): parallelize scan analysis with bounded concurrency

* feat(lens): investigate sampled activity and preserve scan results

* fix(lens): pin the compatible investigation worker image

* fix(lens): report incomplete reviews and simplify setup validation

* fix(lens): stabilize large investigations and preserve incomplete results

* fix(lens): preserve bounded readers and distinguish counterexamples

* fix(lens): pin compatible worker and verify batched grouping cost

* fix(lens): exclude counterexamples from finding recurrence

* feat(lens): show completed scan duration in results and history

* fix(lens): fold batch selection into results navigation
2026-09-30 22:30:04 -07:00

39 lines
1.7 KiB
Python

import json
from typing import Final
from litellm.proxy.engine.models import Evidence, TracePart
from litellm.proxy.engine.trace_store import trace_store
def test_trace_store_pages_large_payloads_and_recovers_exact_evidence() -> None:
with trace_store() as store:
for index in range(1001):
store.add(
(
TracePart(
execution_id="run",
span_id=f"{index:04}",
parent_span_id="root",
name="tool",
kind="tool",
content="x" * 8000,
),
)
)
assert store.count() == 1001
catalogs: Final = tuple(store.catalogs(1))
assert len(catalogs) > 1
assert all(len(json.dumps(page)) < 25000 for page in catalogs)
assert sum(len(page) for page in catalogs) == 1001
assert store.previous("1000") == "0999"
assert store.previous("0000") == ""
assert store.get("missing") is None
original: Final = store.get("1000")
assert original is not None and original.content == "x" * 8000
later: Final = TracePart(
execution_id="run", span_id="1000", name="tool", kind="tool", content="verified failure"
)
store.add_reads((later,))
assert store.evidence(Evidence(execution_id="run", span_id="1000", quote="verified failure")) == later
assert store.evidence(Evidence(execution_id="other", span_id="1000", quote="verified failure")) is None
assert store.evidence(Evidence(execution_id="run", span_id="1000", quote="fabricated")) is None