mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-29 07:58:47 +02:00
Add backend support for plan-mode turn shaping and exit-plan review checkpoints. Run-turn commands now accept an interaction mode, plan-mode prompt guidance tells agents to produce a plan and call exit_plan_mode, and the sidecar emits a structured exit-plan-mode-requested event when the SDK raises that session event. For now the backend intentionally treats exit_plan_mode as a turn boundary and graceful-degradation review checkpoint. The current Agent Framework GitHubCopilotAgent wrapper does not expose a clean way to bridge the live CopilotSession back into same-turn exit-plan resolution, so that follow-up remains documented for the frontend and a future backend slice. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
73 lines
2.6 KiB
C#
73 lines
2.6 KiB
C#
using Aryx.AgentHost.Contracts;
|
|
using Aryx.AgentHost.Services;
|
|
using GitHub.Copilot.SDK;
|
|
|
|
namespace Aryx.AgentHost.Tests;
|
|
|
|
public sealed class CopilotExitPlanModeCoordinatorTests
|
|
{
|
|
[Fact]
|
|
public void RecordExitPlanModeRequest_BuildsEventAndMakesItConsumable()
|
|
{
|
|
CopilotExitPlanModeCoordinator coordinator = new();
|
|
RunTurnCommandDto command = CreateCommand();
|
|
|
|
ExitPlanModeRequestedEventDto exitPlanEvent = coordinator.RecordExitPlanModeRequest(
|
|
command,
|
|
command.Pattern.Agents[0],
|
|
new ExitPlanModeRequestedEvent
|
|
{
|
|
Data = new ExitPlanModeRequestedData
|
|
{
|
|
RequestId = "exit-plan-1",
|
|
Summary = "Proposed plan",
|
|
PlanContent = "1. Investigate\n2. Implement",
|
|
Actions = ["interactive", "autopilot"],
|
|
RecommendedAction = "interactive",
|
|
},
|
|
});
|
|
|
|
Assert.Equal("exit-plan-mode-requested", exitPlanEvent.Type);
|
|
Assert.Equal("turn-1", exitPlanEvent.RequestId);
|
|
Assert.Equal("session-1", exitPlanEvent.SessionId);
|
|
Assert.Equal("exit-plan-1", exitPlanEvent.ExitPlanId);
|
|
Assert.Equal("agent-1", exitPlanEvent.AgentId);
|
|
Assert.Equal("Primary", exitPlanEvent.AgentName);
|
|
Assert.Equal("Proposed plan", exitPlanEvent.Summary);
|
|
Assert.Equal("1. Investigate\n2. Implement", exitPlanEvent.PlanContent);
|
|
Assert.Equal(["interactive", "autopilot"], exitPlanEvent.Actions);
|
|
Assert.Equal("interactive", exitPlanEvent.RecommendedAction);
|
|
|
|
ExitPlanModeRequestedEventDto? consumed = coordinator.ConsumePendingRequest(command.RequestId);
|
|
Assert.NotNull(consumed);
|
|
Assert.Equal("exit-plan-1", consumed!.ExitPlanId);
|
|
Assert.Null(coordinator.ConsumePendingRequest(command.RequestId));
|
|
}
|
|
|
|
private static RunTurnCommandDto CreateCommand()
|
|
{
|
|
return new RunTurnCommandDto
|
|
{
|
|
RequestId = "turn-1",
|
|
SessionId = "session-1",
|
|
Pattern = new PatternDefinitionDto
|
|
{
|
|
Id = "pattern-1",
|
|
Name = "Plan Mode Pattern",
|
|
Mode = "single",
|
|
Availability = "available",
|
|
Agents =
|
|
[
|
|
new PatternAgentDefinitionDto
|
|
{
|
|
Id = "agent-1",
|
|
Name = "Primary",
|
|
Model = "gpt-5.4",
|
|
Instructions = "Help with the request.",
|
|
},
|
|
],
|
|
},
|
|
};
|
|
}
|
|
}
|