Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agents_sdk_user_agent_override()only reset the Agents SDK header overrides after a normal exit. If the body raised or was cancelled, later work in the same context kept ChatKit'sUser-Agentoverride instead of the headers the caller had set before.Both resets now run in
finally, so the previous values are restored and the original exception still propagates.One case can't be handled from inside the helper. If a suspended stream generator is finalized in a different context, for example by the event loop after the stream is abandoned, the tokens can't be reset there. The helper tolerates that
ValueErrorso cleanup doesn't raise a new exception. That path behaves as it did before this change: the values in the originating context are not restored.Normal completion is unchanged, and there are no public API changes.
Test plan
respond()fails.ValueErrorguard, the 2 cross-context close cases fail.make lint,make pyright, andmake testpass; the full suite has 145 passing tests.make format-checkstill reports the same four existing files as the unmodified base. The added test file passes formatting; unrelated files were left unchanged.Validation used Python 3.14.4 and the locked dependencies, without model API requests.