Files
aryx/sidecar/tests/Aryx.AgentHost.Tests/HandoffWorkflowGuidanceTests.cs
T
David KayaandCopilot 1dd13588a0 refactor: move handoff guidance into workflow builder
Move handoff routing and ownership rules out of per-agent system
prompts and into the Agent Framework handoff builder guidance.

This keeps AgentInstructionComposer focused on Aryx-owned system
prompt content while letting WithHandoffInstructions supply the
workflow-level handoff semantics.

- remove handoff-mode runtime guidance from AgentInstructionComposer
- expand HandoffWorkflowGuidance with the triage/specialist rules
- update tests to pin the new split of responsibilities

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 19:05:01 +02:00

61 lines
2.6 KiB
C#

using Aryx.AgentHost.Contracts;
using Aryx.AgentHost.Services;
namespace Aryx.AgentHost.Tests;
public sealed class HandoffWorkflowGuidanceTests
{
[Fact]
public void CreateWorkflowInstructions_RequiresRealHandoffs()
{
string instructions = HandoffWorkflowGuidance.CreateWorkflowInstructions();
Assert.Contains("explicit handoffs", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("routing or triage agent", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("best specialist", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Do not inspect files", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Do not claim that you delegated", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Do not narrate a handoff", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("own the substantive answer", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Specialists should complete the substantive work", instructions, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public void CreateForwardReason_UsesTargetSpecialtyAndOwnership()
{
PatternAgentDefinitionDto specialist = new()
{
Id = "agent-handoff-ux",
Name = "UX Specialist",
Description = "Handles user experience questions.",
Instructions = "Focus on UX.",
Model = "claude-opus-4.5",
};
string reason = HandoffWorkflowGuidance.CreateForwardReason(specialist);
Assert.Contains("Handles user experience questions", reason, StringComparison.OrdinalIgnoreCase);
Assert.Contains("UX Specialist", reason, StringComparison.OrdinalIgnoreCase);
Assert.Contains("substantive response", reason, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public void CreateReturnReason_RestrictsReturnToReroutingCases()
{
PatternAgentDefinitionDto triage = new()
{
Id = "agent-handoff-triage",
Name = "Triage",
Description = "Routes the request to the right specialist.",
Instructions = "Triages requests.",
Model = "gpt-5.4",
};
string reason = HandoffWorkflowGuidance.CreateReturnReason(triage);
Assert.Contains("Triage", reason, StringComparison.OrdinalIgnoreCase);
Assert.Contains("re-routing", reason, StringComparison.OrdinalIgnoreCase);
Assert.Contains("outside your specialty", reason, StringComparison.OrdinalIgnoreCase);
}
}