How to Build a Legal‑Citation Checker Shadow Persona
Video Guide
In the world of LLM‑driven tools, Msty Studio's Shadow Persona is a customizable “assistant” that runs in the background, monitoring the main chat, picking out useful information, and provides it's own responses based on the directives you assign.
In this post we’ll walk through how to create a Shadow Persona that automatically validates court citations in the conversation by using the CourtListener API - all from scratch and all inside Msty Studio, with no external orchestration needed outside of getting your own CourtListener API key.
Why this matters?
Lawyers, paralegals, and anyone who works with legal text often trust the model’s output at face value. But models can hallucinate or mis‑cite cases. A verification step gives that extra layer of confidence, especially when the output is fed into downstream legal workflows.
Before You Start
Prior to jumping in, there are a few things you'll need and have ready to go.
What you need:
- Msty Studio Aurum plan - which unlocks Shadow Personas and Live‑Contexts
- A good LLM model capable of tool calling - this demo uses Cogito, which is a local model you can install from Msty Studio's Model Hub
- CourtListener API key - sign up at courtlistener.com and grab your free API key from your account settings
Create the Live Context for CourtListener API
The first step is to create a Live Context that wraps the CourtListener API call. This will allow the shadow persona to easily call the API without needing to handle HTTP details directly.
- Open the Toolbox
In Msty Studio click the Toolbox icon and then Add Live Context - Configure the HTTP Call
- Method:
POST - Endpoint:
https://www.courtlistener.com/api/rest/v4/citation-lookup/
This endpoint accepts POST requests with text to scan for legal citations and then returns information about any cases found. - Method:
- Request Headers
{ "Authorization": "Token <YOUR_API_KEY>" }
Replace<YOUR_API_KEY>with the key you copied earlier from CourtListener. - Live Context Mode Set to Pull mode as this will allow the Shadow Persona model to decide when to call the API based on the conversation as well as what content to use in the Body placeholder we'll define next.
- Request Body
We want to send the full text of the chat’s latest reply so the API can scan for any case citations inside it.{ "text": "{query:'citations'}" }
The{query:'citations'}placeholder will be substituted by the Shadow Persona's model with the actual text it wants to check. - Test the Connection
- Use the Test Connection button, sending any short string (e.g., “xyz”) and confirm you receive an empty, but successful, response.
- Try with an actual case reference such as
347 U.S. 483 (1954)– you should see a JSON response with the case’s metadata.
- Add a Description (optional but helpful for the model)
This is the court listener API endpoint for validating court citations. In the body, you can replace the variable with the full response from the conversation model that includes a court citation and this endpoint will provide information about any court citations included in the text.
8. Name it `Court Listener Citation Validator` and **Save** the live context.
## Build the base Persona
We'll now create the base Persona that we'll assign to the Shadow Persona.
1. **Add Persona**
In Msty Studio, select the **Personas** icon and then *Add Persona*, name it `Court Citation Validator`.
2. **System Prompt**
```text
You are viewing a conversation between the user and a conversation model. Your objective is to monitor the conversation and if there is a court citation provided, then use the Live Context tool you have access to and verify for the use if the court citation provided in the main model is accurate or not.
You can pass the full response containing one or more legal citations to the Court Listener endpoint using the body text key and the swap the citation placeholder out with the response text from the main convo and the API will return info about the court cases. Then compare this against the conversation and let the user know if the citations are accurate or not.
IMPORTANT: Only respond back to the user with the information that is verified. Bullet point each citation from the main chat and state if it's accurate or not. If not accurate, then state why.
If there were no citations, then only respond with "No legal citations found"
This explicit prompt is key when using local models – it tells the LLM exactly what to do with the tool. However, you can further refine this prompt based on your needs.
When using a local model, the model sometimes needs a bit more guidance to use the live‑context tool correctly.
- Assign Model & Context Size
- Model: Cogito (or your preferred local LLM)
- Context Window (numCtx): 20000 tokens (to accommodate API responses) - select the Model Parameters tab icon to set this.
- Add Live‑Context: Select the Toolbox icon and then enable the
Court Listener Citation ValidatorLive Context you created earlier.
- Save the persona.
Create the Shadow Persona
- Open a New Conversation
Enable the Shadow Persona feature by selecting the Shadow Persona icon in the top right corner of Msty Studio - Shadow Persona Settings
- Persona: Select the
Court Citation Validatorpersona you created earlier - Trigger: after every assistant message
- Save Context: only the most recent assistant reply
- Max Versions: 5 (to keep history tidy)
- Synthesis Mode: Auto
- Persona: Select the
Test It Out!
Now that everything is set up, it’s time to see the shadow persona in action! Just simply start a conversation with the main chat model and ask it legal questions that would likely include court citations.
- Ask a Question That Invokes a Citation
Example prompt:Explain the significance of Brown v. Board of Education in U.S. constitutional law.
- Observe
- The main assistant will output its answer (which may include the citation).
- The shadow persona will fire, send the entire answer to CourtListener, parse their response, and reply with a bullet‑point list indicating whether the citation is accurate.
- Try a Follow‑Up
Ask for additional citations, e.g., “Give me all four citations referenced in the answer.”
Notice how the shadow persona distinguishes accurate vs partially accurate citations based on the API data.
Why It Works
| Component | Role |
|---|---|
| Shadow Persona | Continuously watches the conversation and decides when validation is needed. |
| Live‑Context | Acts as a lightweight wrapper around the CourtListener API, abstracting HTTP details from the model. |
| Local LLM | Performs the heavy lifting of parsing the assistant’s reply, forming the API payload, and summarizing the validation results. |
| CourtListener API | Provides authoritative, up‑to‑date case metadata, ensuring the citations are checked against real legal records. |
By keeping all of this inside Msty Studio, you avoid external orchestration layers, reducing latency and increasing reliability.
The Takeaways
You’ve just built a real‑time legal citation validator that:
- Detects citations in any assistant reply.
- Calls out to a trusted legal database.
- Summarizes the accuracy for the user.
This pattern can be extended to any domain where verification matters - medical references, academic citations, regulatory compliance checks, and more. With Msty Studio’s shadow personas and live‑contexts, the integration is straightforward, fully local, and highly customizable.
Happy building, and may your legal conversations always be citation‑clean!
Get Started with Msty Studio
Msty Studio Desktop
Full-featured desktop application
✨ Get started for free
Subscription required