# af4j

A Java framework and runtime for building multi-agent AI systems on the JVM with explicit governance: human approval gates, spending budgets, tool access policies and durable execution that survives restarts.

af4j (AgentFlow4J) lets a JVM application build multi-agent workflows with explicit orchestration on Spring AI and the Spring ecosystem. A ToolPolicy restricts which tools an agent may call, a BudgetPolicy caps spend for a run, and an ApprovalGate pauses execution until a person approves a step; a CheckpointStore persists graph state so a run resumes from its last completed node after a restart, backed by JDBC or Redis.

It offers two API levels: a Squad API for dynamic routing with minimal setup, and a Graph API for explicit flows, loops and full control over multi-agent orchestration, including a coordinator agent and a parallel agent for fan-out. Other capabilities include a retry policy and failure classifier for resilience, and metrics, run logs and streaming events through Micrometer for observability.

A bundled sample runs a governed multi-agent customer-support workflow with no API key required, falling back to deterministic stubs, or calling Mistral when a key is set. It is installed through Maven or Gradle and released under the Apache-2.0 license.

Website: https://datallmhub.github.io/agentflow4j/
