fix(routing): stop vision_team reviewer↔analyst infinite loop#20
Merged
Conversation
Playwright UI smoke (V-B/V-C scenarios on /chat) showed vision_team
routing was correct but the response never terminated: reviewer kept
critiquing "text not transcribed" or "chart labels unreadable", the team
supervisor kept re-dispatching vision_analyst, and no safeguard ever
fired. Two missing pieces, both lifted into this PR:
1. `apps/backend/workflow/teams/vision.py` was building its graph with
`with_validator=True` but did not pass `max_team_dispatches`, so
`enforce_dispatch_limit` was never armed for the vision layer.
Every other team already wires this from settings — vision was the
odd one out. Added `settings.VISION_TEAM_MAX_DISPATCHES = 3`
(single-worker team, two attempts is plenty).
2. `REVIEWER_PROMPT` (v1.2 → v1.3) had stopping rules only for the Data
Science team. The reviewer had no policy telling it that:
- "확인 불가" / "판독 불가" markers from vision_analyst are
legitimate complete answers (the model literally cannot resolve
sub-pixel text);
- "describe / 해석해줘" requests do NOT imply OCR-grade transcription
(only "그대로", "verbatim", etc. do);
- repeating the same critique twice is a loop, not progress;
- identifying chart TYPE + giving qualitative insight on visible
magnitudes is enough for a chart-interpretation request;
- after two vision_analyst attempts mark VALID regardless.
- tests/test_team_subgraphs.py: extended the parametrized
`test_team_graphs_use_configured_dispatch_limits` to cover vision_team
— pins the wiring from `settings.VISION_TEAM_MAX_DISPATCHES` into the
builder.
- tests/test_routing_prompts.py: new
`test_reviewer_prompt_contains_vision_stopping_rules` locks the five
escape hatches so prompt drift can't silently bring the loop back.
Validation:
- pytest tests -q → 193 passed (191 baseline + 2 new regression locks).
Plans / context:
- The V-B / V-C reproduction is in this session's Playwright run; goal
follow-up will rerun the three scenarios against the merged main.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Playwright UI smoke on `/chat` revealed that vision_team routing worked correctly (head → vision_team → vision_analyst) but the response never terminated: reviewer kept critiquing "text not transcribed" / "labels unreadable" and the team supervisor kept re-dispatching vision_analyst with no safeguard ever firing. Two missing pieces, both fixed here.
Root causes
Fix
Regression locks
Test plan
🤖 Generated with Claude Code