Skip to content

fix(agentchat): use running loop for sync input callbacks#7865

Open
Ghraven wants to merge 1 commit into
microsoft:mainfrom
Ghraven:fix/user-input-running-loop
Open

fix(agentchat): use running loop for sync input callbacks#7865
Ghraven wants to merge 1 commit into
microsoft:mainfrom
Ghraven:fix/user-input-running-loop

Conversation

@Ghraven

@Ghraven Ghraven commented Jun 19, 2026

Copy link
Copy Markdown

Summary

  • replace asyncio.get_event_loop() with asyncio.get_running_loop() when sync user-input callbacks are executed from async AgentChat paths
  • update both UserProxyAgent._get_input() and UserInputManager so they use the already-running event loop before dispatching work to the executor

Problem

These code paths run inside coroutines and only need the active event loop to call run_in_executor(). asyncio.get_event_loop() is a legacy lookup API whose behavior has become stricter across Python versions, while get_running_loop() is the intended API when a coroutine is already executing.

Before / After

Before: sync input callbacks in AgentChat and Console used asyncio.get_event_loop() from async functions.

After: the same callbacks use asyncio.get_running_loop(), preserving behavior while avoiding the legacy event-loop lookup.

Verification

  • python -m compileall python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py python/packages/autogen-agentchat/src/autogen_agentchat/ui/_console.py
  • git diff --check
  • uv run pytest tests/test_userproxy_agent.py -q (5 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.

1 participant