From 5aab51edf4c72afabf8c47aeae2f7b54a98d51c3 Mon Sep 17 00:00:00 2001 From: Richard Guan Date: Fri, 19 Sep 2025 10:59:06 -0700 Subject: [PATCH 1/4] . --- backend/onyx/evals/tracing.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/backend/onyx/evals/tracing.py b/backend/onyx/evals/tracing.py index 26ac25f93e9..3f53cd48a22 100644 --- a/backend/onyx/evals/tracing.py +++ b/backend/onyx/evals/tracing.py @@ -7,18 +7,24 @@ from onyx.configs.app_configs import BRAINTRUST_API_KEY from onyx.configs.app_configs import BRAINTRUST_PROJECT +MASKING_LENGTH = 20000 -def _truncate_str(s: str, head: int = 800, tail: int = 200) -> str: - if len(s) <= head + tail: - return s - return f"{s[:head]}…{s[-tail:]}[TRUNCATED {len(s)} chars to 10,000]" + +def _truncate_str(s: str) -> str: + tail = MASKING_LENGTH // 5 + head = MASKING_LENGTH - tail + return f"{s[:head]}…{s[-tail:]}[TRUNCATED {len(s)} chars to {MASKING_LENGTH}]" + + +def _should_mask(data: Any) -> bool: + return len(str(data)) > MASKING_LENGTH def _mask(data: Any) -> Any: - data_str = str(data) - if len(data_str) > 10_000: - return _truncate_str(data_str) - return data + """Mask data based on span type. Only mask generic and function spans, not root, task, score, or LLM spans.""" + if not _should_mask(data): + return data + return _truncate_str(str(data)) def setup_braintrust() -> None: From 09381a4c487373917c216b4d54ca2fb1039a0812 Mon Sep 17 00:00:00 2001 From: Richard Guan <41275416+rguan72@users.noreply.github.com> Date: Fri, 19 Sep 2025 11:01:08 -0700 Subject: [PATCH 2/4] Update backend/onyx/evals/tracing.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- backend/onyx/evals/tracing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/onyx/evals/tracing.py b/backend/onyx/evals/tracing.py index 3f53cd48a22..780ccedbd19 100644 --- a/backend/onyx/evals/tracing.py +++ b/backend/onyx/evals/tracing.py @@ -21,7 +21,7 @@ def _should_mask(data: Any) -> bool: def _mask(data: Any) -> Any: - """Mask data based on span type. Only mask generic and function spans, not root, task, score, or LLM spans.""" + """Mask data if it exceeds the maximum length threshold.""" if not _should_mask(data): return data return _truncate_str(str(data)) From 72a1b4981ff3d630de39cdd5a2eaca1dbece0fba Mon Sep 17 00:00:00 2001 From: Richard Guan Date: Fri, 19 Sep 2025 13:01:08 -0700 Subject: [PATCH 3/4] . --- backend/onyx/evals/tracing.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/backend/onyx/evals/tracing.py b/backend/onyx/evals/tracing.py index 780ccedbd19..e41a80a8b0b 100644 --- a/backend/onyx/evals/tracing.py +++ b/backend/onyx/evals/tracing.py @@ -16,13 +16,9 @@ def _truncate_str(s: str) -> str: return f"{s[:head]}…{s[-tail:]}[TRUNCATED {len(s)} chars to {MASKING_LENGTH}]" -def _should_mask(data: Any) -> bool: - return len(str(data)) > MASKING_LENGTH - - def _mask(data: Any) -> Any: """Mask data if it exceeds the maximum length threshold.""" - if not _should_mask(data): + if not len(str(data)) <= MASKING_LENGTH: return data return _truncate_str(str(data)) From cfc10f5fdbbcb888e601dfecbb66f3efa6b8932e Mon Sep 17 00:00:00 2001 From: Richard Guan Date: Fri, 19 Sep 2025 13:01:23 -0700 Subject: [PATCH 4/4] . --- backend/onyx/evals/tracing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/onyx/evals/tracing.py b/backend/onyx/evals/tracing.py index e41a80a8b0b..1df631e6a2f 100644 --- a/backend/onyx/evals/tracing.py +++ b/backend/onyx/evals/tracing.py @@ -18,7 +18,7 @@ def _truncate_str(s: str) -> str: def _mask(data: Any) -> Any: """Mask data if it exceeds the maximum length threshold.""" - if not len(str(data)) <= MASKING_LENGTH: + if len(str(data)) <= MASKING_LENGTH: return data return _truncate_str(str(data))