Skip to content

Python: start empty group chats and retain streamed replies - #14857

Open
Twiink wants to merge 2 commits into
microsoft:mainfrom
Twiink:fix/empty-agent-channel-20261122
Open

Twiink wants to merge 2 commits into
microsoft:mainfrom
Twiink:fix/empty-agent-channel-20261122

Conversation

@Twiink

@Twiink Twiink commented Nov 22, 2026

Copy link
Copy Markdown

Motivation and Context

An instruction-driven ChatCompletionAgent can be invoked without an input message, but putting it in an initially empty AgentGroupChat raises IndexError in both normal and streaming mode. Pass None when the channel has no latest message, and collect the completed streamed response from the thread when the agent has not updated channel history, so the first reply is retained for subsequent group turns.

The regression uses the public group-chat API in both modes and checks the response and recorded history with an isolated completion-service double.

Description

Keep existing channel-history updates intact and handle the thread-owned streaming history path.

Contribution Checklist

  • The code builds clean without any errors or warnings.
  • The PR follows the SK Contribution Guidelines.
  • The changes have been tested.
  • The PR has been documented.

Validation: both regressions fail against unchanged production code; all 88 chat-completion/group-chat unit tests and the applicable Ruff lint/format checks pass. Existing Pydantic deprecation warnings remain. No live model call was made.

Prepared with AI assistance and verified locally.

@Twiink
Twiink requested a review from a team as a code owner November 22, 2026 06:18
Copilot AI balanced review requested due to automatic review settings November 22, 2026 06:18
@Twiink
Twiink temporarily deployed to github-app-auth November 22, 2026 06:18 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Using channel length as an offset into separate thread history can drop completed replies with preloaded history or duplicate previous replies across consecutive streamed turns.

1 open issue
What changed in this PR

This PR enables instruction-driven Python agents to start empty group chats and adds handling to retain completed streamed replies in group history.

Changes:

  • Pass None when channel history has no latest message.
  • Recover streamed messages from thread history when channel history is unchanged.
  • Add a public-API regression covering empty starts in normal and streaming modes.
File Description
python/​tests/​unit/​agents/​chat_completion/​test_chat_history_channel.py Tests empty group-chat starts and recorded replies in both modes.
python/​semantic_kernel/​agents/​channels/​chat_history_channel.py Handles empty input history and adds streamed-reply recovery.

Review effort: Balanced


if len(self.messages) == message_count:
thread_messages = [message async for message in self.thread.get_messages()]
self.messages.extend(thread_messages[message_count:])

This branch was previously deployed

1 inactive deployment
github-app-auth — 3dd876ee Deployed Nov 22, 2026 by Twiink via add_label #29796
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.

2 participants