Spring Boot starter and OpenAI-compatible model module behind a REST endpoint, tested against a fake provider on localhost. FakeOperationContext and EmbabelMockitoIntegrationTest examples, retry multiplication, a STUCK process surfacing as NullPointerException, two-goal agents, and plain Spring AI with the branches written. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6vDJ5fWY5uEZaJFNi
2.9 KiB
embabel: goal-oriented agents for Spring developers
Companion code for https://ankurm.com/embabel-goal-oriented-ai-agents-jvm/.
| Component | Version (checked on Maven Central 2026-12-04) |
|---|---|
Embabel embabel-agent-api, -starter, -starter-openai-custom, -test |
1.5.4 (released 2026-10-28) |
| Brought in by it | Spring AI 2.0.1, Spring Boot 4.1.1, OpenAI Java SDK 4.49.0 |
| JDK | 25 |
1.0.0 went GA on 2026-07-20 and was built on Spring Boot 3.5.14 and Spring AI 1.1.7. The 4.x line starts with 1.5.0.
Run
mvn test -pl embabel # 19 tests run, 2 slow ones skipped; no API key, no model
mvn test -pl embabel -Dslow=true # adds the two default-retry measurements, about 7 minutes of backoff
embabel/scripts/two-goals-across-jvms.sh # from the repository root
No real LLM was called. The model is either Embabel's ScriptedLlmOperations, its Mockito test base class,
FakeOperationContext, a scripted Spring AI ChatModel, or a fake OpenAI-compatible HTTP server on localhost.
The application is started from tests with SpringApplication.run; it was not launched from the command line and
was not pointed at a real provider. application.yml reads LLM_BASE_URL, LLM_API_KEY and LLM_MODEL; the request
path is the base URL plus /chat/completions.
Code
| File | What it is |
|---|---|
ResearchAgent, Domain |
three actions over four records |
GuardedResearchAgent, ForgetfulGuardedAgent |
a condition, and the same with the post left out |
CostAwareResearchAgent |
two ways to produce a Summary |
TwoGoalsAgent |
two @AchievesGoal actions in one agent |
PlainResearch, PlainGuardedResearch |
the same job in plain Spring AI, without and with the hand-written branches |
boot/ |
Spring Boot application, REST controller, profiles guarded and two-agents |
EmbabelTest, TestingLayersTest, MockitoBootTest, boot/BootTest |
the tests that write output/ |
Captured output
| File | Shows |
|---|---|
| 01, 02 | the planned order; a step skipped because its result was supplied |
| 03, 06 | a condition stopping a process; a condition no action establishes |
| 04, 17 | cost choosing the route; swapped costs swapping it |
| 05, 09 | same user prompts; different requests on the wire |
| 07 | dependency tree |
| 08, 23 | HTTP request end to end; request path with /v1 |
| 10, 22 | a STUCK process as a 500 with a NullPointerException; checking the status instead |
| 11 | two agents that both produce a Brief |
| 12, 13, 20, 21 | provider requests per invocation, default retries and turned down |
| 14 | unknown default model fails at startup |
| 15, 18, 19 | one action as a unit test; plain Spring AI branches; Mockito integration test |
| 16, 24 | a two-goal agent that sometimes stops at the wrong goal |
Wall times in 12 and 13 are indicative. Files 12 and 13 are only rewritten with -Dslow=true.