Skip to content

Commit 8ff6de9

Browse files
authored
Fix UpdatedVariable truncation crash (langgenius#27359)
Signed-off-by: -LAN- <laipz8200@outlook.com>
1 parent 7fa0ad3 commit 8ff6de9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎api/services/variable_truncator.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def _truncate_array(self, value: list[object], target_size: int) -> _PartResult[
283283
break
284284

285285
remaining_budget = target_size - used_size
286-
if item is None or isinstance(item, (str, list, dict, bool, int, float)):
286+
if item is None or isinstance(item, (str, list, dict, bool, int, float, UpdatedVariable)):
287287
part_result = self._truncate_json_primitives(item, remaining_budget)
288288
else:
289289
raise UnknownTypeError(f"got unknown type {type(item)} in array truncation")
@@ -373,6 +373,11 @@ def _truncate_object(self, mapping: Mapping[str, Any], target_size: int) -> _Par
373373

374374
return _PartResult(truncated_obj, used_size, truncated)
375375

376+
@overload
377+
def _truncate_json_primitives(
378+
self, val: UpdatedVariable, target_size: int
379+
) -> _PartResult[Mapping[str, object]]: ...
380+
376381
@overload
377382
def _truncate_json_primitives(self, val: str, target_size: int) -> _PartResult[str]: ...
378383

0 commit comments

Comments
 (0)