sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

[BUG] Tool response truncation occurs silently

Open prestomation opened this issue 1 year ago • 4 comments

Problem Statement

Turns out some of my research tools have been unusable for my agent and I had no idea. I didn't discover this until I started dumping agent.messages to disk for review and noticed The tool result was too large! in replace of the tool response. Examining the code, it's not clear that even if I did enable debug logging that this behavior would be obvious to me during development. Even if it was, there is no mechanism today to handle this situation dynamically at runtime

Proposed Solution

I don't have a solution in mind but wanted to start with this issue for conversation

Use Case

I have research tools that browse the internet/read documentation pages/etc. The content is dynamic and not something I control and could be a large amount of content

Alternatives Solutions

As a workaround I can add pagination to my tool or use an llm to summarize the content.

Additional Context

No response

prestomation avatar Jun 03 '25 04:06 prestomation

This is currently being done here: https://github.com/strands-agents/sdk-python/blob/8ffe24b44b90c015282845876c219b5b375baef7/src/strands/event_loop/message_processor.py#L159

We think this should be:

zastrowm avatar Jun 05 '25 18:06 zastrowm

Hi @prestomation , wanted to point you toward this issue: https://github.com/strands-agents/sdk-python/issues/152#issuecomment-2945637950

There was an infinite loop bug found in the implementation of the toolResult truncation logic. As a part of that fix, we plan to move this to the context manager and make it configurable!

Unshure avatar Jun 06 '25 19:06 Unshure

Change has been merged, user will be able to use should_truncate_results=False to disable truncating the tool result in the next PyPI release.

poshinchen avatar Jun 13 '25 14:06 poshinchen

@prestomation please let us know if this issue persists, our latest release should have the appropriate changes.

jer96 avatar Jul 22 '25 18:07 jer96