fix: Prevent double using_auto_reply events when using async run#2276
Merged
priyansh4320 merged 6 commits intomainfrom Jan 30, 2026
Merged
fix: Prevent double using_auto_reply events when using async run#2276priyansh4320 merged 6 commits intomainfrom
run#2276priyansh4320 merged 6 commits intomainfrom
Conversation
runrun
Contributor
Collaborator
priyansh4320
left a comment
There was a problem hiding this comment.
thanks @marklysze reviewed and tested approving this PR, also added a couple integration tests.
priyansh4320
approved these changes
Jan 30, 2026
Codecov Report❌ Patch coverage is
... and 111 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
Why are these changes needed?
When running chats asynchronously (via
.a_run), theusing_auto_replyevent was being emitted twice per speaker turn.This occurred because
a_generate_replyiterates through all registered reply functions and calls both sync and async versions. Sincecheck_termination_and_human_reply(sync) anda_check_termination_and_human_reply(async) are both registered, both were being executed and each emitted theUsingAutoReplyEventand incrementing_consecutive_auto_reply_counter.The sync
generate_replymethod correctly skips async functions, but the asynca_generate_replywas not skipping sync functions that have async equivalents.This fix adds a utility method
_get_sync_funcs_to_skip_in_async_chatthat identifies sync functions with async counterparts (by detecting async functions registered withignore_async_in_sync_chat=Trueand matching them to their sync equivalents via the 'a_' naming convention). Thea_generate_replymethod now skips these sync functions, ensuring only the async version is called. This eliminates duplicate events and prevents double-incrementing of the auto-reply counter.Related issue number
N/A
Checks