Skip to content

[Feat] Coach/Weekly Coach 에이전트 피드백 루프 추가#77

Merged
zweadfx merged 2 commits intomainfrom
feat/feedback-loop
Apr 3, 2026
Merged

[Feat] Coach/Weekly Coach 에이전트 피드백 루프 추가#77
zweadfx merged 2 commits intomainfrom
feat/feedback-loop

Conversation

@zweadfx
Copy link
Copy Markdown
Owner

@zweadfx zweadfx commented Apr 3, 2026

어떤 변경사항인가요?

Coach Agent와 Weekly Coach Agent에 유저 피드백 기반 재생성(refine) 기능을 추가합니다.
이전에 생성된 루틴에 대해 "난이도 낮춰줘", "다른 드릴로 바꿔줘" 같은 피드백을 보내면
LangGraph 조건부 엣지를 통해 RAG 재검색 또는 재생성만 수행하여 수정된 결과를 반환합니다.

작업 상세 내용

  • 피드백 요청 스키마 정의 (SkillRefineRequest, WeeklyRefineRequest)
  • Coach Agent 피드백 루프 그래프 구현 (coach_refine_agent.py)
  • Weekly Coach Agent 피드백 루프 그래프 구현 (weekly_coach_refine_agent.py)
  • refine 엔드포인트 추가 (POST /skill/refine, POST /skill/weekly/refine)

체크리스트

  • self-test를 수행하였는가?
  • 관련 문서나 주석을 업데이트하였는가?
  • 설정한 코딩 컨벤션을 준수하였는가?

관련 이슈

리뷰 포인트

  • classify_feedback 노드에서 gpt-4o-mini로 피드백을 re_retrieve / regenerate_only로 분류하는 방식이 적절한지
  • refine_generate 프롬프트에서 "이전 응답 유지 + 피드백 부분만 수정" 지시가 충분한지
  • 기존 retrieve_drills()를 import해서 재사용하는 구조가 괜찮은지

참고사항 및 스크린샷(선택)

피드백 루프 그래프 구조:

classify_feedback ──조건분기──┬── re_retrieve → refine_generate → END
└─────────────→ refine_generate → END

Summary by CodeRabbit

  • New Features
    • Refine previously generated skill breakdowns using user feedback.
    • Refine previously generated weekly training routines using user feedback.
    • Submit feedback (1–500 characters) to iterate on and improve prior recommendations.
    • Weekly refinement includes a timeout and will return an error if processing exceeds the limit.

@zweadfx zweadfx linked an issue Apr 3, 2026 that may be closed by this pull request
6 tasks
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 331a2ef9-b2db-4291-ad26-67f672be9ae0

📥 Commits

Reviewing files that changed from the base of the PR and between a722c40 and 91e7895.

📒 Files selected for processing (1)
  • src/api/v1/endpoints/skill.py

📝 Walkthrough

Walkthrough

Adds feedback-driven refinement: two POST endpoints (/refine and /weekly/refine) accept previous response + feedback, build initial agent state, and run new LangGraph agents (coach_refine_graph and weekly_coach_refine_graph) to produce validated refined SkillLab or WeeklyRoutine responses.

Changes

Cohort / File(s) Summary
API Endpoints
src/api/v1/endpoints/skill.py
Added POST /refine and POST /weekly/refine endpoints that build initial agent state from original request + previous_response + feedback, invoke respective graphs (background), handle errors, and validate final_response types.
Request Schemas
src/models/refine_schema.py
New SkillRefineRequest and WeeklyRefineRequest models wrapping original_request, previous_response, and required feedback (1–500 chars).
Coach Refine Agent
src/services/agents/coach_refine_agent.py
New LangGraph workflow coach_refine_graph with classify_feedback, conditional re_retrieve (re-run retrieval) or refine_generate nodes; uses LLMs for classification and JSON regeneration, validates against SkillBreakdownCard.
Weekly Coach Refine Agent
src/services/agents/weekly_coach_refine_agent.py
New LangGraph workflow weekly_coach_refine_graph with feedback classification, optional re_retrieve, per-day context aggregation, LLM-based JSON generation validated as WeeklyRoutineResponse.
Shared retrieval integration
src/services/agents/...retrieve_drills*
Refine agents call existing retrieve_drills to refresh drill context when classification returns re_retrieve.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API as /refine Endpoint
    participant Agent as coach_refine_graph
    participant LLM1 as OpenAI (gpt-4o-mini)
    participant Retriever as retrieve_drills
    participant LLM2 as OpenAI (gpt-4o)
    Client->>API: POST /refine (original_request + previous_response + feedback)
    API->>Agent: invoke graph with initial_state
    Agent->>LLM1: classify_feedback (re_retrieve | regenerate_only)
    LLM1-->>Agent: feedback_type
    alt feedback_type == "re_retrieve"
        Agent->>Retriever: re_retrieve (update context)
        Retriever-->>Agent: updated context
    end
    Agent->>LLM2: refine_generate (profile + previous_response + feedback + context)
    LLM2-->>Agent: refined JSON
    Agent->>Agent: validate JSON -> final_response
    Agent-->>API: final_response
    API->>Client: SuccessResponse[SkillLabResponse]
