Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[DEVOXXBE] From AI to Agent: A Field Guide to A...

Avatar for Loïc Loïc
October 04, 2026

[DEVOXXBE] From AI to Agent: A Field Guide to Agentic Patterns in LangChain4j

You have already built AI features into your Java application. The model is wrapped in a service, RAG feeds it context, tools are wired, calls are flowing. It works. Then requirements evolve. A single prompt-and-response is no longer enough. You need steps that follow each other, branches based on decisions, retries when things fail, sometimes several actions at once. The question shifts from "how do I call an LLM?" to "how do I keep it under control?".

That is where agentic systems come in. In three hours we start with a single @Agent doing one job and grow it live into a multi-agent system that can analyze, plan, act, and report back. Each step starts naive. We run it, feel the cracks, then reach for the pattern that holds: sequential, loop, parallel, and conditional workflows. AgenticScope and typed keys keep shared state honest. Goal-oriented agents, an LLM-driven supervisor, and a custom Planner take over when a fixed pipeline stops being enough. We add non-AI agents for deterministic work, human-in-the-loop checkpoints before external actions, and observability with the AgentMonitor, because an agent you cannot see is an agent you cannot debug.

You will leave able to look at a problem and tell whether it wants a plain workflow or a real agent, and how much autonomy to hand over before you lose the thread. The goal is not smarter prompts. It is agentic systems easier to reason about and evolve, because the pattern you do not adopt is the one you do not have to debug.

Avatar for Loïc

Loïc

October 04, 2026

More Decks by Loïc

Other Decks in Programming

Transcript

  1. AI Service @UserMessage(""" Turn this message into a sitter card

    with exactly these five lines. Invent nothing — if the message does not say, write "not given": Dog: Meals: Walks: Watch out for: Vet: Message: {{message}}""") String card(@V("message") String message); @LoMagnette
  2. Agent An agent is a service that talk to an

    AI model to perform a goalbased operation using the tools and context it has. @LoMagnette
  3. Agent @Agent(description = "Turns a rambling message about the dog

    into a structured sitter card") @UserMessage(""" Turn this message into a sitter card with exactly these five lines. Invent nothing — if the message does not say, write "not given": Dog: Meals: Walks: Watch out for: Vet: Message: {{message}}""") String card(@V("message") String message); @LoMagnette
  4. Loop Cons • Difficult exit condition • High cost •

    No guaranteed improvement @LoMagnette
  5. Parallel mapper Cons • Items must be independent • large

    batches are expensive • no ChatMemory @LoMagnette
  6. Routing Use cases • Expert routing • Risk routing •

    Format/language routing @LoMagnette
  7. Routing Cons • Depends on routing state • Zero or

    multiple matches • Incompatible branch outputs @LoMagnette
  8. Typed key public record Checklist() implements TypedKey<String>{} var list =

    AgenticServices.agentBuilder(FridgeChecklist.class) .chatModel(model) .name("FridgeChecklist") .outputKey(Checklist.class) .build();
  9. Goal Oriented Use cases • Adaptive document processing • Data-enrichment

    workflows • Deterministic tool pipelines @LoMagnette
  10. Goal Oriented Cons • Keys do not express semantic quality

    • Shortest does not mean best • Limited runtime adaptation @LoMagnette
  11. Peer to peer Use cases • Collaborative research • Reactive

    data enrichment • Emergent multi-expert problem-solving @LoMagnette
  12. Peer to peer Cons • Cycles and invocation explosions •

    Concurrent write conflicts • Unpredictable execution and cost @LoMagnette
  13. Blackboard Cons • The strategy becomes a bottleneck • Sequential

    execution can be slower • Stable state does not guarantee success
  14. Voting Cons • Correlated errors • Aggregation problems • Higher

    cost without guaranteed improvement @LoMagnette
  15. Debate Cons • High cost and latency • Agreement does

    not guarantee truth • Convergence remain difficult
  16. Desire Belief Intention Use cases • Autonomous operational response •

    Robotics or game characters • Business or portfolio management @LoMagnette
  17. Desire Belief Intention Cons • Complex desire design • Plans

    are predefined • Starvation and preemption complexity @LoMagnette
  18. Where to start WORKFLOW GOAP, P2P, Voting,… SUPERVISOR Control High

    Medium Low (LLM) Flexibility Low Medium-High High Cost Low Medium High Auditability Excellent Good Difficult Best for Stable pipeline Variable deps Adaptive systems Deterministic Autonomous Start here @LoMagnette
  19. Where to start “the pattern you do not adopt is

    the one you do not have to debug” @LoMagnette