Skip to content

chore: moved truncation logic to conversation manager and added should_truncate_results #192

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

Conversation

poshinchen
Copy link
Contributor

@poshinchen poshinchen commented Jun 9, 2025

Description

  1. Moved the truncation logic conversation manager.
  2. Allow users to disable truncating the tool result with should_truncate_results flag (Default: True).

The behavior of the reduce_context will be:

  1. When ContextWindowOverflowException is first thrown, if should_truncate_results is not explicitly set to False, the tool result will get truncated first and execute the event loop again.
  2. When ContextWindowOverflowException is thrown again after the truncation, the message history starts to get reduced
  3. Successfully execute the event loop / throw ContextWindowOverflowException if nothing can be reduced by conversation manager

Related Issues

#152
#167

Documentation PR

Will update the documentation as follow up.

Type of Change

  • Bug fix

Testing

[How have you tested the change?]

  • hatch fmt --linter
  • hatch fmt --formatter
  • hatch test --all
  • Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

Checklist

  • I have read the CONTRIBUTING document
  • I have added tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature
  • My changes generate no new warnings
  • [NA] Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@poshinchen poshinchen force-pushed the chore/update-truncation-logic branch from b02c6ac to c5ab63d Compare June 9, 2025 19:55
@poshinchen poshinchen force-pushed the chore/update-truncation-logic branch from c5ab63d to d31ab39 Compare June 9, 2025 19:56
@poshinchen poshinchen requested review from Unshure and zastrowm June 9, 2025 19:56
@poshinchen poshinchen self-assigned this Jun 9, 2025
@poshinchen poshinchen marked this pull request as ready for review June 9, 2025 19:58
@poshinchen poshinchen merged commit 7c7f91e into strands-agents:main Jun 11, 2025
19 of 40 checks passed
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