Loading
sequenceDiagram
    participant Client
    participant API as /weekly/refine Endpoint
    participant Agent as weekly_coach_refine_graph
    participant LLM1 as OpenAI (gpt-4o-mini)
    participant Retriever as retrieve_drills
    participant LLM2 as OpenAI (gpt-4o)
    Client->>API: POST /weekly/refine (original_request + previous_response + feedback)
    API->>Agent: invoke graph with initial_state (week_plan from previous_response.days)
    Agent->>LLM1: classify_feedback (re_retrieve | regenerate_only)
    LLM1-->>Agent: feedback_type
    alt feedback_type == "re_retrieve"
        Agent->>Retriever: re_retrieve (per-day drill retrieval)
        Retriever-->>Agent: updated per-day context
    end
    Agent->>Agent: refine_generate (aggregate per-day context + available_time)
    Agent->>LLM2: prompt for WeeklyRoutineResponse JSON
    LLM2-->>Agent: refined weekly routine JSON
    Agent->>Agent: validate JSON -> final_response
    Agent-->>API: final_response
    API->>Client: SuccessResponse[WeeklyRoutineResponse]
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I nibble on feedback, bright and keen,

Reclassify, retrieve, then tweak the routine,
LLM whispers, drills rearranged,
Weekly and skillful, outputs exchanged,
Hooray — refined routines hop into the green!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements all core coding requirements from issue #76: feedback loop schemas (SkillRefineRequest, WeeklyRefineRequest), agent graphs with conditional routing (classify_feedback → re_retrieve/refine_generate), and new endpoints (/refine, /weekly/refine). However, the maximum regeneration limit to prevent infinite loops is not evident. Add implementation of maximum regeneration/refinement attempt counter and logic to prevent infinite refinement loops as specified in issue #76.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title in Korean clearly describes the main addition of feedback loops to Coach and Weekly Coach agents, which matches the implementation changes.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the feedback loop feature. New files (refine_schema.py, coach_refine_agent.py, weekly_coach_refine_agent.py) and modified skill.py endpoint are all in scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/feedback-loop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zweadfx zweadfx changed the title feat: Coach/Weekly Coach 에이전트 피드백 루프 추가 (#76) [Feat] Coach/Weekly Coach 에이전트 피드백 루프 추가 Apr 3, 2026
@zweadfx zweadfx self-assigned this Apr 3, 2026
@zweadfx zweadfx added the feature 새로운 기능 구현 시 사용합니다. label Apr 3, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/api/v1/endpoints/skill.py`:
- Around line 205-210: In the except asyncio.TimeoutError handler, suppress the
original exception chain by re-raising the HTTPException with "from None" so the
traceback doesn't include the TimeoutError; update the raise HTTPException(...)
in the block that catches asyncio.TimeoutError (the endpoint's timeout handler)
to use "raise HTTPException(... ) from None" referencing asyncio.TimeoutError
and HTTPException to locate the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2570895b-4f47-4631-8e89-7932c85464ca

📥 Commits

Reviewing files that changed from the base of the PR and between c4fb6bc and a722c40.

📒 Files selected for processing (4)
  • src/api/v1/endpoints/skill.py
  • src/models/refine_schema.py
  • src/services/agents/coach_refine_agent.py
  • src/services/agents/weekly_coach_refine_agent.py

@zweadfx zweadfx merged commit 0d87456 into main Apr 3, 2026
2 checks passed
@zweadfx zweadfx deleted the feat/feedback-loop branch April 3, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 새로운 기능 구현 시 사용합니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Coach/Weekly Coach 에이전트에 피드백 루프 추가

1 participant