The demo

Part of Java is Coming for Python’s Lunch - The Rise of JVM AI Agents. Slides 18–24.

The demo slide 18 ↗

one boring business process, reviewed by three agents

A trip is a plain JPA aggregate with its bookings slide 19 ↗

context

@Entity
class Trip(
    var traveler: String,
    var destination: String,
    var startDate: LocalDate,
    var status: TripStatus = TripStatus.DRAFT,
    @OneToMany(cascade = [CascadeType.ALL])
    val hotels: MutableSet<HotelBooking> = linkedSetOf(),
    @OneToMany(cascade = [CascadeType.ALL])
    val flights: MutableSet<FlightBooking> = linkedSetOf(),
    @OneToMany(cascade = [CascadeType.ALL])
    val trains: MutableSet<TrainBooking> = linkedSetOf(),
)

The rules are sentences written for people, not for code slide 20 ↗

context

Policy("Hotel budget",
    "Hotels may cost at most 180 EUR per night. " +
    "In London, Paris and Zurich the limit is 250 EUR per night.")

Policy("Rail first",
    "If the train journey takes 4 hours or less, the train must be used " +
    "instead of a flight. Second class only.")

Every agent reads the same facts through one read-only service slide 21 ↗

integration

@Service
@Transactional(readOnly = true)
class TravelFacts(private val trips: TripRepository, private val policies: PolicyRepository) {
    fun trip(tripId: Long): TripSnapshot
    fun policies(): List<PolicyText>
    fun costs(tripId: Long): CostBreakdown
}

Three agents, one contract slide 22 ↗

type safety

@Serializable
data class ReviewOutcome(
    val verdict: Verdict,
    val summary: String,
    val violations: List<String> = emptyList(),
)

interface TripReviewer {
    val agent: ReviewAgent
    fun review(tripId: Long): ReviewOutcome
}

Choosing the framework is one request parameter slide 23 ↗

reliability

POST /api/trips/2/submit?agent=EMBABEL
@Async
@TransactionalEventListener
fun on(event: TripSubmitted) {
    val review = reviewers.getValue(event.agent).review(event.tripId)
    reviews.save(TripReview(event.tripId, event.agent, review))
}

Every reviewer drafts, a judge audits, a rejection goes back slide 24 ↗

reviewer with tools draft judge without tools accepted ReviewOutcome feedback