modcomms/backend/app/agents/base_agent.py
michael 3a5c3bcde3 Implement revision-aware proof analysis pipeline
When a subsequent revision of a proof is uploaded, the analysis now takes
place in context of the previous version's results. The system identifies:
- Resolved issues: fixed in the new revision
- Outstanding issues: still present from previous version
- New issues: introduced in the new revision

Key changes:
- Add resolvedIssues, outstandingIssues, newIssues fields to SubReview
- Add PreviousReviewContext model for passing previous review data
- Update all specialist agents to accept previous_review context
- Extend GeminiService with include_revision_fields parameter
- Add get_latest_version_review() repository method
- Update LeadAgent to synthesize cross-version context in summary
- Fetch previous analysis in WebSocket handler for revisions

First version analysis continues to work exactly as before with revision
fields set to null.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:04:16 -06:00

33 lines
1.1 KiB
Python
Executable file

from abc import ABC, abstractmethod
from typing import 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,
) -> 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