KEMBAR78
Feature/agentchat message id field 6317 by tejas-dharani · Pull Request #6645 · microsoft/autogen · GitHub
Skip to content

Conversation

@tejas-dharani
Copy link
Contributor

Why are these changes needed?

This PR implements unique ID fields for AgentChat messages to enable proper correlation between streaming chunks and completed messages. Currently, there's no way to correlate ModelClientStreamingChunkEvent chunks with their eventual completed message, which can lead to duplicate message display in streaming scenarios.

The implementation adds:

  • id: str field to BaseChatMessage with automatic UUID generation
  • id: str field to BaseAgentEvent with automatic UUID generation
  • full_message_id: str | None field to ModelClientStreamingChunkEvent for chunk-to-message correlation

This allows consumers of the streaming API to avoid double-printing messages by correlating chunks with their final complete message.

Related issue number

Closes #6317

Checks

…on guide- Fix version format from 0.4.0-dev-1 to 0.4.0-dev.1 for all packages- Remove reference to non-existent Microsoft.AutoGen.Extensions package- Add correct extension packages: Aspire, MEAI, and SemanticKernel- Fix typo: RuntimeGatewway -> RuntimeGateway- Improve documentation structure with clear section headersFixes #6244
Fix issue #6277 where TextMessage was used but not imported in three code cells
of the custom agents documentation, causing NameError when users run the examples.

Changes:
- Add TextMessage to imports in ArithmeticAgent section
- Add TextMessage to imports in GeminiAssistantAgent section
- Add TextMessage to imports in Declarative GeminiAssistantAgent section

The CountDownAgent section already had the correct import.

Fixes #6277
Add unique id field to BaseChatMessage and BaseAgentEvent, plus full_message_id
to ModelClientStreamingChunkEvent for streaming correlation.

Closes #6317
@tejas-dharani
Copy link
Contributor Author

@microsoft-github-policy-service agree

@codecov
Copy link

codecov bot commented Jun 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.75%. Comparing base (3436ec2) to head (0000095).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6645      +/-   ##
==========================================
+ Coverage   79.74%   79.75%   +0.01%     
==========================================
  Files         232      232              
  Lines       17403    17414      +11     
==========================================
+ Hits        13878    13889      +11     
  Misses       3525     3525              
Flag Coverage Δ
unittests 79.75% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

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

LGTM thanks!!

Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

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

Can you fix the formatting? See instructions in python/README.md

@tejas-dharani
Copy link
Contributor Author

Hello @victordibia Sir,

Can you please review this PR ?

…stallation guide- Fix version format from 0.4.0-dev-1 to 0.4.0-dev.1 for all packages- Remove reference to non-existent Microsoft.AutoGen.Extensions package- Add correct extension packages: Aspire, MEAI, and SemanticKernel- Fix typo: RuntimeGatewway -> RuntimeGateway- Improve documentation structure with clear section headersFixes #6244"

This reverts commit 6d9fb2e.
Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

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

Can you also update assistant agent to use this id to generate chunk events

@tejas-dharani
Copy link
Contributor Author

Can you also update assistant agent to use this id to generate chunk events

Hello @ekzhu Sir,

I have implemented the feature.

Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

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

Use default factory unless for streaming chunk events

@tejas-dharani tejas-dharani requested a review from ekzhu June 27, 2025 14:38
@tejas-dharani tejas-dharani requested a review from ekzhu June 29, 2025 11:40
@ekzhu ekzhu merged commit da20f7c into microsoft:main Jun 29, 2025
66 checks 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.

AgentChat messages should have an id field.

2 participants