Skip to content

Use 'stamina' for retries#255

Merged
bmerkle merged 6 commits intomicrosoft:mainfrom
gvanrossum:stamina
Apr 29, 2026
Merged

Use 'stamina' for retries#255
bmerkle merged 6 commits intomicrosoft:mainfrom
gvanrossum:stamina

Conversation

@gvanrossum-ms
Copy link
Copy Markdown
Contributor

Disable the older max_retries options for pydantic_ai; instead, wrap complete() and get_embedding[s]_nocache() in @stamina(...) decorators.

@gvanrossum-ms
Copy link
Copy Markdown
Contributor Author

gvanrossum-ms commented Apr 27, 2026

@KRRT7 Have a look. This uses stamina in the two essential places. Maybe we need a way to be able to configure the stamina call parameters? Or other stamina features?

UPDATE: You can now configure it via ConversationSettings.

Copy link
Copy Markdown
Contributor

@KRRT7 KRRT7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retriers are bound to openai.APIError, which is the base class for all OpenAI errors — including AuthenticationError, BadRequestError, NotFoundError, PermissionDeniedError. Those will never succeed on retry.

Should target transient errors only, something like (openai.RateLimitError, openai.APIConnectionError, openai.APITimeoutError, openai.InternalServerError).

Comment thread src/typeagent/aitools/model_adapters.py Outdated
Comment thread src/typeagent/aitools/model_adapters.py
gvanrossum and others added 2 commits April 28, 2026 19:14
Co-authored-by: Kevin Turcios <106575910+KRRT7@users.noreply.github.com>
@gvanrossum
Copy link
Copy Markdown
Collaborator

@bmerkle This needs your Approval so we can merge it.

Copy link
Copy Markdown
Collaborator

@bmerkle bmerkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

@bmerkle bmerkle merged commit 7157671 into microsoft:main Apr 29, 2026
16 checks passed
@gvanrossum
Copy link
Copy Markdown
Collaborator

@bmerkle Thanks!

@bmerkle
Copy link
Copy Markdown
Collaborator

bmerkle commented Apr 29, 2026

strange, there were still format and import errors on main, so i now created #262

@gvanrossum
Copy link
Copy Markdown
Collaborator

Strange indeed. I am guessing we're (once again) running different versions of isort and/or black?

I have these:

black, 26.3.1 (compiled: yes)
isort 8.0.1

@gvanrossum gvanrossum deleted the stamina branch April 29, 2026 21:13
@bmerkle
Copy link
Copy Markdown
Collaborator

bmerkle commented Apr 29, 2026

hm, next time i will run local build again (as usual) just to be sure. I was in rush and just trusted the review you both did.

but out of some feeling i did it later on main and there was also this type error...
image

I have the same versions, at least on main

 typeagent-py  git switch -c fix-format-etc
Switched to a new branch 'fix-format-etc'
 typeagent-py  black --version
black, 26.3.1 (compiled: yes)
Python (CPython) 3.13.5
 typeagent-py  isort --version

                 _                 _
                (_) ___  ___  _ __| |_
                | |/ _/ / _ \/ '__  _/
                | |\__ \/\_\/| |  | |_
                |_|\___/\___/\_/   \_/

      isort your imports, so you don't have to.

                    VERSION 8.0.1

@gvanrossum
Copy link
Copy Markdown
Collaborator

I can repeat everything you see on Windows. But after merging your most recent PR #262 all is clean.

There may be an explanation but I'd rather not spend more time investigating.

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.

4 participants