Skip to content

fix: validate tool output content size #1111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged

Conversation

ctlai95
Copy link
Contributor

@ctlai95 ctlai95 commented Apr 24, 2025

Problem

Service is sometimes throwing ValidationException with reason CONTENT_LENGTH_EXCEEDS_THRESHOLD if content becomes too large.

Solution

Validate the tool output to ensure the results are not too large

Previous implementation: https://github.com/aws/aws-toolkit-vscode/blob/feature/agentic-chat/packages/core/src/codewhispererChat/tools/toolUtils.ts#L75-L90

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ctlai95 ctlai95 requested a review from a team as a code owner April 24, 2025 05:50
let maxToolResponseSize
switch (toolUse.name) {
case 'fsRead':
maxToolResponseSize = 200_000
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should we store these as constants somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should but not sure where, maybe in runtimes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly. I haven't really looked into that package to be honest. Maybe we can just add it to the constants file here or create one for agenticChat: https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/src/language-server/chat/constants.ts

@ctlai95 ctlai95 merged commit e22fd16 into aws:main Apr 24, 2025
6 checks passed
@ctlai95 ctlai95 deleted the validate-output branch April 24, 2025 06:01
@ege0zcan
Copy link
Contributor

Does it makes sense to use partial results of a long output by truncating the long output? In the current case we fail the validation and the tool result doesn't get added to the message.

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.

3 participants