DEV Community

Eni Agunbiade
Eni Agunbiade

Posted on

Building LexAegis: How Qwen 3.8 Max Powers an Evidence-Backed Legal AI Assistant on Monad

Building LexAegis: How Qwen 3.8 Max Powers an Evidence-Backed Legal AI Assistant on Monad
Building AI that helps professionals make decisions is one challenge. Building AI whose evidence, limitations and human approvals can be inspected is another.
For the Monad Metropolis hackathon, I built LexAegis, an AI-assisted legal workspace that combines Qwen 3.8 Max, encrypted document storage, human-controlled review and blockchain-based Proof of Review.
The goal is straightforward:
AI proposes. Humans decide. Monad records. Anyone can verify.
In this article, I'll explain how Qwen powers LexAegis, how we prevent the model from making decisions it shouldn't, and what we've actually tested.

  1. The problem: AI answers are not enough Imagine an employment solicitor reviewing a settlement agreement. The agreement contains payment provisions, confidentiality obligations, references to missing schedules and requirements relating to independent legal advice. An AI assistant could summarise the agreement quickly. But a lawyer needs more than a confident summary. They need to know:
  2. Which document supports each conclusion?
  3. Are important schedules or supporting documents missing?
  4. Do the financial figures reconcile?
  5. What remains uncertain?
  6. Has a human actually reviewed and approved the result? Without those answers, AI can accelerate reading while making the overall review process harder to audit. LexAegis addresses this problem by separating AI-assisted analysis from evidence verification and human approval.
  7. Why we chose Qwen 3.8 Max Qwen 3.8 Max serves as the reasoning and language component of Aegis, the LexAegis assistant. We integrated the model through Alibaba Cloud's compatible-mode API, using structured JSON output and native tool calling. Rather than asking Qwen to generate an unrestricted legal opinion, LexAegis gives it a constrained workflow. Qwen can help:
  8. Explain legal clauses in accessible language.
  9. Identify potential contractual risks.
  10. Highlight missing supporting evidence.
  11. Interpret deterministic financial checks.
  12. Summarise selected evidence.
  13. Suggest questions and next steps for the reviewer. Crucially, the model is not responsible for deciding whether a settlement is legally valid. Qwen assists the reviewer; it doesn't replace the reviewer.
  14. Giving Qwen tools instead of unrestricted authority LexAegis implements four read-only assistant tools: read_sources Retrieves the evidence excerpts made available to the model, allowing its response to reference actual source material. check_payments Uses deterministic application code to examine payment figures. The calculations use integer representations of GBP pence rather than relying on the language model to perform arithmetic. check_evidence Examines available evidence information and identifies gaps relevant to the review. get_status Retrieves permitted application or review status information. Qwen can request these tools, but the application validates the arguments and controls execution. Tool requests are subject to limits on execution time, provider attempts and tool usage. The model cannot use these tools to sign agreements, approve documents, alter confirmed facts or execute blockchain transactions. This separation matters because a model's ability to recommend an action is not authority to perform it.
  15. A real Qwen test: detecting a £2,000 discrepancy We tested the integration against a fictional employment settlement fixture. The synthetic agreement contained: Item Amount Stated settlement total £24,000 First instalment £10,000 Second instalment £12,000 Sum of instalments £22,000 Unexplained difference £2,000

During the recorded live-provider test, Qwen requested the available tools and incorporated their results into its response.
The deterministic payment checker identified:

  • Stated total: 2,400,000 pence.
  • Instalment sum: 2,200,000 pence.
  • Difference: 200,000 pence. The model also received evidence-gap information, including the absence of linked evidence relating to independent advice. The final response contained source-linked explanations rather than unsupported assertions. This demonstrates an important design principle: Use the language model for interpretation. Use deterministic code for calculations and verification. The example is synthetic, and the test does not establish legal correctness or reliability across real client matters. The underlying test evidence is available in our GitHub repository.
  • Building a conversational legal workspace Our initial interface required users to select document passages before requesting an AI explanation. That offered tight evidence control, but it was cumbersome for ordinary conversations. We subsequently introduced a matter-aware Command Centre. Instead of highlighting every passage, the intended workflow is: Open a matter → Ask Aegis → Review the evidence-backed response. For example, a lawyer can ask: Analyse this employment settlement matter. Identify the main risks, missing evidence and recommended next steps.

