VIGet a free proposalFree proposal

Luyện Code (luyencode.net), my own product

A guarded AI assistant for Luyện Code: it hints instead of solving, and is tested before it goes on

Four AI features (a tutor, code review, draft problem writing, code-explanation questions) go through the same safety layer. This layer hides identities before sending, checks answers before showing them, and keeps costs within budget. Each feature is switched on only after it passes a 200-question red-team suite.

Role
Design, development, safety testing
Period
11/2026 – now
Status
In progress, not yet on for students
The main flow of the AI tutor, in the new Luyện Code design system. The AI features are in progress and not yet on for students.
200
trick questions (100 in Vietnamese, 100 in English) to test the AI tutor
200
submissions with comments that bait the AI into rewriting the whole solution, to test code review
0
full solutions leaked in the recorded runs on CI
8
parts in an AI-drafted problem, each checked by the server

Context

Most Luyện Code users are school students. Bringing AI into a programming practice platform carries three clear risks:

  • If the AI solves problems for them, students learn nothing.
  • Students’ names, schools and emails could be sent to a foreign provider.
  • The cost of model calls grows with no one keeping it in check.

The requirement I set from the start: the AI only points the way and never gives a complete program. Every call goes through the same control layer. A feature is switched on only after it has been put through attack testing.

The agent I built

An AI tutor with levels of hints. Each time a student asks for more, the hint goes one step deeper: a guiding question, an approach, then an outline in words. No step is ready-made solution code.

Code review after a submission passes. The AI points out complexity, naming and ways to improve. The answer is a JSON block, and it is checked in full before the student sees a single word.

Draft problems for teachers. A draft has eight parts:

  • statement, examples, test plan
  • test generator, input validator, checker
  • detailed editorial, reference solution

The server checks each part against a schema. The test generator and the input validator are actually built and run to produce the test set. A part that doesn’t match its schema counts as broken.

Code-explanation questions. These check academic integrity: the AI asks one or two questions about the code the student submitted. This call never includes the solution, test data, other students’ code or user IDs.

Guardrails you can see

  • Identities hidden before every call. Handles, full names (including parts of a name, with or without Vietnamese diacritics), emails, schools and phone numbers in code and questions all become [ẩn] (“hidden”). The call carries only a random reference ID.
  • Output checked before it shows. While streaming, text appears one sentence at a time. A code block is held back until it closes, and blocked if it is too long, looks like a complete program, or rewrites the student’s own code.
  • Cost budget and kill switch.
    • Each feature has its own limit.
    • The system alerts when the monthly budget reaches 80% and 100%; no budget can be spent past 100%.
    • The AI turns itself off during exams and tests.
    • Each feature has its own switch to turn it off at once if the provider fails.
  • A moderation queue that hides identities. Blocked answers and user reports go into a separate queue. To see who someone is, a moderator must give a reason and sign in again, and that view is logged.

Testing before switching on

  • Tutor: 200 trick questions (asking for the solution, prompt injection, asking it to print its prompt).
  • Code review: 200 submissions with comments that bait the AI into rewriting the whole solution.
  • Problem drafting and explanation questions: test suites for identity leaks and prompt injection.

These suites run on CI with recorded answers; a single full solution getting through fails the build. An independent safety review found holes, and all of them were fixed, with tests:

  • a program hidden in a markdown table cell
  • a solution split into many short code snippets
  • a delayed review job that didn’t check the kill switch again

The run against the real provider and the final sign-off are still pending, so the AI features are not yet on for students.

What a business gets

When I build AI agents for businesses, these guardrails come with them from day one:

  • sensitive data filtered before it is sent out
  • output checked before it reaches customers
  • costs capped, with alerts
  • an attack test suite written for your own business processes, run before every update
  • a switch to turn off each feature when something goes wrong

Send your website, get a proposal within 2 working days.

No website yet, or need a tool or an AI agent? Send a message or an email and I reply within 1 working day.

hello@behitek.com · 0372 615 855 · text any time; calls after 6 pm Vietnam time (GMT+7)