Agent Client

August 6, 2026 ยท View on GitHub

Important

This repository is no longer maintained.

Active development has moved to markpollack/agent-client. Current documentation is available at lab.pollack.ai.

This repository remains available for historical Spring AI Community releases. Its Apache 2.0 license and historical contents are unchanged. Please submit new issues and pull requests to the active repository.

Agent Client

Maven Central

What ChatClient did for completion endpoints, AgentClient does for agent CLIs.

Agent Client provides a unified Java API for autonomous CLI agents โ€” Claude Code, Codex, Gemini, Amazon Q, and Amp โ€” with Spring Boot auto-configuration support.

๐Ÿ“– Documentation | Getting Started | Reference | Tutorial

Quick Start

Add the dependency for your provider:

<dependency>
    <groupId>org.springaicommunity.agents</groupId>
    <artifactId>agent-claude</artifactId>
    <version>0.15.0</version>
</dependency>

Build a model, create a client, run a goal โ€” no Spring Boot required:

ClaudeAgentModel model = ClaudeAgentModel.builder()
    .defaultOptions(ClaudeAgentOptions.builder()
        .model("claude-sonnet-4-5")
        .yolo(true)
        .build())
    .build();

AgentClient client = AgentClient.create(model);
AgentClientResponse response = client.run("Create hello.txt with 'Hello from Agent Client!'");

With Spring Boot

Use a starter for auto-configuration:

<dependency>
    <groupId>org.springaicommunity.agents</groupId>
    <artifactId>agent-starter-claude</artifactId>
    <version>0.15.0</version>
</dependency>
@Component
public class MyAgent implements CommandLineRunner {
    private final AgentClient.Builder agentClientBuilder;

    public MyAgent(AgentClient.Builder agentClientBuilder) {
        this.agentClientBuilder = agentClientBuilder;
    }

    @Override
    public void run(String... args) {
        AgentClient client = agentClientBuilder.build();
        AgentClientResponse response = client.run("Fix the failing test");
    }
}

Supported Providers

ProviderStarterStatus
Claude Codeagent-starter-claudeProduction
Codexagent-starter-codexProduction
Gemini CLIagent-starter-geminiProduction
Amazon Qagent-starter-amazon-qBeta
Ampagent-starter-ampBeta

Multi-Provider Support

Switch providers without changing code โ€” use Maven profiles or swap the starter:

// This code works with ANY provider
AgentClient client = AgentClient.create(model);
AgentClientResponse response = client.run("Create hello.txt");

See Switching Providers for the Maven profile pattern.

Configuration

spring:
  ai:
    agents:
      mode: loose  # or strict
      claude-code:
        model: claude-sonnet-4-5
        timeout: PT5M
        yolo: true
      codex:
        model: gpt-5-codex
        full-auto: true
      gemini:
        model: gemini-2.5-flash
        yolo: true

See the Reference pages for all configuration options.

Architecture

agent-client/
โ”œโ”€โ”€ agent-client-core/               # AgentClient fluent API
โ”œโ”€โ”€ agent-models/                    # Provider adapters
โ”‚   โ”œโ”€โ”€ agent-model/                 # Core abstractions (AgentModel, AgentOptions)
โ”‚   โ”œโ”€โ”€ agent-tck/                   # Provider parity test kit
โ”‚   โ”œโ”€โ”€ agent-claude/                # Claude Code adapter
โ”‚   โ”œโ”€โ”€ agent-codex/                 # Codex adapter
โ”‚   โ”œโ”€โ”€ agent-gemini/                # Gemini CLI adapter
โ”‚   โ”œโ”€โ”€ agent-amazon-q/              # Amazon Q adapter
โ”‚   โ””โ”€โ”€ agent-amp/                   # Amp adapter
โ”œโ”€โ”€ provider-sdks/                   # CLI client libraries
โ”œโ”€โ”€ agent-starters/                  # Spring Boot auto-configuration
โ””โ”€โ”€ agents/                          # JBang-compatible agents

Two-Layer Design

  • AgentClient โ€” High-level fluent API (like ChatClient)
  • AgentModel โ€” Low-level provider interface (like ChatModel)

Provider selection happens at construction time. Everything after AgentClient.create(model) is portable.

Documentation

TypeLink
Getting StartedQuick start guide
TutorialStep-by-step lessons
ReferenceConfiguration options
Provider ReferenceClaude ยท Codex ยท Gemini
Defaults PhilosophyLOOSE vs STRICT modes
SessionsMulti-turn conversations

Building

./mvnw clean compile          # Compile
./mvnw clean test             # Unit tests
./mvnw clean verify -Pfailsafe  # Integration tests (requires CLIs + API keys)

License

Apache 2.0 โ€” see LICENSE.