modcomms/backend/app/agents/base_agent.py
Vadym Samoilenko efa6e772e0 Add toast notification when primary Gemini model falls back to backup
Backend: thread on_fallback callback through analysis chain
(gemini_service → agents → analysis_service → handlers). The handler
sends a 'model_fallback' WebSocket message exactly once per analysis
when the primary model is unavailable.

Frontend: handle 'model_fallback' WS message and show a dismissible
yellow toast at the bottom of the screen with an 8-second auto-dismiss.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 13:00:12 +00:00

34 lines
1.2 KiB
Python
Executable file

from abc import ABC, abstractmethod
from typing import Awaitable, Callable, List, Optional, Tuple
from app.models.schemas import PreviousReviewContext, SubReview
class BaseAgent(ABC):
"""Abstract base class for all review agents."""
name: str = "Base Agent"
@abstractmethod
async def analyze(
self,
images: List[Tuple[bytes, str]],
previous_review: Optional[PreviousReviewContext] = None,
on_fallback: Optional[Callable[[], Awaitable[None]]] = None,
) -> SubReview:
"""
Analyze the proof and return a SubReview.
Args:
images: List of (file_data, mime_type) tuples representing the proof.
For single images/videos, this will contain one tuple.
For multi-page PDFs, this will contain one tuple per page.
previous_review: Optional context from the previous version's review
for revision-aware analysis.
Returns:
SubReview containing ragStatus, feedback, and issues.
When previous_review is provided, also includes resolvedIssues,
outstandingIssues, and newIssues.
"""
pass