diff --git a/model_tools.py b/model_tools.py index a4ed0c20c5..dda40405b7 100644 --- a/model_tools.py +++ b/model_tools.py @@ -704,7 +704,11 @@ _TOOL_ERROR_ROLE_TAG_RE = re.compile( _TOOL_ERROR_FENCE_OPEN_RE = re.compile(r'^\s*```(?:json|xml|html|markdown)?\s*', re.MULTILINE) _TOOL_ERROR_FENCE_CLOSE_RE = re.compile(r'\s*```\s*$', re.MULTILINE) _TOOL_ERROR_CDATA_RE = re.compile(r'', re.DOTALL) -_TOOL_ERROR_MAX_LEN = 2000 +# Single home for the tool-error context cap: tools/registry.py. Both this +# sanitizer (exception paths) and the dispatch-boundary bounding +# (tool_error / _bound_json_error_result) trim to the same budget so text +# never passes two different caps with two different markers. +from tools.registry import _MAX_TOOL_ERROR_CHARS as _TOOL_ERROR_MAX_LEN def _sanitize_tool_error(error_msg: str) -> str: