refactor(tools): unify the tool-error cap on one constant
model_tools._TOOL_ERROR_MAX_LEN (2000, '...' marker) and the new registry._MAX_TOOL_ERROR_CHARS (2048, '… [truncated]' marker) were two caps for the same budget; text on the dispatch exception path passed both. Alias the sanitizer's cap to the registry constant so the tool-error budget lives in one home. model_tools already imports from tools.registry at module level, so no import-cycle risk.
This commit is contained in:
@@ -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'<!\[CDATA\[.*?\]\]>', 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:
|
||||
|
||||
Reference in New Issue
Block a user