compact 이후 컨텍스트 재주입과 일반 작업 최종 보고를 claw-code 스타일로 경량화

- compact boundary가 적용된 query view에 post_compact_context system 메시지를 추가해 복원된 파일/이미지 참조를 짧게 다시 전달함

- 일반 Cowork/Code 작업은 final-report 품질 프롬프트를 3줄 요약 중심으로 줄이고 review/high-impact 작업만 구조적 상세 보고를 유지함

- README.md 및 docs/DEVELOPMENT.md를 2026-04-12 23:14 (KST) 기준으로 갱신함

- 검증: dotnet build src/AxCopilot/AxCopilot.csproj -c Release -v minimal -p:OutputPath=bin\\verify\\ -p:IntermediateOutputPath=obj\\verify\\ (경고 0, 오류 0)
This commit is contained in:
2026-04-12 22:18:55 +09:00
parent 4db75d46cd
commit c7b2bba063
4 changed files with 69 additions and 3 deletions

View File

@@ -3519,10 +3519,17 @@ public partial class AgentLoopService
private static string BuildFinalReportQualityPrompt(TaskTypePolicy taskPolicy, bool highImpact)
{
if (!taskPolicy.IsReviewTask && !highImpact)
{
return "[System:FinalReportQuality] 최종 답변을 짧고 명확하게 정리하세요.\n" +
"1. 무엇을 변경했는지\n" +
"2. 무엇을 확인했는지\n" +
"3. 실제 미해결 이슈가 있을 때만 한 줄로 적기\n" +
"불필요한 세부 목록, 메타 설명, 후속 권유는 쓰지 마세요.";
}
var taskLine = taskPolicy.FinalReportTaskLine;
var riskLine = taskPolicy.IsReviewTask || highImpact
? "남은 리스크나 추가 확인 필요 사항이 실제로 남아 있을 때만 짧게 적으세요.\n"
: "";
var riskLine = "남은 리스크나 추가 확인 필요 사항이 실제로 남아 있을 때만 짧게 적으세요.\n";
return "[System:FinalReportQuality] 최종 답변을 더 구조적으로 정리하세요.\n" +
"1. 무엇을 변경했는지\n" +

View File

@@ -22,6 +22,7 @@ public sealed class AgentQueryContextWindowResult
public static class AgentQueryContextBuilder
{
private const int ProtectedRecentNonSystemMessages = 8;
private const string PostCompactContextMetaKind = "post_compact_context";
public static AgentQueryContextWindowResult Build(IReadOnlyList<ChatMessage> sourceMessages)
{
@@ -60,6 +61,9 @@ public static class AgentQueryContextBuilder
windowMessages.Add(CloneMessage(sourceMessages[i]));
}
if (boundaryApplied)
InjectPostCompactContextMessage(windowMessages);
var tokensBeforeBudget = TokenEstimator.EstimateMessages(windowMessages);
var budgetResult = AgentToolResultBudget.Apply(windowMessages, ProtectedRecentNonSystemMessages);
var tokensAfterBudget = TokenEstimator.EstimateMessages(windowMessages);
@@ -134,4 +138,42 @@ public static class AgentQueryContextBuilder
}).ToList(),
};
}
private static void InjectPostCompactContextMessage(List<ChatMessage> messages)
{
if (messages.Count == 0)
return;
if (messages.Any(m => string.Equals(m.MetaKind, PostCompactContextMetaKind, StringComparison.OrdinalIgnoreCase)))
return;
var attachedFiles = messages
.SelectMany(m => m.AttachedFiles ?? Enumerable.Empty<string>())
.Distinct(StringComparer.OrdinalIgnoreCase)
.Take(5)
.ToList();
var imageCount = messages.Sum(m => m.Images?.Count ?? 0);
if (attachedFiles.Count == 0 && imageCount == 0)
return;
var lines = new List<string> { "[post-compact context]" };
if (attachedFiles.Count > 0)
lines.Add("restored file refs: " + string.Join(", ", attachedFiles));
if (imageCount > 0)
lines.Add($"restored image refs: {imageCount}");
var insertIndex = 0;
while (insertIndex < messages.Count && string.Equals(messages[insertIndex].Role, "system", StringComparison.OrdinalIgnoreCase))
insertIndex++;
messages.Insert(insertIndex, new ChatMessage
{
Role = "system",
MetaKind = PostCompactContextMetaKind,
Content = string.Join("\n", lines),
Timestamp = DateTime.Now,
AttachedFiles = attachedFiles.Count > 0 ? attachedFiles : null,
});
}
}