Skip to content

fix(supervisor): multi-turn follow-up turn handoff + savefig nesting#14

Merged
DONGRYEOLLEE1 merged 1 commit into
mainfrom
fix/multi-turn-follow-up-routing
May 22, 2026
Merged

fix(supervisor): multi-turn follow-up turn handoff + savefig nesting#14
DONGRYEOLLEE1 merged 1 commit into
mainfrom
fix/multi-turn-follow-up-routing

Conversation

@DONGRYEOLLEE1
Copy link
Copy Markdown
Owner

Summary

S-G 시나리오(같은 thread 2번째 메시지 동일 csv 재사용 차트 추가) 실패의 4가지 원인을 일괄 fix.

Fixes

  1. LLMRouter retry + JSON salvage (plan §4.0.5) — parse_failed 즉시 종료를 1회 retry + ValidationError 메시지의 raw JSON 복원
  2. head_supervisor _max_same_team_streak current-turn only 슬라이싱 — multi-turn redirect 5/2 false positive 차단
  3. team_supervisor dispatch_count current-turn only 재계산 — follow-up turn 첫 worker도 6/5 hit하던 회귀 해소
  4. worker history note prev/current turn 분리 + head 결정에 status="completed" (finalizer 경로 포함) → boundary 신호 명확
  5. matplotlib savefig nesting_plt._orchagent_real_savefig에 진짜 savefig 1회 보존, fresh wrap

Verification

  • pytest 316 → 319 PASS (retry+salvage 단위 테스트 +3)
  • E2E S-G turn 1: region별_revenue_합계_막대차트.png
  • E2E S-G turn 2: product별_units_sold_합계_막대차트.png
  • 회귀 0

🤖 Generated with Claude Code

S-G 시나리오(같은 thread 2번째 메시지에서 동일 csv 재사용 차트 추가) 실패
원인 4건을 한 묶음으로 fix.

1) LLMRouter parse-failure 1회 retry + raw error JSON salvage (plan §4.0.5)
   - decide_route가 첫 호출 ValueError 시 즉시 fallback FINISH로 종료하던
     문제. 1회 재시도 + 그래도 실패 시 ValidationError 메시지에 박힌
     RouterDecision JSON 추출하여 복원. test_llm_router.py +2 cases.

2) head supervisor _max_same_team_streak를 current-turn-only로 필터
   - 멀티 turn에서 누적된 head→team 카운트로 인해 turn 2 첫 호출부터
     redirect 5/2 safeguard 발동. route_history를 가장 최근 head
     status="completed" 이후로 슬라이스.

3) team supervisor dispatch count도 current-turn 재계산
   - shared_context의 _dispatch_count는 turn 누적 → follow-up turn에서
     첫 worker 호출도 6/5 ceiling hit. route_history 슬라이스로 재계산.

4) team worker history note를 prev/current turn 분리 + finalizer
   경유 head도 turn 종료로 status="completed" 마킹
   - "이전 turn은 이미 완료" + "이번 turn은 아직 미시작" 컨텍스트를
     team supervisor LLM에 명확히 전달. finalizer 경로도 route entry
     status="completed"로 boundary 신호.

5) matplotlib savefig monkey-patch nesting 차단
   - matplotlib.pyplot은 process-wide singleton이라 매 turn 새 wrapper가
     이전 wrapper 위에 nesting되어 stale artifact_dir로 path rewriting.
     _plt._orchagent_real_savefig에 진짜 savefig를 1회 보존하고 매 turn
     그 reference로 fresh wrap.

E2E (dong, playwright) S-G:
- turn 1: region별_revenue_합계_막대차트.png ✅
- turn 2: product별_units_sold_합계_막대차트.png ✅ (같은 csv 재사용)

pytest 316 → 319 PASS (+3 retry/salvage tests), 회귀 0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
orchagent Ready Ready Preview, Comment May 22, 2026 4:37am
project-vdajw Ready Ready Preview, Comment May 22, 2026 4:37am

@DONGRYEOLLEE1 DONGRYEOLLEE1 merged commit d3ddf77 into main May 22, 2026
5 checks passed
@DONGRYEOLLEE1 DONGRYEOLLEE1 deleted the fix/multi-turn-follow-up-routing branch May 22, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant