???? ?? ?? ?? ??? ?? fallback ???? ?? ??
- CodeLanguageCatalog? UTF-8 ???? ????? ?? fallback ???? ??? ??? manifest/build/test/lint ?? ?? ??? ???? - WorkspaceContextGenerator? ?? ??? ????? ?? Language Workflow ??? ?????? ??? no-LSP ?????? ?? ??? ?? ??? ?? ??? - AgentLoopLlmRequestPreparationService? ??? ?? tool-call ??? pre-call reminder ?? ??? AgentLoopService?? ??? - CodeLanguageCatalogTests, WorkspaceContextGeneratorTests, AgentLoopLlmRequestPreparationServiceTests? ??? ?? fallback/????/LLM ?? ?? ??? ??? - ??: dotnet build src/AxCopilot/AxCopilot.csproj -c Release -v minimal -p:OutputPath=bin\\verify_final_batch\\ -p:IntermediateOutputPath=obj\\verify_final_batch\\ (?? 0 / ?? 0) - ??: dotnet test src/AxCopilot.Tests/AxCopilot.Tests.csproj -c Release -v minimal --filter "CodeLanguageCatalogTests|WorkspaceContextGeneratorTests|AgentLoopLlmRequestPreparationServiceTests|AgentLoopIterationPreparationServiceTests|AgentMessageInvariantHelperTests|AgentToolResultBudgetTests|ChatStorageServiceTests|HtmlSkillGoldenReportTests|PptxSkillGoldenDeckTests|DocxSkillGoldenDocumentTests|ExcelSkillGoldenWorkbookTests" -p:OutputPath=bin\\verify_final_batch_tests\\ -p:IntermediateOutputPath=obj\\verify_final_batch_tests\\ (?? 54)
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using AxCopilot.Models;
|
||||
using AxCopilot.Services.Agent;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace AxCopilot.Tests.Services;
|
||||
|
||||
public class AgentLoopLlmRequestPreparationServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void Prepare_ShouldInjectToolReminderOnFirstForcedCall()
|
||||
{
|
||||
var queryMessages = new List<ChatMessage>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Role = "user",
|
||||
Content = "inspect the repository"
|
||||
}
|
||||
};
|
||||
|
||||
var result = AgentLoopLlmRequestPreparationService.Prepare(
|
||||
queryMessages,
|
||||
totalToolCalls: 0,
|
||||
forceInitialToolCallEnabled: true,
|
||||
injectPreCallToolReminder: true,
|
||||
noToolCallLoopRetry: 0);
|
||||
|
||||
result.ForceInitialToolCall.Should().BeTrue();
|
||||
result.InjectedToolReminder.Should().BeTrue();
|
||||
result.SendMessages.Should().HaveCount(2);
|
||||
result.SendMessages.Last().Content.Should().Contain("[TOOL_REQUIRED]");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Prepare_ShouldSkipReminderWhenRetryLoopIsAlreadyActive()
|
||||
{
|
||||
var queryMessages = new List<ChatMessage>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Role = "user",
|
||||
Content = "inspect the repository"
|
||||
}
|
||||
};
|
||||
|
||||
var result = AgentLoopLlmRequestPreparationService.Prepare(
|
||||
queryMessages,
|
||||
totalToolCalls: 0,
|
||||
forceInitialToolCallEnabled: true,
|
||||
injectPreCallToolReminder: true,
|
||||
noToolCallLoopRetry: 1);
|
||||
|
||||
result.ForceInitialToolCall.Should().BeTrue();
|
||||
result.InjectedToolReminder.Should().BeFalse();
|
||||
result.SendMessages.Should().HaveCount(1);
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class CodeLanguageCatalogTests
|
||||
summary.Should().Contain("go build ./...");
|
||||
summary.Should().Contain("go test ./...");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildWorkflowSummary_ShouldExposeActionableWorkflowHints()
|
||||
{
|
||||
@@ -77,4 +78,18 @@ public class CodeLanguageCatalogTests
|
||||
CodeLanguageCatalog.GetTestHints("kotlin").Should().Contain("./gradlew test");
|
||||
CodeLanguageCatalog.GetLintHints("javascript").Should().Contain("eslint .");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildWorkspaceWorkflowSummaries_ShouldPreferSelectedLanguageAndDedupeEntries()
|
||||
{
|
||||
var summaries = CodeLanguageCatalog.BuildWorkspaceWorkflowSummaries(
|
||||
[".go", ".py", ".go", ".rs"],
|
||||
preferredKey: "python",
|
||||
maxLanguages: 3);
|
||||
|
||||
summaries.Should().HaveCount(3);
|
||||
summaries[0].Should().StartWith("Python:");
|
||||
summaries.Should().Contain(summary => summary.StartsWith("Go:"));
|
||||
summaries.Should().Contain(summary => summary.StartsWith("Rust:"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,4 +338,27 @@ public class WorkspaceContextGeneratorTests
|
||||
Directory.Delete(tempDir, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetectLanguageWorkflowHints_ShouldPreferSelectedLanguage()
|
||||
{
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(tempDir);
|
||||
try
|
||||
{
|
||||
File.WriteAllText(Path.Combine(tempDir, "main.go"), "package main");
|
||||
File.WriteAllText(Path.Combine(tempDir, "worker.go"), "package main");
|
||||
File.WriteAllText(Path.Combine(tempDir, "helper.py"), "print('hi')");
|
||||
|
||||
var hints = WorkspaceContextGenerator.DetectLanguageWorkflowHints(tempDir, preferredLanguage: "python");
|
||||
|
||||
hints.Should().NotBeEmpty();
|
||||
hints[0].Should().StartWith("Python:");
|
||||
hints.Should().Contain(hint => hint.StartsWith("Go:"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(tempDir, recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user