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:
@@ -1665,3 +1665,7 @@ MIT License
|
||||
- [AgentLoopTransitions.Documents.cs](/E:/AX%20Copilot%20-%20Codex/src/AxCopilot/Services/Agent/AgentLoopTransitions.Documents.cs) 는 `document_plan` 성공 직후 추가 user 압박 메시지를 넣지 않고, terminal 문서 도구 성공 시 Cowork에서 바로 종료할 수 있게 정리했습니다.
|
||||
- [AgentLoopTransitions.Verification.cs](/E:/AX%20Copilot%20-%20Codex/src/AxCopilot/Services/Agent/AgentLoopTransitions.Verification.cs) 는 `CodeDiffGate`, `RecentExecutionGate`, `ExecutionSuccessGate`를 review 작업 중심으로 제한해 일반 코드 수정의 과검증을 줄였습니다.
|
||||
- [TaskTypePolicy.cs](/E:/AX%20Copilot%20-%20Codex/src/AxCopilot/Services/Agent/TaskTypePolicy.cs), [ChatWindow.SystemPromptBuilder.cs](/E:/AX%20Copilot%20-%20Codex/src/AxCopilot/Views/ChatWindow.SystemPromptBuilder.cs), [cowork_문서작성.json](/E:/AX%20Copilot%20-%20Codex/src/AxCopilot/Assets/Presets/cowork_%EB%AC%B8%EC%84%9C%EC%9E%91%EC%84%B1.json), [cowork_보고서.json](/E:/AX%20Copilot%20-%20Codex/src/AxCopilot/Assets/Presets/cowork_%EB%B3%B4%EA%B3%A0%EC%84%9C.json) 도 같은 기준으로 문서 생성/텍스트 종료 조건을 더 얇게 맞췄습니다.
|
||||
- 업데이트: 2026-04-12 23:14 (KST)
|
||||
- compact 이후 query view에 복원된 파일/이미지 참조를 짧게 다시 주입해, `claw-code`의 post-compact attachment continuity에 더 가깝게 맞췄습니다.
|
||||
- [AgentQueryContextBuilder.cs](/E:/AX%20Copilot%20-%20Codex/src/AxCopilot/Services/Agent/AgentQueryContextBuilder.cs)는 compact boundary가 적용된 query view에 `post_compact_context` system 메시지를 추가해, 복원된 파일 참조와 이미지 참조 개수를 함께 전달합니다.
|
||||
- [AgentLoopService.cs](/E:/AX%20Copilot%20-%20Codex/src/AxCopilot/Services/Agent/AgentLoopService.cs)의 final-report 품질 프롬프트는 일반 작업에서는 더 짧고 명확한 3줄 요약 중심으로 축소하고, review/high-impact 작업에만 구조적 상세 보고를 유지하도록 조정했습니다.
|
||||
|
||||
@@ -706,3 +706,16 @@ owKindCounts를 함께 남겨 %APPDATA%\\AxCopilot\\perf 기준으로 transcript
|
||||
- Code는 일반 수정 작업에서 review 수준의 무거운 follow-up gate가 덜 개입합니다.
|
||||
- 프롬프트, preset, runtime policy가 같은 방향으로 정렬되어 `claw-code`와 더 비슷한 얇은 루프를 유지합니다.
|
||||
|
||||
## post-compact context 재주입 / 일반 final-report 경량화 (2026-04-12 23:14 KST)
|
||||
|
||||
- `claw-code`는 compact 뒤 attachment/tool/memory 상태를 다시 붙여 첫 post-compact turn이 맥락을 잃지 않게 만듭니다. AX는 파일명 continuity는 있었지만, query view에 “복원된 참조 상태”를 직접 실어주는 층이 약했습니다.
|
||||
- `src/AxCopilot/Services/Agent/AgentQueryContextBuilder.cs`
|
||||
- compact boundary가 적용된 query view에 `post_compact_context` system 메시지를 삽입합니다.
|
||||
- 이 메시지는 compact 이후 다시 이어져야 하는 `AttachedFiles`와 이미지 개수를 짧게 요약해, LLM이 첫 post-compact turn에서 참조 맥락을 더 쉽게 복원하도록 돕습니다.
|
||||
- `src/AxCopilot/Services/Agent/AgentLoopService.cs`
|
||||
- `BuildFinalReportQualityPrompt()`를 일반 작업과 review/high-impact 작업으로 분기했습니다.
|
||||
- 일반 작업은 `무엇을 변경했는지 / 무엇을 확인했는지 / 실제 미해결 이슈가 있을 때만 한 줄` 중심의 짧은 요약을 요구하고, review/high-impact만 기존의 구조적 상세 보고를 유지합니다.
|
||||
- 기대 효과
|
||||
- compact 직후 첫 query turn이 복원된 파일/이미지 참조를 더 안정적으로 이어받습니다.
|
||||
- 일반 Cowork/Code 작업의 최종 응답이 `claw-code`처럼 더 짧고 메타 밀도가 낮아집니다.
|
||||
|
||||
|
||||
@@ -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" +
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user