Skip to content

fix(adk): keep token refresh loop alive after a failed read#2330

Open
mesutoezdil wants to merge 2 commits into
kagent-dev:mainfrom
mesutoezdil:fix/token-refresh-loop-resilience
Open

fix(adk): keep token refresh loop alive after a failed read#2330
mesutoezdil wants to merge 2 commits into
kagent-dev:mainfrom
mesutoezdil:fix/token-refresh-loop-resilience

Conversation

@mesutoezdil

Copy link
Copy Markdown
Contributor

_refresh_token only handled a token read returning None. Any other exception from the read (anything other than the OSError already handled inside read_token) escaped the while loop and killed the background refresh task for the rest of the process, no restart, no backoff. The token would never refresh again after that, easy to miss since the task is never awaited elsewhere.

Now a failed read is logged and the loop keeps going on its next 60s cycle instead of dying.

Added a test that fails the first read, then succeeds on the second, and checks the loop is still alive and the token still updates. Confirmed it fails against the old code (loop dies on the first exception) and passes with the fix.

_refresh_token only handled a token read returning None. Any other
exception from the read (not just the OSError already handled inside
read_token) escaped the while loop and killed the background task for
the rest of the process, with no restart. The token would never
refresh again after that.

Now a failed read is logged and the loop keeps going on its next
60s cycle.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
@mesutoezdil
mesutoezdil requested a review from a team as a code owner July 25, 2026 10:24
@github-actions github-actions Bot added the bug Something isn't working label Jul 25, 2026
…p-resilience

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant