Legislative drafting with LangChain and Claude

LangChain Claude API RAG Agentic AI

Problem

Drafting legislation is slow, specialist work. Bills have to follow Office of the Parliamentary Counsel (OPC) conventions, sit consistently with existing statute, and come with explanatory notes that a non-lawyer can actually read. The hackathon challenge from government was to cut that cycle time without pretending a model could replace parliamentary counsel.

The useful product is not “an LLM that writes an Act”. It is a drafting assistant that proposes text, shows its sources, and keeps a human in the loop for legal and ethical review.

Architecture

The prototype was a LangChain application with Claude as the generation model:

That is a small agentic system: tools and retrieval, a staged workflow, and an accountable human decision at the points that matter. It is not a fully autonomous drafter, and it was not designed to be one.

Approach

The work was done over three days at Imperial College London in April 2024, at the generative AI hackathon run with Evidence House, a No.10 initiative. Teams mixed civil servants with students and were asked to build against live government problems. Legislation was one of the problem tracks; ours focused on reducing the time to a first defensible draft.

We biased the system toward citation and review rather than fluency. A fluent clause that cannot be tied back to OPC guidance or existing law is a liability in this domain. The demo path was: policy intent in, structured draft plus notes out, with the retrieved sources visible.

Result

The team placed third nationally. Imperial’s write-up of the event described the third-place tool, Legis-maker, as using existing legislation and OPC guidelines to suggest legislative text or explanatory notes, with embedded ethical checks through a human-in-the-loop process. Winning teams were invited to present to senior officials in Downing Street.

For a portfolio this is the project that speaks directly to agentic AI engineering: retrieval, tool use, staged agents, and a domain where hallucination is not a UX issue but a governance one.

Imperial College news: Imperial and civil servants join forces on AI for government challenges

← Back to home