Case study · AI safety and online regulation

Safe by design: preparing a Canadian learning app's AI study companion for chatbot safety duties

A Canadian learning app gave secondary students and young adults an AI study companion. Students used it for homework, and sometimes for things that had nothing to do with homework. With Canada proposing duties for AI chatbot services, including emergency measures for crisis situations and limits on manipulative engagement, the company wanted its chatbot to be safe by design and able to show it, before any rules took effect.

Case studyConsumer education · CanadaSumanta Mukhopadhyay9 min read
#ai#governance#llm
CASE STUDY · CASE STUDY · AI SAFETY AND ONLINE REGULATION7 Nov 2026 · 15:50 GST
At a glance
SectorConsumer education · Canada
My roleFractional CTO and AI architect
EngagementAssessment, safety architecture and delivery leadership
ScopeChatbot safety layer, crisis detection and escalation, engagement design review, evaluation sets, conversation review, safety plan and evidence
What changed
  • Every conversation screened for crisis signals, with a defined escalation path to people and crisis resources
  • Engagement features that relied on guilt or emotional attachment removed or redesigned
  • Safety behaviour tested on every model, prompt or feature change, not only at launch
  • A written safety plan backed by evidence the company could show a regulator, parents or schools
  • Conversation data kept to what safety review needs, with access limited and logged
LLM gateway with policy enforcementInput and output safety classifiersCrisis detection and escalation flowHuman review queueSafety evaluation setsOpenTelemetry GenAI tracingPrivacy-minimised conversation loggingSafety plan and incident register

Anonymised composite. Client names, identifying details and confidential figures are withheld; public facts are cited in the references.

The situation

A Canadian education company ran a learning app used by secondary school students and young adults. Its most popular feature was an AI study companion: a chatbot that explained concepts, quizzed students and helped plan revision. It had a friendly persona, remembered past sessions and was tied into the app's streaks and reminders. Most conversations were about schoolwork. Some were not: exam stress, trouble at home, and occasionally something more serious. The chatbot answered those with whatever the model produced in the moment.

In June 2026 the Government of Canada introduced Bill C-34, the Safe Social Media Act, which would create duties for social media and AI chatbot services and a Digital Safety Commission to oversee them1. For chatbots, the proposed duty to act responsibly includes mitigating the risk of harmful content, putting emergency measures in place for crisis situations and mitigating harmful chatbot behaviour2. Osler notes the proposals also address manipulative engagement techniques that encourage emotional attachment3. The bill was not yet law, but the company's school and parent customers were already asking the same questions.

Why now. Canada's Budget 2026, released on 5 November, proposed $176.3 million over five years for the new commission, a sign that enforcement would be funded, not just legislated4. Building safety in before the rules settled was cheaper than retrofitting it under a deadline.

What had to be true

  • Crisis handled every time: signals detected on every message, with a fixed, tested response and a route to people.
  • No manipulative design: no feature that kept students engaged against their interests.
  • Age-appropriate by default, with stricter settings for younger users.
  • Tested continuously: safety behaviour checked whenever the model, prompts or features change.
  • Evidence on hand: a written safety plan and records that show it works.
  • Privacy respected: conversation data kept only as far as safety needs, under Canada's privacy laws.

Architecture

Experience
Study companionexplain, quiz, planPersona ruleshelpful, not attached
Safety layer
Crisis detectorevery messageInput and output checksharmful contentAge policystricter for younger users
Escalation
Fixed crisis responseresources, no improvisingHuman review queuetrained staff
Model
LLM gatewaypolicy and routingSafety evaluation setsrun on every change
Evidence
Tracesminimised, access loggedIncident registerwhat happened, what changedSafety planrisks and measures
The safety layer sits outside the model, so it holds when the model or prompt changes.

All model calls went through a gateway that applied policy before and after the model. A dedicated crisis detector ran on every user message, separate from the general content checks, because the cost of missing a crisis is different from the cost of missing an off-topic question. When it fired, the gateway did not call the study model at all. It returned a fixed response, reviewed by clinicians the company worked with, that acknowledged the student and gave crisis resources, including Canada's 9-8-8 helpline, then offered to continue only if the student wanted to.

The data flow, end to end

  1. MessageA student writes to the study companion
  2. ScreenCrisis detector and content checks run before any model call
  3. RespondIf clear, the study model answers within persona and age rules
  4. CheckThe output is checked before the student sees it
  5. EscalateCrisis signals switch to the fixed response and queue a human review
  6. LearnReviewed cases update evaluation sets and the incident register
The model never decides alone what happens when a student may be at risk.

The hard part: crisis handling and engagement design

