A Multi-Agent Legal Research Workflow
Summary
Discovery, analysis, verification, and the report share one typed state and can resume after a stop.
Companion code: 08-multi-agent in indian-legal-ai-lab.
Previous: Part 7: Agentic RAG and Precedent Research
Discovery, reading, citation checks, and the report are different jobs. They share one `ResearchState` so a stopped run can continue from the stage it reached.
The state is the handoff
`ResearchState` holds the question, discovered passages, analysis lines, verification notes, the report, and a stage string. Stages used by the code are `new`, `discover`, `analyze`, `verify`, `report`, `insufficient`, `refused`, and `completed`.
`ResearchWorkflow.RunAsync` does not restart work that is already done:
- `DiscoverIfNeeded` runs only when the stage is `new` or `discover`.
- `AnalyzeIfNeeded` runs only for `analyze`.
- `VerifyIfNeeded` runs only for `verify`.
- `WriteIfNeeded` runs only for `report`, then sets `completed`.
`JudgmentAnalysis` groups passages by case id, takes three cases, and describes them in parallel with `Task.WhenAll`. Each line is `{caseId} ({citation}) has {count} retrieved passage(s). Synthetic={flag}.`
`ResearchReportWriter.Write` fills question, cases, findings, evidence, one competing-interpretation sentence, limitations, references, and `HumanReview`. The limitations say the corpus is small, metadata-only judgments have no full text, citation links are string matches, and the product is not legal advice. `Empty` is the report used for a refusal or for insufficient evidence.
dotnet run --project labs/08-multi-agent`Article 19 speech Romesh Thappar` ends at stage `completed` and prints a verification line per retrieved chunk. The four roles are stages in one process. They are not four model conversations.
Next
Part 9: Event-Driven Judgment Ingestion
Verified in this revision
The stages are still `new`, `discover`, `analyze`, `verify`, `report`, `insufficient`, `refused`, and `completed`. The API passes the request cancellation token only as `ThrowIfCancellationRequested` before `RunAsync`. The workflow method itself does not take a token.
More in Applied AI
Agentic RAG and Precedent Research
Decompose a privacy question, keep a human-review flag, and do not treat a citation string as an overruling.
Event-Driven Judgment Ingestion
A local queue retries extraction, dead-letters repeated failures, and skips a job id that already completed.
LLM Fundamentals in C#
A supplied judgment can be summarized only from passages you pass in. The same client, with no passage, names a citation that the catalog rejects.