[Week2] 그래프에 short-term memory 추가#8
Open
qlqlrh wants to merge 7 commits into
Open
Conversation
OpenAI function calling 모드가 반환하는 JSON 뒤에 trailing characters가 붙어 Pydantic 파싱이 실패하던 케이스 해결.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
도메인 & 이번 주 구현 목표
Week 2 목표
agent ⇄ tools)를 그대로 가져오면서,compile()에 두 줄만 추가해 stateful 시스템으로 전환checkpointer=InMemorySaver()→thread_id별 대화 분리·복원interrupt_before=["tools"]→ 보험 도구 호출 직전 사용자 검토구현 요약
파일 구조
그래프 시각화
agent ⇄ toolsReAct 루프는 1주차와 동일.Tool 3종 (도메인 교체분)
lookup_productlookup_ridersummarize_coveragewith_structured_output(method="json_schema", strict=True)로 반환 스키마 강제실행 제어 패턴
4가지 옵션(
streaming · interrupt · branching · subgraph) 중 interrupt 선택.왜냐하면, 보험 도메인은 "민감한 외부 정보 조회 전 사용자 검토" 가 자연스럽다고 생각함
시나리오 결과 요약
① 같은 thread (
alice-001) — 맥락 누적 (4턴, 맥락 의존 질문 3개+)암 진단비,재진단암,항암치료,암 수술비)을 병렬lookup_rider로 한 번에 호출 후 통합 답변turn 4 는 도구 호출이 4번이지만 한 superstep 으로 묶여서 interrupt 도 한 번만 발동.
② 다른 thread (
bob-001) — 격리 확인alice-001과 똑같은 맥락 의존 질문("방금 말한 조건에서 암보험은 어떤가요?")을 던졌을 때kind="chat", 도구 호출 0회[중요 - 맥락 참조 규칙]이, 모델이 모호한 참조에서 임의로 추정하지 않고 되묻도록 강제③
get_state_history— checkpointer 가 thread 별로 따로 쌓는지alice-001bob-001막힌 점 / 다음 주 개선할 점
method="json_schema", strict=True로 전환해 해결!