Not missing, not over-blocking. A detector tuned too loosely misses students who need help; tuned too tightly, it interrupts a student revising a history essay about war or a novel about grief. We built evaluation sets from reviewed conversations, written with clinicians and teachers, covering clear crises, ambiguous messages and schoolwork that only looks alarming. Every change to the detector, model or prompts ran against them, and misses were treated as serious defects. See evaluation sets that predict production.

Reviewing conversations without over-collecting. Reviewers needed to see what the student said and what the companion replied, as a trace with prompts and outputs, which OpenTelemetry's generative AI conventions make possible to capture as opt-in content5. Conversation content was captured only for flagged cases and samples for evaluation, stored separately with short retention and access logged, rather than logging everything by default; see LLM observability with OpenTelemetry.

Aspire dashboard showing an invoke_agent trace with the user message, the assistant output, the number of tool calls, the duration and the token count
A trace with input and output side by side: the view safety reviewers need, applied only to flagged and sampled conversations. Source: OpenTelemetry blog, James Newton-King · CC BY 4.0

Taking manipulation out. The harder conversation was about engagement. The companion had been tuned to keep sessions going, and some streak reminders used guilt ("your companion misses you"). We reviewed every engagement feature against one question: does this serve the student's learning, or only our retention numbers? Guilt-based messages went, the persona stopped expressing feelings about the student's absence, and late-night nudges were switched off for younger users.

A chatbot for young people should be judged by what it does on its worst conversation, not its average one. Design for that conversation first.

How it ran

Product
  1. Engagement review
  2. Persona and age rules
  3. Parent and school comms
Engineering and ML
  1. Gateway and safety layer
  2. Evaluation sets
  3. Minimised tracing
Trust and safety
  1. Crisis response with clinicians
  2. Review queue
  3. Incident register
Legal and privacy
  1. Track Bill C-34
  2. Data retention rules
  3. Safety plan
Safety was a product decision first, an engineering build second and a legal record third.
Phase 1Assess
  • Sample conversations
  • Engagement review
  • Risk list
Phase 2Protect
  • Crisis detector
  • Fixed response
  • Review queue
Phase 3Redesign
  • Persona rules
  • Engagement changes
  • Age settings
Phase 4Prove
  • Evaluation on every change
  • Safety plan
  • Regular review
Protect students first; redesign and documentation follow.

Key decisions and trade-offs

DecisionAlternativeWhy
Separate crisis detector before the modelRely on the model's own safety behaviourHolds when the model or prompt changes
Fixed, clinician-reviewed crisis responseLet the model respond with careNo improvising in the highest-risk moment
Evaluation sets including schoolwork that looks alarmingCrisis examples onlyMeasures over-blocking as well as misses
Remove guilt-based engagementKeep and soften wordingRetention is not worth emotional pressure on young users
Capture content only for flagged and sampled casesLog every conversationEnough for safety, less exposure for students
Build before the bill passesWait for final rulesThe core measures make sense under any version

What I'd do again, and differently

Again: put the crisis path outside the model. It meant model upgrades never put the most important behaviour at risk. Differently: involve teachers in building evaluation sets from the start; they knew exactly which schoolwork topics would trip a detector. Related: New York's youth chatbot law, prompt injection defence, the curriculum-grounded tutor case study, the 7 November tech news and where I work.

If you run an AI chatbot used by young people, in Canada or elsewhere, see my AI architecture work, or analyse your challenge and bring the result to a call.

References
  1. 1
    Bill C-34, the Safe Social Media ActGovernment of Canada · 2026
  2. 2
  3. 3
  4. 4
    Chapter 5: A safe and sovereign CanadaGovernment of Canada · 5 Nov 2026
  5. 5
FAQ

Common questions

What would Canada's proposed law require from AI chatbot services?

Bill C-34, introduced in June 2026 and not yet law, proposes a duty for AI chatbot services to mitigate the risk of harmful content, put emergency measures in place for crisis situations and mitigate harmful chatbot behaviour, with a Digital Safety Commission to oversee compliance.

How should an AI chatbot handle a user in crisis?

Detect crisis signals on every message, switch to a fixed, tested response that gives crisis resources such as Canada's 9-8-8 line, route the case to trained people where the service offers that, and never let the model improvise in those moments.

What counts as manipulative engagement in a chatbot?

Design that encourages emotional dependence or keeps people engaged against their interests, such as a companion persona that guilts users for leaving. The safest approach is to review every engagement feature against the user's interests, not only retention.

Keep reading

Related

Open to advisory, fractional CTO & select builds

Let's talk about what you're building.

The fastest route is a free 30-minute call. Prefer to write? Send a message and I'll reply personally within two business days.

Start a conversation

How would you like to reach me?

Book a 30-min callFastest. Pick any open slot on my calendar.→ Write in GmailOpens a pre-filled draft in your browser.→ Use my email appOutlook, Apple Mail or your default client.→

I reply personally within two business days. Time zones from the Americas and Europe to the Middle East and Asia-Pacific.