-
Notifications
You must be signed in to change notification settings - Fork 164
Add retry strategy documentation #455
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
Documentation Deployment CompleteYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-455/ |
|
|
||
| ## Custom Retry Logic | ||
|
|
||
| For more complex retry scenarios—retrying on different exception types, validating responses before accepting them, or implementing custom backoff algorithms—use the hooks system. The `AfterModelCallEvent` provides access to any exception that occurred, and setting `event.retry = True` triggers another attempt: |
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.
nit: AI really likes '-' sentenses, maybe considering rewrite those sentenses.
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.
I'd rather write for humans first, AI 2nd. I'm increasingly feeling that I'm alone in that however.
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.
I should pharse it better, I mean AI generated content has a lot of -, reader will feel AI taste. I am not sure if it's fine or not.
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.
Ah, my apologies; I thought you were advocating for making it more bullet-listy;
Updated to be less listy - and also improved the flow of other places too
| from strands import Agent, ModelRetryStrategy | ||
|
|
||
| agent = Agent( | ||
| retry_strategy=ModelRetryStrategy(max_attempts=1) |
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.
Can't we just do retry_strategy=None?
If we can't we should improve DevX. If we can, we should update docs
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.
Not at the moment; None is the default and if None is passed it uses the default retry strategy.
For improved UX, we'll have to use the same sentinel default value that we do for the callback_handler; I'm expecting that can be done when we have a base RetryStrategy class
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.
Not at the moment; None is the default and if None is passed it uses the default retry strategy.
Did we release this? 😅 we could have just made default into model retry instead of None, right? something like
def __call__(retry_strategy=ModelRetryStrategy(max_attempts=4, ...)):
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.
We can use a sentinel value to detect None, I like the idea of an explicit none disabling retries
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.
(@mkmeral created strands-agents/sdk-python#1579 in response to this)
7910321
Documentation Deployment CompleteYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-455/ |
Description
Add documentation for the RetryStrategy/ModelRetryStrategy.
I think a dedicated page here makes sense because we'll be expanding retries and this serves as a nice place for detailing tool retries in the future, along with how to retry service-unavailable exceptions later on.
Related Issues
Type of Change
Checklist
mkdocs serveBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.