Skip to content

Conversation

@marklysze
Copy link
Collaborator

@marklysze marklysze commented Dec 21, 2025

Why are these changes needed?

When running chats asynchronously (via .a_run), the using_auto_reply event was being emitted twice per speaker turn.

This occurred because a_generate_reply iterates through all registered reply functions and calls both sync and async versions. Since check_termination_and_human_reply (sync) and a_check_termination_and_human_reply (async) are both registered, both were being executed and each emitted the UsingAutoReplyEvent and incrementing _consecutive_auto_reply_counter.

The sync generate_reply method correctly skips async functions, but the async a_generate_reply was not skipping sync functions that have async equivalents.

This fix adds a utility method _get_sync_funcs_to_skip_in_async_chat that identifies sync functions with async counterparts (by detecting async functions registered with ignore_async_in_sync_chat=True and matching them to their sync equivalents via the 'a_' naming convention). The a_generate_reply method 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

@marklysze marklysze changed the title fix: Prevent double Auto Reply Events execution when using async run fix: Prevent double using_auto_reply events when using async run Dec 21, 2025
@marklysze marklysze requested a review from randombet December 21, 2025 09:01
@joggrbot
Copy link
Contributor

joggrbot bot commented Dec 21, 2025

📝 Documentation Analysis

All docs are up to date! 🎉


✅ Latest commit analyzed: c840716 | Powered by Joggr

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
autogen/agentchat/conversable_agent.py 88.23% 0 Missing and 2 partials ⚠️
Files with missing lines Coverage Δ
autogen/agentchat/conversable_agent.py 65.30% <88.23%> (-0.75%) ⬇️

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants