You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: Rejected system messages leave AgentChat permanently active #14638
AgentChat.add_chat_messages() sets its activity signal before validating message roles. If it rejects a system message, it raises before entering the try/finally that clears the signal. After the caller catches this validation error, the same AgentGroupChat cannot accept a corrected message, read its history, or reset: each operation reports that another agent is active.
Reproduced against current main, commit 25501830b9483ad6b23955dee340c8590fa54152, with Python 3.12.13 on macOS arm64:
importasynciofromsemantic_kernel.agentsimportAgentGroupChatfromsemantic_kernel.contentsimportChatMessageContentfromsemantic_kernel.contents.utils.author_roleimportAuthorRolefromsemantic_kernel.exceptions.agent_exceptionsimportAgentChatExceptionasyncdefmain():
chat=AgentGroupChat()
awaitchat.add_chat_message("seed")
try:
awaitchat.add_chat_message(
ChatMessageContent(role=AuthorRole.SYSTEM, content="unsupported")
)
exceptAgentChatException:
passprint(chat.is_active) # True, although no operation is runningawaitchat.add_chat_message("corrected input")
# Exception: Unable to proceed while another agent is active.asyncio.run(main())
Expected behavior: keep rejecting system messages, preserve the existing history, and release the activity signal so the caller can recover. A mixed user/system batch is correctly rejected without partially appending the user message, but it leaves the same stuck activity signal.
The existing test_add_chat_messages_throws_exception_for_system_role checks the rejection but does not check recovery. The existing group-chat and strategy tests pass (77 tests) while six real-API rejection/recovery scenarios reproduce the problem and three valid-message controls succeed. These checks require no model or provider API.
I would like to take on a small fix that keeps role validation inside the activity cleanup scope, with regression coverage for history preservation and recovery. The activity acquisition would remain outside the try so a rejected competing operation cannot release another operation's signal. Is this correction still welcome in the legacy group-chat API given the Agent Framework migration?
This issue and the offline reproduction were prepared with Codex assistance. No implementation patch has been submitted.
Activity