mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-06 19:58:43 +02:00
fix: preserve handoff final authorship
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -159,6 +159,24 @@ internal static class WorkflowTranscriptProjector
|
||||
}
|
||||
}
|
||||
|
||||
if (remainingMessageCount == 1)
|
||||
{
|
||||
if (fallbackAgent.HasValue
|
||||
&& AgentIdentityResolver.IsGenericAssistantIdentifier(message.AuthorName)
|
||||
&& TryFindLastSegment(
|
||||
remainingSegments,
|
||||
segment => string.Equals(
|
||||
AgentIdentityResolver.ResolveDisplayAuthorName(pattern, segment.AuthorName),
|
||||
fallbackAgent.Value.AgentName,
|
||||
StringComparison.Ordinal),
|
||||
out (string MessageId, string AuthorName, string Content) fallbackMatchedSegment))
|
||||
{
|
||||
return fallbackMatchedSegment;
|
||||
}
|
||||
|
||||
return remainingSegments[^1];
|
||||
}
|
||||
|
||||
return remainingSegments.Count == remainingMessageCount
|
||||
? remainingSegments[0]
|
||||
: null;
|
||||
@@ -182,6 +200,25 @@ internal static class WorkflowTranscriptProjector
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool TryFindLastSegment(
|
||||
IReadOnlyList<(string MessageId, string AuthorName, string Content)> segments,
|
||||
Func<(string MessageId, string AuthorName, string Content), bool> predicate,
|
||||
out (string MessageId, string AuthorName, string Content) matchedSegment)
|
||||
{
|
||||
for (int index = segments.Count - 1; index >= 0; index--)
|
||||
{
|
||||
(string MessageId, string AuthorName, string Content) segment = segments[index];
|
||||
if (predicate(segment))
|
||||
{
|
||||
matchedSegment = segment;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
matchedSegment = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<ChatMessage> SelectNewOutputMessages(
|
||||
IReadOnlyList<ChatMessage> outputMessages,
|
||||
IReadOnlyList<ChatMessage> inputMessages)
|
||||
|
||||
Reference in New Issue
Block a user