Skip to content

Conversation

@zastrowm
Copy link
Member

@zastrowm zastrowm commented Jan 21, 2026

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

  • New content

Checklist

  • I have read the CONTRIBUTING document
  • My changes follow the project's documentation style
  • I have tested the documentation locally using mkdocs serve
  • Links in the documentation are valid and working

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

@strands-agent
Copy link
Contributor

Documentation Deployment Complete

Your documentation preview has been successfully deployed!

Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-455/

@zastrowm zastrowm marked this pull request as ready for review January 28, 2026 16:07

## 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:
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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)
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

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, ...)): 

Copy link
Member

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

Copy link
Member Author

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)

dbschmigelski
dbschmigelski previously approved these changes Jan 28, 2026
Unshure
Unshure previously approved these changes Jan 28, 2026
JackYPCOnline
JackYPCOnline previously approved these changes Jan 28, 2026
@strands-agent
Copy link
Contributor

Documentation Deployment Complete

Your documentation preview has been successfully deployed!

Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-455/

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.

6 participants