Fix CreateSamplingHandler to use ChatRole.Tool for tool result messages (#1128)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> Co-authored-by: Stephen Toub <stoub@microsoft.com> Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com> Co-authored-by: Mackinnon Buck <mackinnon.buck@gmail.com>
This commit is contained in:
parent
db0beeb2e8
commit
bafbb0a8ba
1 changed files with 103 additions and 2 deletions
|
|
@ -128,7 +128,11 @@ public static class AIContentExtensions
|
|||
{
|
||||
if (sm.Content?.Select(b => b.ToAIContent()).OfType<AIContent>().ToList() is { Count: > 0 } aiContents)
|
||||
{
|
||||
messages.Add(new ChatMessage(sm.Role is Role.Assistant ? ChatRole.Assistant : ChatRole.User, aiContents));
|
||||
ChatRole role =
|
||||
aiContents.All(static c => c is FunctionResultContent) ? ChatRole.Tool :
|
||||
sm.Role is Role.Assistant ? ChatRole.Assistant :
|
||||
ChatRole.User;
|
||||
messages.Add(new ChatMessage(role, aiContents));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue