Skip to content

Conversation

@yyfamazon
Copy link

@yyfamazon yyfamazon commented Nov 3, 2025

Description

Enforce size limit for SearchIndexTool.
PER agent rely on LLM to generate DSL then call SearchIndexTool to execute the DSL. There is no size limit enforced by SearchIndexTool, if LLM generate a DSL that returns 1000 or even more data, SearchIndexTool will do so and when the result sending back to agent as context, it will fail due to Input is too long for requested model error. We need to add a size limit for SearchIndexTool to return at most 100? records no matter what's the size value is set by LLM.

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.


if (StringUtils.isNotEmpty(parameters.get(SIZE_FIELD))) {
try {
size = Math.min(size == null ? 100 : size, Integer.parseInt(parameters.get(SIZE_FIELD)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size here is also generated by LLM, right? Only when LLM doesn't generate anything we will use the default size 100 in PER agent.

@xinyual
Copy link
Collaborator

xinyual commented Nov 3, 2025

Please apply spotless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants