fix: correct handoff output attribution

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-24 23:55:30 +01:00
co-authored by Copilot
parent 2fc03454c4
commit 7c848113c0
4 changed files with 98 additions and 115 deletions
@@ -1,90 +0,0 @@
using Eryx.AgentHost.Contracts;
using Eryx.AgentHost.Services;
namespace Eryx.AgentHost.Tests;
public sealed class CopilotAgentBundleTests
{
[Fact]
public void ShouldDisableSessionTools_DisablesScratchpadAgents()
{
PatternDefinitionDto pattern = CreatePattern(
mode: "sequential",
CreateAgent("agent-primary", "Primary"));
bool disabled = CopilotAgentBundle.ShouldDisableSessionTools(
pattern,
pattern.Agents[0],
workspaceKind: "scratchpad");
Assert.True(disabled);
}
[Fact]
public void ShouldDisableSessionTools_DisablesOnlyHandoffEntryAgent()
{
PatternDefinitionDto pattern = CreatePattern(
mode: "handoff",
CreateAgent("agent-handoff-triage", "Triage"),
CreateAgent("agent-handoff-runtime", "Runtime Specialist"));
bool triageDisabled = CopilotAgentBundle.ShouldDisableSessionTools(
pattern,
pattern.Agents[0],
workspaceKind: "project");
bool specialistDisabled = CopilotAgentBundle.ShouldDisableSessionTools(
pattern,
pattern.Agents[1],
workspaceKind: "project");
Assert.True(triageDisabled);
Assert.False(specialistDisabled);
}
[Fact]
public void ShouldDisableSessionTools_LeavesNonHandoffProjectAgentsEnabled()
{
PatternDefinitionDto pattern = CreatePattern(
mode: "sequential",
CreateAgent("agent-analyst", "Analyst"),
CreateAgent("agent-builder", "Builder"));
bool disabled = CopilotAgentBundle.ShouldDisableSessionTools(
pattern,
pattern.Agents[0],
workspaceKind: "project");
Assert.False(disabled);
}
private static PatternDefinitionDto CreatePattern(string mode, params PatternAgentDefinitionDto[] agents)
{
return new PatternDefinitionDto
{
Id = $"pattern-{mode}",
Name = mode,
Mode = mode,
Availability = "available",
Agents = agents,
Graph = PatternGraphResolver.CreateDefault(new PatternDefinitionDto
{
Id = $"pattern-{mode}",
Name = mode,
Mode = mode,
Availability = "available",
Agents = agents,
}),
};
}
private static PatternAgentDefinitionDto CreateAgent(string id, string name)
{
return new PatternAgentDefinitionDto
{
Id = id,
Name = name,
Instructions = $"You are {name}.",
Model = "gpt-5.4",
};
}
}
@@ -330,6 +330,47 @@ public sealed class CopilotWorkflowRunnerTests
Assert.Equal("The button is in place.", message.Content);
}
[Fact]
public void ProjectCompletedMessages_PrefersContentMatchedStreamingSegmentOverPosition()
{
RunTurnCommandDto command = new()
{
RequestId = "turn-1",
SessionId = "session-1",
Pattern = new PatternDefinitionDto
{
Id = "pattern-handoff",
Name = "Handoff Support Flow",
Mode = "handoff",
Availability = "available",
Agents =
[
CreateAgent(id: "agent-handoff-triage", name: "Triage"),
CreateAgent(id: "agent-handoff-runtime", name: "Runtime Specialist"),
],
},
};
IReadOnlyList<ChatMessageDto> messages = WorkflowTranscriptProjector.ProjectCompletedMessages(
command,
[
new ChatMessage(ChatRole.Assistant, "Done — GoogleClient.cs now contains the requested class.")
{
AuthorName = "assistant",
},
],
[
("msg-1", "Triage", "I'll hand this to a coding specialist."),
("msg-2", "Runtime Specialist", "Done — GoogleClient.cs now contains the requested class."),
],
new AgentIdentity("agent-handoff-runtime", "Runtime Specialist"));
ChatMessageDto message = Assert.Single(messages);
Assert.Equal("msg-2", message.Id);
Assert.Equal("Runtime Specialist", message.AuthorName);
Assert.Equal("Done — GoogleClient.cs now contains the requested class.", message.Content);
}
[Fact]
public void ProjectCompletedMessages_DropsBlankAssistantOutputMessages()
{