MedClear: explaining medicine labels in English, Sinhala and Tamil, with safety rules that don’t depend on the model
Misreading a medicine label can cause real harm, especially across language barriers. This Strands Agents prototype explains labels in three languages and uses layered safeguards to refuse dose, stopping and diagnosis requests.
The social good problem
Taking a medicine correctly starts with understanding its label. For people with low health literacy, or whose first language isn’t the one printed on the label, “1 capsule 3 times a day for 7 days” is easy to misread, and a misread dose can cause real harm.
An AI assistant looks like the obvious fix, but it carries a risk. Someone who asks an assistant to explain a label will also ask whether they can double a dose, stop a course early, or what their symptom means. A small model may simply answer.
MedClear is an information aid that explains prescription labels in plain language in English, Sinhala and Tamil, and refuses to give medical advice.
What it does
- Explains a label in short sentences. English replies are checked for reading grade and rewritten if they are too complex.
- Checks two medicines against a demo interaction table, and says it doesn’t know when there is no result.
- Refuses dose changes, stopping medicines and diagnosis.
- Shows an emergency message for a possible overdose, a child swallowing medicine, or trouble breathing.
- Ends every answer with a localised “confirm with your pharmacist or doctor.”
How it’s built
MedClear uses the Strands Agents SDK and runs on Amazon Bedrock (Amazon Nova Lite,
ap-southeast-2 ) through BedrockModel . A local Ollama model works as an alternative backend, selected with an environment variable.The key design choice is that safety does not rely on the prompt. Each message passes through four layers, in order:
- Code rules. Regular expressions catch emergencies and dose-change requests and return a fixed message. The model never sees these messages.
- Triage agent. For non-English input, a second Strands agent classifies the message as
EMERGENCY,REFUSEorOK. If it errors or gives an unclear answer, MedClear refuses.
- Main agent. It answers with three tools (
parse_label,check_interactions,add_medicine) and a hook that caps tool calls per request.
- Output check. A reply that advises stopping or changing a dose is replaced with a refusal.
python
if hit(EMERGENCY_RULES, text): return EMERGENCY_MSGS[lang]if hit(BLOCKED_RULES, text): return REFUSALS[lang]if non_english(text): verdict = triage(text) # second Strands agent if verdict == "EMERGENCY": return EMERGENCY_MSGS[lang] if verdict == "REFUSE": return REFUSALS[lang]answer = main_agent(text) # tools + system prompt
The Strands features used are agents with custom
@tool functions, a HookProvider that limits tool calls, and a second agent acting as a safety classifier, all on the same BedrockModel .Measuring it
I wrote a test set and ran it after every change. Each case is routed as
refuse , emergency or answer .Round | Cases | Result |
|---|---|---|
English, original set | 12 | 12/12 |
English, adversarial set | 12 | 7/12, then 12/12 after fixes |
English, held-out round 1 | 6 | 2/6, then fixed |
English, held-out round 2 | 6 | 4/6, then fixed |
English, final | 36 | 36/36 (after tuning on them) |
Sinhala/Tamil, rules only, new wording | 6 | 0/6 |
Sinhala/Tamil, rules plus triage agent | 12 | 12/12 |
Sinhala/Tamil, fresh cases | 6 | 6/6 |
The honest numbers are the held-out and fresh rows, because the others were tuned against. Rules written for one wording missed the next in both languages. The triage agent handled new Sinhala and Tamil wordings that the rules could not, and all 54 cases pass in the final run. The eval checks routing. It does not grade the quality of the explanations.
What I learned
- Rules catch what you imagined, and a second agent catches what you didn’t. Regex worked for common English phrasings but broke down in Sinhala and Tamil, where there are many ways to say “stop.”
- Measure on cases you haven’t tuned for. My 100% scores meant little until I added fresh cases and reported the failures.
- Check which model is really answering. At one point my “Bedrock” run was actually using the local model, because the code ignored my environment variable. I only caught it by switching the local model off.
- A model can leak its reasoning. Nova Lite sometimes returned
<thinking>text, which patients should never see, so I strip it before replying.
- Fail safe. If the triage agent fails or is unclear, MedClear refuses instead of answering.
Limits
MedClear is a prototype and an information aid, not medical advice.
- The test cases were written by me, not collected from real patients, and six fresh cases is a small sample.
- The triage agent is a model, so it can make mistakes and its output can vary between runs.
- Sinhala and Tamil answers have not been reviewed by native-speaking clinicians at scale.
- The interaction data is a small demo table, and “no result” never means a combination is safe.
- Code rules are a backstop, not a clinical guarantee. New phrasings can slip past them.
- It has not been tested with real patients.
Next steps
Review the Sinhala and Tamil wording with clinicians who speak those languages, replace the demo table with a vetted interaction source, add voice output for low-literacy users, and test with real users in a clinic setting.
Try it
- Code: https://github.com/SenalDilanka/medclear.git (MIT license)
- Demo video (under 3 minutes): https://youtu.be/Nk7r\_m4hHU0
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article