arXiv:2610.27347cs.AIOct 2026

Manuscript Offprint

arXiv:2610.27347

An LLM-Based Agent for Legal Compliance Assessment: Architecture, Memory, and Evaluation in a Canadian and Quebec Context

Soukaina Alaoui Ismaili, Jean-Sebastien Dessureault

Abstract

Checking whether a text complies with a body of law is slow when done by hand and fragile when done with keyword rules. This paper presents ComplianceAgent, the legal compliance sub-agent of COMPASS, a multi-agent framework that evaluates texts along four axes: digital sovereignty, carbon impact, compliance, and ethics. The agent relies on a large language model that scores a text on a fixed rubric, grounds its judgment in a reference legal corpus, and, when the score falls at or below a critical threshold, runs a corrective chain made of self-healing rewrites, a compliance label, an explainability report, and escalation to a human reviewer. We describe what the language model does at each step, how the memory of the agent is organized, and how the same implementation can be pointed at different reference corpora. We evaluate the agent in a Canadian and Quebec context, on a corpus of thirteen legal instruments that brings together federal and provincial texts, international treaties, and municipal documents of the City of Trois-Rivières. The evaluation relies on a hand-annotated gold standard of fifteen texts and combines classification metrics, a repeated-query stability test, retrieval precision, and a composite score. On this gold standard the agent separates every conforming text from every non-conforming one, its scores remain stable under repeated queries, and the index returns relevant passages.

Keywords: legal compliance, large language models, agent memory, AI governance, Canadian and Quebec law, evaluation.

1 Introduction

Organizations that build or deploy automated systems are increasingly asked to show that their practices respect the rules that apply to them. In Canada and Quebec these rules come from several levels at once: federal statutes such as the Personal Information Protection and Electronic Documents Act [Government of Canada, 2000], provincial statutes such as Quebec's Law 25 [Gouvernement du Québec, 2021], municipal policies and by-laws, and the international treaties that frame them. Voluntary frameworks such as the NIST AI Risk Management Framework [National Institute of Standards and Technology, 2023] and management system standards such as ISO/IEC 42001 [International Organization for Standardization, 2023] add further expectations. All of this turns into documents, statements, and policies that someone has to read and judge. Doing so by hand does not scale with the volume of text, and rule-based checkers break as soon as a statement does not match a fixed pattern. A language model that can read a statement in context and compare it with the relevant provisions offers a practical middle path, provided that its judgment can be tied to the source text and explained to a human reader.

Using a language model in this role raises questions that are rarely answered together. What exactly does the model decide, and what is left to the surrounding code? What does the system remember, and what does it retrieve at the moment of judgment? How should its output be evaluated when no accepted benchmark exists for the legal context of interest? Work on legal language processing tends to evaluate models on reasoning tasks, and work on language agents tends to describe memory and refinement loops in general terms. An agent that scores, corrects, explains, and escalates over a given legal corpus is seldom documented in enough detail to be reproduced and criticized. We organize the study around three research questions. The first concerns design: how can the roles of the model, of retrieval, and of memory be organized in a compliance agent so that each can be described and tested? The second concerns performance: how well does the agent separate conforming from non-conforming texts in a Canadian and Quebec legal corpus, and how stable are its scores? The third concerns evidence: what can a small evaluation made by a single annotator actually support?

This paper describes ComplianceAgent, the compliance sub-agent (COM) of COMPASS, a research framework [Dessureault et al., 2026] that evaluates a text along four independent axes: digital sovereignty (SOV), carbon impact (CAR), regulatory compliance (COM), and ethics (ETH). Each axis is handled by a dedicated sub-agent built on a shared base class, and an orchestrator sends a text to the relevant sub-agents, either on explicit request or through a filter that is itself a language model call. The work reported here concerns the compliance axis only. The other sub-agents are developed by other members of the project and fall outside the scope of this paper.

The agent is configurable by domain, which means that the reference corpus is a parameter and not a path written into the code. In this study it is pointed at a corpus of thirteen Canadian, Quebec, municipal, and international legal instruments. This paper makes three contributions. First, we document the architecture precisely enough for a reader to know what the language model does, what each kind of memory holds, and what the retrieval step does and does not contribute. Second, we define the evaluation metrics mathematically and apply them to a hand-annotated gold standard. Third, we report what the evaluation shows and, just as importantly, what it cannot show given its size and design.

The rest of the paper follows the usual structure of a scientific article. Section 2 reviews the state of the art. Section 3 presents the methodology, namely the architecture of the agent, the language model and its prompts, the data, and the evaluation protocol and metrics. Section 4 reports the results. Section 5 discusses them, with their limits and the perspectives they open, and Section 6 concludes.