Agent Parser Conversation Summary Short Circuit
Use this skill when conversation summary behavior feels slow or misleading for short conversations.
Typical symptoms:
- the UI spins on
대화요약생성중...for a long time and then says summary is unavailable - the backend says fewer than 3 user messages only after a slow request
- auto-triggered conversation summary generation still runs heavy context collection for short threads
- the frontend treats an empty summary as pending instead of a terminal "not eligible" state
Core Rule
Eligibility must be decided before expensive summary preparation starts.
- first compute a lightweight turn count
- only collect full summary inputs when the minimum user-turn threshold is met
- return an explicit terminal status such as
insufficient_user_messagesfor non-eligible conversations
Do not solve this with longer timeouts, extra retries, or ad hoc UI exceptions.
Root Cause Pattern
The common failure mode is split responsibility across backend and frontend:
- backend performs heavy context loading before checking minimum user turns
- backend returns
""for both "not generated yet" and "cannot generate" - frontend interprets
""as pending and keeps retrying
That creates slow requests, wasted model/context work, and a misleading loading state.
Canonical Fix Pattern
Introduce a two-step summary pipeline:
- lightweight eligibility check
- expensive summary preparation only for eligible conversations
Recommended backend structure:
get_conversation_turn_counts(conversation_id)_prepare_conversation_summary_generation(conversation_id, prompt_hint=None)
Expected behavior:
- if
user_message_count < minimum, immediately return:status: insufficient_user_messagessummary: ""user_message_countassistant_message_count
- if generation is in progress, return:
status: pendingsummary: 요약중...
- only schedule background generation after eligibility succeeds
Backend Targets
Inspect and align these paths:
app/services/conversation_context.pyapp/routers/analyze.pyapp/routers/deps.py
Requirements:
- GET summary endpoint must distinguish
pendingvsinsufficient_user_messages - manual refresh endpoint must short-circuit the same way
- auto-trigger path must use the same eligibility helper, not a separate heavy path
Frontend Targets
Inspect and align these paths:
dashboard/src/lib/api.tsdashboard/src/pages/ThreatStreamV2Page.tsx
Requirements:
- summary fetch type must include
status - retry loop must continue only for
pending insufficient_user_messagesmust stop loading immediately- manual refresh should stop instantly when the backend reports non-eligible status
- empty string alone must not be treated as proof of pending generation
Validation Checklist
After the patch:
- run Python compile checks for summary-related backend files
- build the dashboard
- verify a short conversation returns
insufficient_user_messageswithout long delay - verify the UI stops retrying for that status
- verify an eligible conversation still returns
pendingfirst and later resolves to a real summary
Output Contract
Return:
- the single root-cause category
- where eligibility was being checked too late
- how backend and frontend status semantics were unified
- what was validated in runtime or build checks