1 of 22

Building secure AI agents with

Quarkus LangChain4j

Radek Kargul & Willem Jan Glerum

Devoxx BE 2025

Workshop

2025/10/06

2 of 22

3

Agentic AI/Quarkus & Langchain4j

Agenda

Outline

Introduction

5

Authentication

11

Retrieval-Augmented Generation (RAG)

13

Guardrails

15

Testing LLM Applications

16

Workshop

17

1

2

3

4

5

6

7

Building secure AI agents with

Quarkus LangChain4j

01

02

03

04

05

//

06

07

2

3 of 22

Introduction

Building secure AI agents with

Quarkus LangChain4j

Radek Kargul

  • Software Engineer @ Lunatech 👨‍💻
  • MSc Comp Sci @TU Delft (Software + AI) 🎓
  • Certified Fitness Instructor 💪
  • https://github.com/rkargul

//

3

4 of 22

Introduction

Building secure AI agents with

Quarkus LangChain4j

Willem Jan Glerum

  • Principal Software Engineer @ Lunatech
  • Using Quarkus since 2019 ??
  • Volunteer @ Scouting (both at local & international events)
  • Travelling and outdoors
  • https://github.com/wjglerum

//

4

5 of 22

Agentic AI

Definition

Building secure AI agents with

Quarkus LangChain4j

  • System that can reason, plan, and take actions based on natural language instructions.
    • Autonomous (low supervision)
    • Plans multi-step tasks
    • Calls tools/APIs to act

//

5

6 of 22

Agentic AI

Use Cases

Building secure AI agents with

Quarkus LangChain4j

  • Automating workflows (tickets, approvals, back-office)
  • Customer support
  • Business data analysis and reporting
  • Research assistants and summarizers
  • Many more…

//

6

7 of 22

Agentic AI

What powers it

Building secure AI agents with

Quarkus LangChain4j

  • Large Language Models (LLMs)
  • Function/Tool calling (databases, APIs, business services)
  • Memory & RAG (bring your own knowledge)
  • Orchestration (guardrails, auth, observability)

//

7

8 of 22

Quarkus & LangChain4j

Building secure AI agents with

Quarkus LangChain4j

  • Quarkus: modern Java framework; fast, lean, cloud-native.
  • LangChain4j: framework for building AI agents in Java.
  • Together:
    • Easy integration of AI into enterprise apps
    • Built-in structures for tool usage & extensions
    • Hooks to enforce authentication (OIDC), guardrails, audit logging.

//

8

9 of 22

Why Security Matters for AI Agents (1)

Building secure AI agents with

Quarkus LangChain4j

Agents don’t just answer questions - they take actions.

Risks:

  • Prompt injection: malicious user tricks agent into leaking data or running dangerous actions.
  • Privilege escalation: agent performs unauthorized operations.
  • Data leakage: sensitive business/customer data exposed.

Securing agents is as important as securing any enterprise application.

//

9

10 of 22

Why Security Matters for AI Agents (2)

Building secure AI agents with

Quarkus LangChain4j

Agents don’t just answer questions - they take actions.

Defenses

  • AuthN/Z (OIDC + roles)
  • Guardrails (input/output validation)
  • Monitoring & audit logging

Securing agents is as important as securing any enterprise application.

//

10

11 of 22

OIDC

What is it?

Building secure AI agents with

Quarkus LangChain4j

  • OpenID Connect
  • Open authentication protocol
  • Extends OAuth 2.0 with an identity layer
    • Adds the ID token
  • Standard way to authenticate users and services

//

11

12 of 22

OIDC�The Flow

12 / 17

https://quarkus.io/guides/security-oidc-code-flow-authentication

13 of 22

Retrieval-Augmented Generation (1)

Building secure AI agents with

Quarkus LangChain4j

Why: bring fresh, domain knowledge without fine-tuning

Two steps:

  • Ingest: split → embed → store
  • Augment: retrieve →inject into prompt

//

13

14 of 22

Retrieval-Augmented Generation (2)

Building secure AI agents with

Quarkus LangChain4j

Ingest: split → embed → store

//

14

15 of 22

Retrieval-Augmented Generation (3)

Building secure AI agents with

Quarkus LangChain4j

Augment: retrieve →inject into prompt

//

15

16 of 22

Retrieval-Augmented Generation (4)

Building secure AI agents with

Quarkus LangChain4j

Keep it simple

  • Start with local embeddings + EasyRAG / in-memory store
  • Swap models/stores later

Security

  • Combine with Guardrails (prompt-injection filters, per-tool RBAC) so the model can’t “browse” past your KB or make up facts.

//

16

17 of 22

Guardrails

Building secure AI agents with

Quarkus LangChain4j

Validate both input & output before/after the LLM.

Input

  • Block prompt injection / out-of-scope
  • Enforce constraints (length, domains, required fields)

Output

  • Enforce format (JSON shape, schema)
  • Enforce grounding (ee.g., “must cite KB” or “must mention allowed locations”)
  • Detect likely hallucinations

//

17

18 of 22

Testing LLM Applications

Building secure AI agents with

Quarkus LangChain4j

  • Fast, deterministic unit tests for guardrails (no LLM calls) langchain4j-test
  • Fits CI: milliseconds per test

  • Optional: Scorer for behavior checks (semantic similarity / AI judge)

//

18

19 of 22

Workshop

Building secure AI agents with

Quarkus LangChain4j

  • Follow the readme & steps
    • Work in step 1 directory
    • Checkout solution directory if you are stuck
  • Determine your LLM
    • Ollama
    • OpenAI
    • Gemini
  • Ask questions!

//

19

20 of 22

Workshop

Building secure AI agents with

Quarkus LangChain4j

https://github.com/wjglerum/quarkus-ai-agent-workshop

  • Follow the readme & steps
    • Work in step 1 directory
    • Checkout solutions if you are stuck
  • Determine your LLM
    • Ollama
    • OpenAI
    • Gemini
  • Ask questions!

//

20

21 of 22

Any Questions?

Q & A

22 of 22

Thanks!

Radek Kargul

&

Willem Jan Glerum