Build and demo Java AI agent systems with langchain4j-agentic: workflow patterns, supervisor, custom Planner strategies (incl. the flagship typed-verdict / CriticResult-style critic pattern), plus MCP tools, A2A remote agents, build setup, and conference-demo storylines. Pinned to 1.15.0 / 1.15.0-beta25.
89%
Does it follow best practices?
Impact
100%
4.76x2 of 3 eval scenarios. Add 1 more for a full score.
Passed
No findings from the security scan
Build agentic AI systems in Java with langchain4j-agentic: deterministic workflows, the LLM-driven supervisor, and custom Planner strategies — including the flagship typed-critic pattern this demo is built around. Extends to langchain4j-mcp (tools) and langchain4j-agentic-a2a (remote agents).
Use for LangChain4j Java agent work. Not for Spring AI, Google ADK-Java, raw Anthropic/OpenAI SDK without LangChain4j, or Python LangChain.
The module is experimental; builder names and coordinates drift between betas. Run scripts/check_versions.sh before writing build files. Confirmed current (2026-05-25, via maven-metadata.xml):
| Artifact | Version | Notes |
|---|---|---|
langchain4j-bom / langchain4j / -anthropic / -open-ai | 1.15.0 | GA; BOM aligns core only |
langchain4j-agentic / -agentic-a2a / -agentic-patterns / -mcp | 1.15.0-beta25 | pin explicitly — NOT in the BOM |
The stable BOM does not manage the beta artifacts — pin each independently or you get NoSuchMethodError at runtime. See docs/tools-memory-and-build.md.
The centerpiece is Custom Strategy with Domain Modeling — docs/custom-strategy-critic-result.md. A verifier agent returns a typed result object (illustrated as CriticResult — application code, not a framework type, and need not be generic) carrying a pass/fail verdict, feedback, and the typed payload, which deterministically drives Identify → Fix → Verify → Adjust: pass → finish emitting the typed payload; fail → adjust with the feedback, re-verify. Domain-modeling the object that flows between agents (instead of a bare double score) makes routing compile-checked and the success branch fully typed. When the user is building "the demo", this is the pattern to reach for.
AgenticServices is the single factory. Static methods return a builder per pattern; everything is explicit construction. Full inventory in docs/index.md.@Agent decorates a method on an interface using @UserMessage/@SystemMessage/@V. Tools use the existing @Tool/@P from langchain4j-core — there is no agentic-specific tool annotation. Agents are AiServices with orchestration on top.AgenticScope is the shared blackboard. Agents publish via outputKey="k", downstream agents read via @V("k"). Created per top-level invocation; records invocation history.sequence/loop/parallel/conditionalBuilder = fixed topology. supervisorBuilder hands control to an LLM planner. plannerBuilder = your own algorithmic strategy (the flagship lives here). Show the contrast on stage.AgentListener for hooks, AgentMonitor + HtmlReportGenerator.generateReport(monitor, Path) for an HTML topology+timeline — the framework's strongest visual moment.assets/build.gradle.kts). Maven only on request.-parameters — without it @V("name") binds null silently. Already set in the template.gpt-4o-mini ready as a hot-swap fallback. Bigger model for planners/critics, smaller for workers..maxSequentialToolsInvocations(10) is mandatory on any tool-using agent (runaway-loop guard).MessageWindowChatMemory.withMaxMessages(20) when memory is needed.HtmlReportGenerator one-liner.| Need | Use | Doc |
|---|---|---|
| Typed verify/adjust loop driven by a domain verdict | ⭐ custom Planner + typed verdict object (CriticResult-style) | custom-strategy-critic-result.md |
| Fixed order, piping outputs | sequenceBuilder | workflow-patterns.md |
| Iterate until condition met | loopBuilder | workflow-patterns.md |
| Independent agents concurrently | parallelBuilder / parallelMapperBuilder | workflow-patterns.md |
| Route by condition | conditionalBuilder | workflow-patterns.md |
| Pause for human approval | humanInTheLoopBuilder | workflow-patterns.md |
| LLM plans which agent runs | supervisorBuilder | pure-agentic.md |
| Goal-graph / peer-to-peer / voting | plannerBuilder + Planner | pure-agentic.md |
| Annotation-driven definition | declarative API | declarative-api.md |
| External tools / remote agents | MCP toolProviders / a2aBuilder | mcp-and-a2a.md |
| Build/deps/tools/memory/models | — | tools-memory-and-build.md |
| Conference talk / workshop | four-act structure | demo-storylines.md |
| Debugging / stage rehearsal | top-10 risks | gotchas.md |
AgentListener callbacks take AgentRequest/AgentResponse; inheritedBySubagents() defaults to false.Planner is init/firstAction/nextAction returning Action via call(...)/done() helpers.SCORED uses a scorer agent ranking the summary vs. the last output — not "sub-agents return scores."outputKey / typedOutputKey (older examples use .outputName(...)).assets/build.gradle.kts — Gradle Kotlin DSL build (BOM + explicit beta pins, both LLM clients, -parameters).assets/App.java — ~80-line runnable bootstrap (one @Agent, two @Tools, AnthropicChatModel, AgentMonitor, HTML report).scripts/check_versions.sh — query Maven Central for current GA + beta of every artifact.Always cross-check generated code against the official source: langchain4j/docs/docs/tutorials/agents.md.