-
Notifications
You must be signed in to change notification settings - Fork 120
RecursionError + "input length and max_tokens exceed context limit #164
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
base: main
Are you sure you want to change the base?
Conversation
This fix solved the following issue: #152 But when I ran a benchmark, I saw another exception in the logs:
I wonder why we are not calling the reduce_context when the context limit exception happens in the event loop? |
if recursion_depth >= 2: | ||
# Remove older messages if there are more than a few | ||
if len(messages) > 4: | ||
# Keep the first message (usually system) and the last 3 messages | ||
preserved_messages = [messages[0]] + messages[-3:] | ||
messages.clear() | ||
messages.extend(preserved_messages) | ||
logger.debug("Aggressively truncated conversation history to %s messages", len(messages)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gargshilpi22, Thanks for raising potential fix PR. I am just ramping up on strands sdk (not part of strands team) hence few followup questions:
- could aggressive truncation mean losing more conversation context hence could lead to inaccurate result?
- should we make last N messages truncation configurable by users (similar to
window_size
in SlidingWindowConversationManager)? Also, should we bring this logic out oferror_handler
?
Hi @gargshilpi22, I wanted to point you to the logic in our The |
Hi @Unshure , I think |
#152
Description
[Provide a detailed description of the changes in this PR]
Related Issues
[Link to related issues using #issue-number format]
Documentation PR
[Link to related associated PR in the agent-docs repo]
Type of Change
[Choose one of the above types of changes]
Testing
[How have you tested the change?]
hatch fmt --linter
hatch fmt --formatter
hatch test --all
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.