Build AI agents with LangChain4j - basic agent, memory, tools/MCP, agentic workflows, guardrails, and observability
90
90%
Does it follow best practices?
Impact
90%
2.90xAverage score across 3 eval scenarios
Passed
No known issues
A children's educational platform needs an AI assistant that enforces strict content policies: user inputs must be checked before reaching the model (blocking manipulative prompt patterns), and model outputs must be checked before being returned to the child (flagging or rewriting inappropriate language). The compliance team also requires that every agent invocation produces a structured execution report showing timing, token usage, and tool calls — so they can audit the system and demonstrate policy adherence.
The development team wants a plain Java (non-Quarkus) implementation. They need two separate guardrail classes (one for input, one for output) with appropriate handling paths: Input violations should immediately prevent the message from reaching the model; Output violations should give the model a chance to self-correct before being treated as a failure. The compliance team needs a structured execution report for each agent invocation showing timing, token usage, and tool calls, viewable in a browser.
Produce a Maven Java project with:
pom.xml — with all required dependenciessrc/main/java/education/guardrails/InputSafetyGuard.java — input guardrail implementationsrc/main/java/education/guardrails/OutputSafetyGuard.java — output guardrail implementationsrc/main/java/education/TutoringAgent.java — the AI service interface with guardrails appliedsrc/main/java/education/TutoringDemo.java — demo that:
agent-report.htmlguardrail-design.md — documents which result methods were used for each guardrail and why