Skip to content

Commit c30a731

Browse files
committed
perf(redaction): cache _internal_roots() to avoid recomputation per call
_internal_roots resolves 8 candidate paths + builds 3 separator variants + sorts on every redact_internal_paths call. On the worker hot path this runs once per task error / event / file-tool failure. Result is process- stable (paths don't change without a restart), so @cache it. Follow-up to #119.
1 parent 0a254c0 commit c30a731

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

agent/src/tools/redaction.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
import sys
1313
import sysconfig
14+
from functools import cache
1415
from pathlib import Path
1516

1617
_SENTINEL = "<redacted>"
1718

1819

20+
@cache
1921
def _internal_roots() -> list[str]:
2022
# AGENT_DIR derived like agent/src/providers/llm.py:90
2123
# (Path(__file__).resolve().parents[2]); redaction.py is agent/src/tools/

0 commit comments

Comments
 (0)