Files
2026-11-06 21:43:16 +05:30

26 lines
1.6 KiB
Markdown

# agentic-patterns
Companion code for *Agentic Patterns in Spring AI: Routing, Orchestrator-Workers, Evaluator-Optimizer and Parallelization*
on [ankurm.com](https://ankurm.com). The five workflows from Anthropic's
[Building effective agents](https://www.anthropic.com/engineering/building-effective-agents) as plain `ChatClient` code,
tested against a scripted `ChatModel` that records every prompt. No API key, no network call to a model.
```bash
mvn test -pl agentic-patterns # from the repo root; rewrites output/01..13
bash agentic-patterns/scripts/run-all.sh # the same, plus output/14
```
Versions: Spring AI `spring-ai-client-chat` 2.0.2, Spring Boot BOM 4.1.2, JDK 25, JUnit 6.1.3. The parent pom still pins
2.0.1 and 4.1.1 for the other modules; this module overrides both in its own `<properties>`.
| File | Role |
|---|---|
| `PromptChain`, `Router`, `Parallelizer`, `Orchestrator`, `EvaluatorOptimizer` | One class per pattern, under `src/main/java/com/ankurm/agentic/` |
| `ScriptedChatModel` (test) | Rule-based fake `ChatModel`: scripted replies, recorded prompts, logical start/end ticks |
| `Scenarios`, `Transcript` (test) | The shared scripted conversations; writes `output/NN-*.txt` |
| `*Test` | One class per pattern, plus `CostTest` for the call-count table |
| `preview/ScopeProbe.java`, `scripts/probe-structured-task-scope.sh` | Standalone probe of `StructuredTaskScope` on JDK 25 (preview), writes `output/14` |
| `output/` | Captured transcripts quoted in the post |
Not covered: a real model's behaviour (the scripted replies prove the control flow, not the quality), streaming, and tool calling inside a step.