LexAegis automatically retrieves relevant excerpts from the currently open matter's verified documents.
The request is bounded: it uses a limited evidence selection, not unrestricted access to every document.
The disclosure preview identifies the scope of the material being shared. The model is instructed to acknowledge incomplete coverage rather than claim to have reviewed an entire case file.
Lawyers can still use the dedicated Review interface to examine individual passages.
The conversational Command Centre was deployed to Railway on 13 October 2026. The new retrieval workflow has automated test coverage, while its behaviour with real-world legal matters requires further validation.

  1. Privacy: the user controls what Qwen receives LexAegis uses a client-side encrypted Vault for document storage. The AI integration follows an explicit disclosure process. Before material is sent to Qwen, the application prepares a request and allows the user to review the information that will leave the browser. Only the authorised excerpts and permitted context are included. The application also verifies source material against its stored document references. This creates an important boundary between private documents and external AI processing. However, this is not end-to-end encryption through model inference. Information disclosed to Qwen must be readable by the model provider. LexAegis does not independently establish the provider's retention or training policies. The application therefore makes disclosure an explicit user decision rather than disguising external processing.
  2. Making AI conclusions traceable One of our most important architectural decisions was to validate evidence citations. When Qwen receives source material, the application associates it with reference handles. The model can cite those handles in its output. LexAegis checks that cited references correspond to evidence actually made available during the run. This helps prevent fabricated source references from appearing as genuine citations. It doesn't guarantee that every interpretation is correct. It does provide a stronger foundation for human review: the lawyer can inspect the underlying text instead of accepting an unsupported answer.
  3. Connecting AI-assisted work to Monad LexAegis also implements a Proof of Review workflow. The idea is to make a human-approved review package independently verifiable. The process separates three responsibilities: Qwen: Assists with analysis and explanation. The lawyer: Reviews evidence, makes decisions and authorises the approved package. Monad: Records a cryptographic commitment associated with the review. Our ProofOfReviewRegistry smart contract is deployed on Monad Testnet. Contract address: 0x453bfd1602d8a8666f55bf9a8d87b127cb94048f Chain ID: 10143 An independent verifier can check supported review packages against the associated on-chain records. Importantly, a blockchain receipt proves that a particular commitment was recorded. It does not prove that the underlying legal advice was correct or that the reviewer possessed particular professional qualifications. Qwen cannot independently authorise an approval or submit a transaction.
  4. What we actually validated Our recorded Qwen integration testing included:
  5. Genuine requests to the configured Qwen 3.8 Max provider.
  6. Native tool calling.
  7. Structured output validation.
  8. Read-only tool execution.
  9. Source-reference validation.
  10. Detection of a synthetic payment discrepancy.
  11. Provider capability verification.
  12. Cancellation behaviour. The recorded smoke test contains six provider request identifiers. We also tested cancellation during a provider interaction. A cancelled request did not continue executing local tools, although cancellation cannot retract information already transmitted to the provider. The application has since been deployed, and a real Qwen explanation was observed through the production Review interface using a synthetic employment settlement document. These results demonstrate a functioning integration, not comprehensive testing of legal reasoning accuracy.
  13. Why Qwen matters to LexAegis Without Qwen, LexAegis would still have its encrypted Vault, deterministic checks, approval workflow and blockchain registry. But it would lack an accessible way for a lawyer to explore complex document evidence conversationally. Qwen provides the language understanding and reasoning interface that connects those systems. A user can ask a question in ordinary language and receive an explanation informed by the evidence and tools made available to the model. The value isn't simply faster summarisation. It's making evidence-backed professional review more accessible, understandable and efficient while keeping consequential decisions under human control. That's the role we believe AI should play in high-stakes professional workflows.
  14. Try LexAegis Live application: https://terrific-joy-production-54e8.up.railway.app Independent verifier: https://lexaegis-verifier-production.up.railway.app Source code: https://github.com/ejasuave/LexAegis Monad Testnet registry: 0x453bfd1602d8a8666f55bf9a8d87b127cb94048f LexAegis is a hackathon prototype. Its legal analysis must be independently assessed by qualified professionals before any real-world reliance. Our next steps include improving matter-wide evidence coverage, expanding testing and strengthening the experience of reviewing and verifying AI-assisted professional work. Final thoughts The future of professional AI isn't just about generating better answers. It's also about being able to explain where those answers came from, what the model was allowed to do and who ultimately accepted responsibility for the result. With LexAegis, we're exploring that future using Qwen 3.8 Max for evidence-assisted reasoning and Monad for independently verifiable Proof of Review. AI proposes. Humans decide. Monad records. Anyone can verify.

Top comments (0)