[Phase 17-A] Reflexion 자기성찰 메모리 시스템 구현

ReflexionEvaluatorService 신규 구현 (ReflexionService.cs):
- LLM 기반 자기평가: 완성도 점수(0~1), 강점/약점/교훈 추출
- $$raw string 평가 프롬프트로 JSON 포맷 안전하게 삽입
- JSON 블록 추출 + 역직렬화, LLM 실패 시 규칙 기반 폴백 엔트리
- ReflexionRepository.BuildContextPromptAsync() maxEntries 파라미터 추가

AgentLoopService.Reflexion.cs (신규, 82줄):
- InjectReflexionContextAsync(): 세션 시작 전 과거 교훈→시스템 메시지 주입
- FireAndForgetReflexionEval(): 세션 완료 후 Task.Run 비동기 자기평가 저장
- 지연 초기화(_reflexionRepo, _reflexionEval): 사용 시점에 생성

AgentLoopService.cs 통합 포인트 2개 추가:
- RunAsync() 루프 시작 전: await InjectReflexionContextAsync()
- finally 블록 통계 섹션: FireAndForgetReflexionEval() 호출

AgentSettingsPanel — 자기성찰 메모리 섹션 추가:
- 활성화 토글(ChkReflexionEnabled)
- 성공 세션만 평가 토글(ChkReflexionSuccessOnly)
- 최대 참고 교훈 수 슬라이더(1~20, 기본값 5)
- LoadFromSettings() 초기화 + 3개 이벤트 핸들러

빌드: 경고 0, 오류 0
This commit is contained in:
2026-04-03 23:07:59 +09:00
parent 5fe6d5c6ba
commit 90d5943327
6 changed files with 380 additions and 4 deletions

View File

@@ -195,6 +195,57 @@
<Border Height="1" Background="{DynamicResource BorderColor}" Margin="0,8,0,16"/>
<!-- ═══ 자기성찰 메모리 (Phase 17-A) ═══ -->
<TextBlock Text="자기성찰 메모리" FontSize="13" FontWeight="SemiBold"
Foreground="{DynamicResource PrimaryText}" Margin="0,0,0,8"/>
<!-- 자기성찰 활성화 -->
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="자기성찰 메모리" Foreground="{DynamicResource SecondaryText}" FontSize="12"/>
<TextBlock Text="동일 유형 작업 시 과거 교훈 자동 참고" FontSize="10"
Foreground="{DynamicResource SecondaryText}" Opacity="0.7"/>
</StackPanel>
<CheckBox x:Name="ChkReflexionEnabled" Grid.Column="1"
Style="{StaticResource ToggleSwitch}"
Checked="ChkReflexion_Changed" Unchecked="ChkReflexion_Changed"/>
</Grid>
<!-- 성공 시만 평가 -->
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="성공 세션만 평가" Foreground="{DynamicResource SecondaryText}" FontSize="12"
VerticalAlignment="Center"/>
<CheckBox x:Name="ChkReflexionSuccessOnly" Grid.Column="1"
Style="{StaticResource ToggleSwitch}"
Checked="ChkReflexionSuccessOnly_Changed" Unchecked="ChkReflexionSuccessOnly_Changed"/>
</Grid>
<!-- 최대 참고 교훈 수 -->
<Grid Margin="0,0,0,4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="40"/>
</Grid.ColumnDefinitions>
<TextBlock Text="최대 참고 교훈 수" Foreground="{DynamicResource SecondaryText}" FontSize="12"
VerticalAlignment="Center"/>
<TextBlock x:Name="TxtReflexionMaxEntries" Grid.Column="1" Text="5"
Foreground="{DynamicResource PrimaryText}" FontSize="12"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
</Grid>
<Slider x:Name="SliderReflexionMaxEntries" Minimum="1" Maximum="20" Value="5"
IsSnapToTickEnabled="True" TickFrequency="1"
ValueChanged="SliderReflexionMaxEntries_ValueChanged" Margin="0,0,0,8"/>
<Border Height="1" Background="{DynamicResource BorderColor}" Margin="0,8,0,16"/>
<!-- ═══ 탭 전용 설정 ═══ -->
<TextBlock Text="탭 전용 설정" FontSize="13" FontWeight="SemiBold"
Foreground="{DynamicResource PrimaryText}" Margin="0,0,0,8"/>