From 6fa1a1d6c39fff25f2e26dbb9f55465a11509993 Mon Sep 17 00:00:00 2001 From: Kian Jones <11655409+kianjones9@users.noreply.github.com> Date: Tue, 4 Nov 2025 13:43:19 -0800 Subject: [PATCH] make sure tool return chars within max int range (#5942) * max * final * Set return_char_limit maximum to 1 million in OpenAPI spec (#5946) * Initial plan * Set max int range to 1 million for return_char_limit Co-authored-by: kianjones9 <11655409+kianjones9@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kianjones9 <11655409+kianjones9@users.noreply.github.com> * Update tool.py * fix api --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> --- fern/openapi.json | 10 +++++++++- letta/schemas/tool.py | 21 ++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/fern/openapi.json b/fern/openapi.json index 0f6ea0a1..35737640 100644 --- a/fern/openapi.json +++ b/fern/openapi.json @@ -33008,6 +33008,8 @@ }, "return_char_limit": { "type": "integer", + "maximum": 1000000, + "minimum": 1, "title": "Return Char Limit", "description": "The maximum number of characters in the response.", "default": 50000 @@ -33497,6 +33499,8 @@ }, "return_char_limit": { "type": "integer", + "maximum": 1000000, + "minimum": 1, "title": "Return Char Limit", "description": "The maximum number of characters in the response.", "default": 50000 @@ -34111,7 +34115,9 @@ "return_char_limit": { "anyOf": [ { - "type": "integer" + "type": "integer", + "maximum": 1000000, + "minimum": 1 }, { "type": "null" @@ -36191,6 +36197,8 @@ }, "return_char_limit": { "type": "integer", + "maximum": 1000000, + "minimum": 1, "title": "Return Char Limit", "description": "The maximum number of characters in the response.", "default": 50000 diff --git a/letta/schemas/tool.py b/letta/schemas/tool.py index fcaa8d33..4c21bb33 100644 --- a/letta/schemas/tool.py +++ b/letta/schemas/tool.py @@ -58,7 +58,12 @@ class Tool(BaseTool): args_json_schema: Optional[Dict] = Field(None, description="The args JSON schema of the function.") # tool configuration - return_char_limit: int = Field(FUNCTION_RETURN_CHAR_LIMIT, description="The maximum number of characters in the response.") + return_char_limit: int = Field( + FUNCTION_RETURN_CHAR_LIMIT, + description="The maximum number of characters in the response.", + ge=1, + le=1_000_000, + ) pip_requirements: list[PipRequirement] | None = Field(None, description="Optional list of pip packages required by this tool.") npm_requirements: list[NpmRequirement] | None = Field(None, description="Optional list of npm packages required by this tool.") default_requires_approval: Optional[bool] = Field( @@ -118,7 +123,12 @@ class ToolCreate(LettaBase): None, description="The JSON schema of the function (auto-generated from source_code if not provided)" ) args_json_schema: Optional[Dict] = Field(None, description="The args JSON schema of the function.") - return_char_limit: int = Field(FUNCTION_RETURN_CHAR_LIMIT, description="The maximum number of characters in the response.") + return_char_limit: int = Field( + FUNCTION_RETURN_CHAR_LIMIT, + description="The maximum number of characters in the response.", + ge=1, + le=1_000_000, + ) pip_requirements: list[PipRequirement] | None = Field(None, description="Optional list of pip packages required by this tool.") npm_requirements: list[NpmRequirement] | None = Field(None, description="Optional list of npm packages required by this tool.") default_requires_approval: Optional[bool] = Field(None, description="Whether or not to require approval before executing this tool.") @@ -175,7 +185,12 @@ class ToolUpdate(LettaBase): None, description="The JSON schema of the function (auto-generated from source_code if not provided)" ) args_json_schema: Optional[Dict] = Field(None, description="The args JSON schema of the function.") - return_char_limit: Optional[int] = Field(None, description="The maximum number of characters in the response.") + return_char_limit: Optional[int] = Field( + None, + description="The maximum number of characters in the response.", + ge=1, + le=1_000_000, + ) pip_requirements: list[PipRequirement] | None = Field(None, description="Optional list of pip packages required by this tool.") npm_requirements: list[NpmRequirement] | None = Field(None, description="Optional list of npm packages required by this tool.") metadata_: Optional[Dict[str, Any]] = Field(None, description="A dictionary of additional metadata for the tool.")