코드 탭 컨텍스트 영속화와 Auto budget 복구 적용
- AxAgentExecutionEngine에서 시스템 프롬프트 중복을 제거하고 structured tool_use/tool_result 전사본을 conversation.Messages로 동기화해 다음 턴과 저장 이력에서도 코드 작업 컨텍스트가 유지되도록 수정 - AgentQueryContextBuilder와 ContextCondenser에 post-compact tool snippet 복원, recent window 확대, tool result 보존 강화 로직을 추가해 장기 코드 실행 중 빌드/파일 근거 손실을 줄임 - MaxContextTokens=0 Auto 모드를 AppSettings, SettingsService 마이그레이션, 설정 UI, 오버레이 UI, 컨텍스트 사용량 표시, LLM 요청 본문에 연결하고 Auto 모드에서는 provider output cap 강제 주입을 제거 - 관련 회귀 테스트와 문서 README/DEVELOPMENT/CODE_CONTEXT_RELIABILITY_PLAN을 갱신하고 깨진 진단 문자열 기대값을 영어 기준으로 정리 검증: - dotnet build src/AxCopilot/AxCopilot.csproj -c Release -v minimal -p:OutputPath=bin\\verify_context_reliability_followup\\ -p:IntermediateOutputPath=obj\\verify_context_reliability_followup\\ - dotnet test src/AxCopilot.Tests/AxCopilot.Tests.csproj -c Release -v minimal --filter "AxAgentExecutionEngineTests|AgentQueryContextBuilderTests|ContextCondenserTests|SettingsServiceTests|AgentLoopDiagnosticsFormatterTests" -p:OutputPath=bin\\verify_context_reliability_followup_tests\\ -p:IntermediateOutputPath=obj\\verify_context_reliability_followup_tests\\ - dotnet test src/AxCopilot.Tests/AxCopilot.Tests.csproj -c Release -v minimal --filter "AgentLoopQueryAssemblyServiceTests|AgentLoopPreLlmStageServiceTests|AgentLoopLlmRequestPreparationServiceTests|AgentMessageInvariantHelperTests|CodeTaskWorkingSetServiceTests|AgentLoopE2ETests" -p:OutputPath=bin\\verify_context_reliability_followup_tests2\\ -p:IntermediateOutputPath=obj\\verify_context_reliability_followup_tests2\\ - dotnet build src/AxCopilot/AxCopilot.csproj -c Release -v minimal -p:OutputPath=bin\\verify_context_reliability_final\\ -p:IntermediateOutputPath=obj\\verify_context_reliability_final\\
This commit is contained in:
@@ -34,12 +34,13 @@ public static class ContextCondenser
|
||||
/// <summary>도구 결과 1개당 최대 유지 길이 (자)</summary>
|
||||
private const int MaxToolResultChars = 1500;
|
||||
private const int MicrocompactSingleKeepChars = 480;
|
||||
private const int MicrocompactGroupMinCount = 2;
|
||||
private const int MicrocompactGroupMinCount = 4;
|
||||
private const int SnipKeepHeadChars = 220;
|
||||
private const int SnipKeepTailChars = 140;
|
||||
private const int ToolResultTruncationKeepCount = 6;
|
||||
|
||||
/// <summary>요약 시 유지할 최근 메시지 수</summary>
|
||||
private const int RecentKeepCount = 6;
|
||||
private const int RecentKeepCount = 12;
|
||||
private const int AutoCompactBufferTokens = 13_000;
|
||||
private const int SummaryReserveTokens = 20_000;
|
||||
private const string TimeBasedClearedToolResultMessage = "[time-based microcompact] 이전 tool_result 내용이 정리되었습니다.";
|
||||
@@ -78,9 +79,17 @@ public static class ContextCondenser
|
||||
};
|
||||
}
|
||||
|
||||
private static int GetEffectiveContextWindowSize(string service, string model, int configuredLimit)
|
||||
public static int ResolveContextBudgetTokens(string service, string model, int configuredLimit)
|
||||
{
|
||||
var contextWindow = configuredLimit > 0 ? configuredLimit : GetModelInputLimit(service, model);
|
||||
if (configuredLimit > 0)
|
||||
return Math.Clamp(configuredLimit, 1_024, 1_000_000);
|
||||
|
||||
return GetModelInputLimit(service, model);
|
||||
}
|
||||
|
||||
public static int GetEffectiveContextWindowSize(string service, string model, int configuredLimit)
|
||||
{
|
||||
var contextWindow = ResolveContextBudgetTokens(service, model, configuredLimit);
|
||||
var reservedForSummary = Math.Min(SummaryReserveTokens, Math.Max(4_000, contextWindow / 8));
|
||||
return Math.Max(8_000, contextWindow - reservedForSummary);
|
||||
}
|
||||
@@ -337,10 +346,10 @@ public static class ContextCondenser
|
||||
/// </summary>
|
||||
private static bool TruncateToolResults(List<ChatMessage> messages)
|
||||
{
|
||||
var budgetResult = AgentToolResultBudget.Apply(messages, RecentKeepCount);
|
||||
var budgetResult = AgentToolResultBudget.Apply(messages, ToolResultTruncationKeepCount);
|
||||
bool truncated = budgetResult.TruncatedCount > 0;
|
||||
|
||||
var cutoff = Math.Max(0, messages.Count - RecentKeepCount);
|
||||
var cutoff = Math.Max(0, messages.Count - ToolResultTruncationKeepCount);
|
||||
|
||||
for (int i = 0; i < cutoff; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user