diff --git a/letta/otel/tracing.py b/letta/otel/tracing.py index a646acd6..cae7850d 100644 --- a/letta/otel/tracing.py +++ b/letta/otel/tracing.py @@ -250,22 +250,25 @@ def trace_method(func): "chunks", # Large chunk arrays } - # Max size for parameter value strings (1KB) - MAX_PARAM_SIZE = 1024 - # Max total size for all parameters (100KB) - MAX_TOTAL_SIZE = 1024 * 100 + # Priority parameters that should ALWAYS be logged (exempt from opt-out) + NEVER_SKIP_PARAMS = {"request_data"} + + # Max size for parameter value strings + MAX_PARAM_SIZE = 1024 * 1024 * 2 # 2MB (supports ~500k tokens) + # Max total size for all parameters + MAX_TOTAL_SIZE = 1024 * 1024 * 4 # 4MB total_size = 0 for name, value in param_items: try: - # Check if we've exceeded total size limit - if total_size > MAX_TOTAL_SIZE: + # Check if we've exceeded total size limit (except for priority params) + if total_size > MAX_TOTAL_SIZE and name not in NEVER_SKIP_PARAMS: span.set_attribute("parameters.truncated", True) span.set_attribute("parameters.truncated_reason", f"Total size exceeded {MAX_TOTAL_SIZE} bytes") break - # Skip parameters known to be large - if name in SKIP_PARAMS: + # Skip parameters known to be large (opt-out list, but respect ALWAYS_LOG) + if name in SKIP_PARAMS and name not in NEVER_SKIP_PARAMS: # Try to extract ID for observability type_name = type(value).__name__ id_info = ""