Skip to content

Commit 3e231bf

Browse files
authored
fix(drivers-prompt-griptape-cloud): set very high max_input_tokens to avoid client-side input truncation (#2066)
1 parent 073ad9e commit 3e231bf

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

griptape/drivers/prompt/griptape_cloud_prompt_driver.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ class GriptapeCloudPromptDriver(BasePromptDriver):
3838
default=Factory(
3939
lambda self: SimpleTokenizer(
4040
characters_per_token=4,
41-
max_input_tokens=2000,
41+
# Set very high to prevent client-side truncation. The Griptape Cloud backend
42+
# selects the actual model and enforces its real token limits. This SimpleTokenizer
43+
# is only used for client-side estimation and shouldn't prematurely prune context.
44+
max_input_tokens=500000,
4245
max_output_tokens=self.max_tokens,
4346
),
4447
takes_self=True,

tests/unit/drivers/prompt/test_griptape_cloud_prompt_driver.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,3 +513,14 @@ def request(*args, **kwargs):
513513
},
514514
stream=True,
515515
)
516+
517+
def test_tokenizer_max_input_tokens(self):
518+
"""Test that tokenizer has high max_input_tokens to prevent client-side truncation.
519+
520+
The GriptapeCloudPromptDriver uses a SimpleTokenizer with max_input_tokens=500000
521+
to prevent premature pruning of conversation context. The actual model token limits
522+
are enforced by the Griptape Cloud backend.
523+
"""
524+
driver = GriptapeCloudPromptDriver(api_key="foo")
525+
526+
assert driver.tokenizer.max_input_tokens == 500000

0 commit comments

Comments
 (0)