Skip to content

Fix auth refresh propagation during streaming tool calls#399

Merged
ericdallo merged 1 commit intomasterfrom
fix-auth-propagation-after-tool-calls
Apr 8, 2026
Merged

Fix auth refresh propagation during streaming tool calls#399
ericdallo merged 1 commit intomasterfrom
fix-auth-propagation-after-tool-calls

Conversation

@zikajk
Copy link
Copy Markdown
Member

@zikajk zikajk commented Apr 8, 2026

Auth tokens were captured in provider closures at prompt start. When tokens expired during long-running tool calls like spawn_agent, the renewed credentials in db* weren't propagated back to the recursive streaming calls, causing mid-session auth failures.

on-tools-called! now returns fresh-api-key and provider-auth so providers can use refreshed credentials for subsequent requests. Also renews tokens 60 seconds before expiration to avoid race between check and request.

  • I added a entry in changelog under unreleased section.
  • This is not an AI slop.

Auth tokens were captured in provider closures at prompt start. When tokens
expired during long-running tool calls like spawn_agent, the renewed credentials
in db* weren't propagated back to the recursive streaming calls, causing
mid-session auth failures.

on-tools-called! now returns fresh-api-key and provider-auth so providers can
use refreshed credentials for subsequent requests. Also renews tokens 60
seconds before expiration to avoid race between check and request.
Copy link
Copy Markdown
Member

@ericdallo ericdallo left a comment

Choose a reason for hiding this comment

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

great!

@ericdallo ericdallo merged commit 67ccc01 into master Apr 8, 2026
9 checks passed
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.

2 participants