mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Fix: Add missing ChatMessage[] handler to ChatProtocolExecutor (#1337)
- Added ChatMessage[] handler to ConfigureRoutes to support array dispatch - Workflow runtime can dispatch messages as either List<ChatMessage> or ChatMessage[] - Added 10 comprehensive unit tests validating message routing behavior - Tests ensure functionality and protect against future refactoring (issue #782) - Updated code comments to reflect exact-type-matching requirement Fixes issue where raw WorkflowBuilder with AIAgent nodes failed to receive initial messages due to missing array type handler.
This commit is contained in:
@@ -33,8 +33,10 @@ internal abstract class ChatProtocolExecutor(string id, ChatProtocolExecutorOpti
|
||||
routeBuilder = routeBuilder.AddHandler<string>((message, _, __) => this._pendingMessages.Add(new(this._stringMessageChatRole.Value, message)));
|
||||
}
|
||||
|
||||
// Routing requires exact type matches. The runtime may dispatch either List<ChatMessage> or ChatMessage[].
|
||||
return routeBuilder.AddHandler<ChatMessage>((message, _, __) => this._pendingMessages.Add(message))
|
||||
.AddHandler<List<ChatMessage>>((messages, _, __) => this._pendingMessages.AddRange(messages))
|
||||
.AddHandler<ChatMessage[]>((messages, _, __) => this._pendingMessages.AddRange(messages))
|
||||
.AddHandler<TurnToken>(this.TakeTurnAsync);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user