Skip to main content
Back to Blog
Engineering

From Upload to Intelligence: Inside the Review Pipeline

PAK4L EngineeringFebruary 5, 20267 min read

When you upload a document and click "Start Review," a sophisticated pipeline kicks into action. Here's what happens in the ~3 minutes between upload and results.

Stage 1: Ingestion (0-5 seconds)

The uploaded file is saved, and text is extracted. For PDFs, we use a multi-strategy approach: first trying direct text extraction, then falling back to OCR for scanned documents. For DOCX files, we preserve structural information (headings, tables) that helps agents understand document hierarchy. Visual elements (tables, charts) are processed separately and appended as structured context.

Stage 2: Classification & Planning (5-15 seconds)

The `DynamicAgentFactory` classifies the document and selects the review panel. This stage also determines the rubric (balanced, quality-focused, or economy mode) and configures agent parameters like temperature and token limits.

python
# The orchestrator plans the review
orchestrator = GenericReviewOrchestrator(
    app_config=config,
    output_language="Italian",
    deep_review=True,
    progress_callback=ws_progress,
    boardroom_callback=ws_boardroom,
)

Stage 3: Batched Agent Execution (15-180 seconds)

This is where the real work happens. Agents are launched in batched waves — typically 4-6 per wave. Each agent receives:

  • The full document text
  • Its specialized system prompt (persona)
  • The response protocol (JSON schema for structured output)
  • RAG context from the user's knowledge base (if available)
  • Reference documents for comparison (if provided)

Every agent returns structured JSON with its findings. The orchestrator uses a hybrid parser that handles both valid JSON and malformed output — because LLMs occasionally break format, and we never want to lose findings.

Stage 4: Synthesis (10-30 seconds)

Once all agents complete, the Coordinator Agent receives the aggregated findings and produces the final report. The coordinator:

  • Deduplicates overlapping findings from different agents
  • Resolves severity disagreements (when two agents rate the same issue differently)
  • Generates the overall quality score (1-10)
  • Produces the executive summary
  • Creates the revised document with tracked changes (redline)

Stage 5: Artifact Generation (5-15 seconds)

The final stage generates downloadable artifacts: a DOCX redline with tracked changes, a PDF report, and the structured JSON data. For DOCX files, we preserve the original formatting and insert changes as native Word tracked changes — so you can open the result in Microsoft Word and use the standard Review tools.

The entire pipeline runs asynchronously. You can close your browser and come back later — the review continues in the background and results are persisted to your dashboard.

Ready to try PAK4L?

Upload a document and see multi-agent review in action.

Get Started Free