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>
This commit is contained in:
Kian Jones
2025-11-04 13:43:19 -08:00
committed by Caren Thomas
parent aedddcb1d1
commit 6fa1a1d6c3
2 changed files with 27 additions and 4 deletions

View File

@@ -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

View File

@@ -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.")