Skip to content

[Week 1] StateGraph를 활용하여 알고리즘 도메인 특화 ReAct Agent 설계 및 구현#1

Open
pykido wants to merge 3 commits into
mainfrom
pykido/week1-react-graph
Open

[Week 1] StateGraph를 활용하여 알고리즘 도메인 특화 ReAct Agent 설계 및 구현#1
pykido wants to merge 3 commits into
mainfrom
pykido/week1-react-graph

Conversation

@pykido
Copy link
Copy Markdown
Collaborator

@pykido pykido commented May 5, 2026

도메인 / 목표

  • 도메인 : 알고리즘 학습 / 코딩 테스트 준비
  • create_agent 같은 helper 없이 StateGraph 로 직접 ReAct loop 구성하였습니다.
  • 코테 준비의 3가지 use case (개념 / 추천 / 리뷰) 를 도구 3개에 1:1 매핑한 학습 코치 에이전트를 만들었습니다.

그래프 흐름 (노드/엣지)

flowchart TD
    START([START]) --> agent
    agent -->|tool_calls| tools[tools / ToolNode]
    agent -->|tools_condition: END→remap| format_answer[format_answer / with_structured_output]
    tools --> agent
    format_answer --> END([END])
Loading
  • agentbind_tools 된 LLM, 도구 호출 여부 결정
  • tools — 강의 06번대로 langgraph.prebuilt.ToolNode
  • 분기 — tools_conditionEND 출구를 path_map 으로 format_answer 에 remap
  • format_answerwith_structured_output(ReActAnswer) 로 Pydantic 정규화
  • State — class AgentState(MessagesState): final_answer: Optional[ReActAnswer] (강의 04번 패턴)

도구

도구 용도
get_algorithm_pattern(name) 패턴 설명/시간복잡도/템플릿/실수
recommend_problems(topic, level, problem_id) 프로그래머스 문제 추천/조회
review_solution(problem_id, user_code) 풀이 리뷰용 reference rubric
  • review_solution 은 코드를 직접 채점하지 않고 rubric 만 반환한 뒤, LLM 이 user_code vs rubric 비교 (RAG 의 retrieval+generation 분리 결)

  • 응답 스키마: Pydantic ReActAnswer(answer, used_tools, sources, confidence)

테스트 4개 (노트북에 출력 박혀 있음)

# 질문 호출 도구 결과
1 이분 탐색 패턴 정리 get_algorithm_pattern 템플릿 + 실수 정리, confidence 0.9
2 Lv.3 binary-search 추천 recommend_problems(topic, level) pgs-43238 입국심사
3 TLE 나는 brute-force 코드 리뷰 review_solution O(max_t × M) 원인 진단 → 이분 탐색 O(M log(...)) 정답 코드 제시
4 패턴 + 추천 다단계 get_algorithm_pattern + recommend_problems 병렬 슬라이딩 윈도우 설명 + pgs-67258 보석 쇼핑 통합

@pykido pykido requested a review from myeolinmalchi May 5, 2026 06:38
@pykido pykido self-assigned this May 5, 2026
Copy link
Copy Markdown
Member

@myeolinmalchi myeolinmalchi left a comment

Choose a reason for hiding this comment

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

태윤님 너무 잘 봤습니다!

ipynb로 작성해주신건 좋은데, 나중에 고도화를 하기 위해선
파이썬 모듈로 작성을 해주시면 좋을 것 같아요

공식 문서 참고하셔서 폴더 구조 러프하게 세팅해서 커밋해주시면 감사하겠습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants