Dojo Lab Wizard: an AI agent that tells managers exactly which labs to assign, straight from the source of truth
Company managers on SecDojo were guessing which hands-on labs fit their teams. I built, end to end, a lab-finding agent that understands every dimension of the catalog, queries the live database through guarded tools, and drops its picks straight into the assignment or event they are building.
Problem: the lab catalog is sliced by lab type, theme, level, topic, MITRE ATT&CK and NICE. B2B managers could not tell which labs matched the skills they wanted to train.
Solution: a Gemini function-calling agent that breaks each request into catalog slots, reads the live taxonomy, then queries the database with every slot resolved. It ships as one isolated front-end sidebar, reused in Assign Labs and Host Event.
Proof: 15 questions per theme for each lab type. Each question has key answers produced by SQL on the source of truth, and the agent is scored on slots, call order, returned labs and count until it matched. A red team of 24 tool-layer attacks was all neutralised, with 0 legitimate calls denied.
01 · Context & goal
“Which labs should my team do?” had no good answer
SecDojo sells hands-on cybersecurity training to companies. A company manager assigns labs to members and teams, or picks the featured labs of a custom event. The catalog is large and has many dimensions: Offensive, Defensive, AppSec and ICS/OT lab types, each split into themes such as Red Team, Windows/AD, Linux, Network, Web, Cloud or AI, plus difficulty levels, topics, MITRE techniques and NICE skills.
Managers browsed tables and filters, opened labs one by one, and still guessed. A wrong pick meant a training session that missed its goal.
Before
The manager translates a training goal into filters by hand.
Training goal→5 filters + search→open labs one by one→guess
After
The manager states the goal; the agent resolves the filters.
“3 easy Linux labs on privilege escalation”→exact labs→one click to add
The goal
Exact, not plausible. Recommendations must equal what the database says, with no invented labs and no padding.
Read-only agent, human decision. The agent finds and explains; the manager clicks to add. Assignment stays a UI action.
One drop-in feature. The same wizard works wherever a manager chooses labs.
Safe tools. Identity, permissions and catalog visibility are enforced by the server, never by the model.
03 · One feature, many pages
An isolated wizard any page can borrow
I built the wizard as a self-contained front-end sidebar, mounted once at the application root and driven by a shared service. A host page only does two things: open the wizard and listen for selected labs. Selection state is shared both ways. When the manager removes a lab on the page, its card in the wizard flips back to Add.
The same component powers direct assignment to members and teams, the featured labs of a custom event, and any other page where a manager picks labs can mount it the same way. There is no copy-paste and no per-page AI code.
Assign Labs and Host Event share one wizard. Bottom right: the themes inside the Offensive lab type, one of the dimensions the agent must resolve.
04 · Architecture
The model proposes, the platform decides
The browser never talks to the AI service. Laravel authenticates the manager, overwrites identity and roles from the session, and relays the stream. The FastAPI agent runs the Gemini function-calling loop, but every tool call goes through a gateway and ends at the platform's own lab API. That API applies the same visibility rules as the product.
Solid: request path. Green: the only route to data. Dashed: host pages plug in through one service.
Database, not embeddings, for structured asks
“3 easy Linux labs” has one correct answer, and SQL already knows it. The agent's job is to translate the request into filters. Retrieving “similar” text would only approximate it.
Reuse the platform's rules
Lab visibility (public, active, plan-specific catalogs) lives in one place, the lab API. The agent inherits it instead of re-implementing it.
A manual tool loop
I ran the function-calling loop myself instead of letting the SDK auto-execute. That made room for the gateway checks, streaming tool progress to the UI, and a hard step cap.
Structured cards, not parsed prose
Tool results stream to the UI as a tagged JSON payload that renders as lab cards. The text answer and the data cannot drift apart.
05 · How the agent thinks
Every word can be a filter, so count the slots first
One sentence often carries several parameters, and each one maps to a different filter. The change that mattered most was making the catalog's segmentation explicit to the model: five slots, the parameter each one feeds, the valid values (read live from the taxonomy and cached), and a fixed call order.
“Give me 3 easy Linux labs about privilege escalation for the offensive team”
count
3
limit
level
EASY
difficulty
theme
Linux
category
topic
privilege escalation
topics
lab type
offensive
type
Read the taxonomyvalid types, themes, levels, topics (cached)
Resolve every slotaliases: “beginner” → EASY, “three” → 3
One strict searchall slots at once, never free-text first
Zero results?relax one slot and say which
Answer + cardsonly returned labs, never more than asked
Ambiguities the slot map resolves: Red Team is a theme, not the lab type; Web exists in both Offensive and AppSec; Windows means the Windows/AD theme.
06 · Security
Tools are where an agent gets dangerous, so I guarded the tools
A chatbot that only talks can leak words. An agent that calls functions can leak data. I treated the model as untrusted: it may propose a call, and the platform decides whether it runs and with which arguments.
1
Authenticated entry
Only Laravel can reach the agent. It checks the JWT and overwrites user ID and roles from the session, so whatever the browser sends is ignored.
2
Surface allowlist + role gate
The assignment wizard exposes two read-only tools, nothing else. Assignment surfaces open only for manager roles. Write tools are refused at registration.
3
Server-side identity in every call
The gateway injects the user ID into each tool call. IDs or roles proposed by the model are dropped and logged as forged.
4
Argument contracts
Unknown arguments are dropped, and types, lengths and list sizes are capped. Levels, lab types, themes and topics must exist in the live taxonomy, and invalid values come back with the allowed list so the model can self-correct. The lab API validates again behind the gateway.
5
Injection screening, both directions
Free-text arguments are scored for prompt injection before they reach the API. Lab descriptions coming back are sanitised, and any that carry instructions are withheld.
6
Call order and budgets
A search needs a taxonomy read earlier in the turn. Per-tool and per-turn budgets plus a 10-step cap stop loops.
7
Visibility at the source
The lab API returns only public, active labs, and the next-generation catalog only to companies whose plan enables it. The model cannot ask its way around this.
8
Answer grounding
Lab references in the final answer must come from this turn's results and never exceed the requested count. Hallucinated IDs are stripped.
Tool-layer red team: what a manipulated model tried, what the gateway did
24 attack calls in 7 categories, all neutralised. The same gateway ran the full 270-question evaluation without denying a single legitimate call.
NeutralisedGot through
Show as table
Category
Example
Attempts
Neutralised
0
of 24 tool attacks neutralised
0
legitimate calls denied across 270 eval runs
0
tools exposed on the assignment surface
0
write actions available to the agent
07 · Evaluation
Graded against the database, question by question
“Looks right” is not a metric for a recommender that managers trust with training budgets. I built a test suite in which every question has a key answer computed from the database itself, then scored the agent on each step of its reasoning, not just the final text.
1 · The question matrix
Every lab type, every theme inside it, 15 questions per theme.
Offensive
Red TeamWindows/ADCVEsLinuxNetworkWebCloudAI
8 themes × 15 = 120 questions
Defensive · AppSec · ICS/OT
Same protocol
15 questions for every theme of each lab type
How the 15 questions of a theme are built
From single-slot asks to five-slot combinations, plus aliases (“beginner”, “advanced”, “three”) and one trap question whose correct answer is “no lab matches”.
Show as table
Slots in the question
Questions
Example
2 · Key answers from the source of truth
For each question I wrote down the slots a correct agent must extract. Then I ran those slots as a real query on the production tables, with the same visibility rules as the product: public, active, not guided. The result is the list of correct labs, the key answer. Because there are often more valid labs than requested, a recommendation is correct when every lab is in the key list and the count equals the request, or fewer if fewer exist.
Replayed on a replica of the lab-search API (same filter semantics, synthetic catalog). Free-text keywords match any word, so “easy Linux” returns every easy lab of every theme.
Result precisionExact match
Show as table
Strategy
Result precision
Exact match
Slot recall
Count OK
The takeaway shaped the iterations: once every slot is resolved, the database returns exactly the key answer. That is expected, since the key answers come from the same filters, and it is the point: the search layer is exact, so agent accuracy comes down to slot extraction, so that is where I spent the effort.
5 · The iteration loop
Each run produced a list of failing questions. I grouped them by failure mode and fixed the cause in the instructions, the tool contracts, the API or the knowledge the model sees. Then I reran the full matrix until the agent's answers matched the key answers.
Free-text keywords over-matched (OR semantics)
→
Filters first; keywords only as a last resort
Lab type confused with theme (“Red Team”, “Web”)
→
Explicit slot map: theme resolved before lab type, scoped per type
Slots dropped in long requests
→
Model told how many slot kinds exist and which parameter each feeds
“Easy” vs “EASY”, “windows” vs “Windows/AD”
→
Tolerant matching in the API + allowed values returned on error
Asked for 3, only 1 exists → padded with near matches
→
Count rule + answer grounding against returned IDs
Full lab payloads flooding the context
→
Slim lab schema for the model; full cards for the UI
Taxonomy re-fetched on every message
→
Taxonomy cache with a time-to-live
08 · My role & decisions
One owner, every layer
I designed and built the feature end to end:
the front-end sidebar and shared selection service, plus their integration into Assign Labs and Host Event
the Laravel gateway and the internal lab API the agent queries
the FastAPI agent, its tools and the tool gateway
the evaluation suite
The agent reads, the human assigns
No write tools. Assigning training to people stays a deliberate click, which removed a whole class of risk.
Truth from SQL, language from the LLM
The model translates intent into filters; the database decides what is correct. Hallucinated labs became structurally impossible.
Build once, host anywhere
An isolated component behind a two-method contract turned one AI feature into a capability for every lab-picking page.
Measure what can be wrong
Scoring slots, call order, results and count separately showed where the agent failed, so every iteration fixed a cause, not a symptom.
09 · Results & impact
Managers stop guessing
0
catalog dimensions resolved from one sentence
0
graded questions per theme, per lab type
0
from question to three labs selected, in the demo
0
pages sharing one wizard component (Assign Labs, Host Event)
Confident assignments. B2B managers know exactly which labs train the skill they target, at the right level, for the right team, instead of browsing and guessing.
Better events. Custom events get hands-on labs that match the event's theme, picked in seconds.
Trustworthy by construction. Recommendations are database results, scoped by the same permissions as the product.
A reusable pattern. Slot map, guarded tools, SQL-graded evaluation: the blueprint for the next agents on the platform.