> ## Documentation Index
> Fetch the complete documentation index at: https://springaicommunity.mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Client

> Portable Java API for autonomous CLI agents — Claude Code, Codex, Gemini, Amazon Q, and Amp

<Warning>
  This project has moved to [markpollack/agent-client](https://github.com/markpollack/agent-client).
  Current documentation is at [lab.pollack.ai/projects/agent-client](https://lab.pollack.ai/projects/agent-client).
  The content below may be outdated.
</Warning>

<img src="https://img.shields.io/badge/Status-Incubating-blue" alt="Incubating Status" />

[GitHub](https://github.com/spring-ai-community/agent-client) • [Maven Central](https://central.sonatype.com/search?q=g:org.springaicommunity.agents) • [Tutorial](https://github.com/spring-ai-community/agent-client-tutorial)

<Note>
  **Version 0.16.0** — Available on [Maven Central](https://central.sonatype.com/search?q=g:org.springaicommunity.agents)
</Note>

## What's New in 0.16.0

* **Framework-independent core** — `agent-client-core` has zero Spring Boot dependencies. Use from plain Java, Quarkus, or Micronaut.
* **`AgentApi` replaces `AgentModel`** — new name reflects that implementations wrap CLI runtimes, not AI models. `AgentModel` is deprecated with a shim.
* **New property prefix `agent-client.*`** — replaces `spring.ai.agents.*` to properly distance from Spring AI namespace. Example: `agent-client.claude.model` instead of `spring.ai.agents.claude-code.model`.
* **LOOSE mode sandbox bypass** — Codex LOOSE now derives `dangerouslyBypassSandbox=true`, fixing bwrap sandbox failures.
* **Codex model default** — updated to `gpt-5.4-mini` (replaces retired `gpt-5-codex`).
* **Gemini working directory fix** — request working directory now properly propagated to CLI process.

### Previous (0.15.0)

* **AgentClientMode** (LOOSE/STRICT) — portable enum controlling default permissiveness.
* **Provider Parity TCK** — `@ProviderCapability` annotation with JUnit Assumptions.
* **Reference documentation** — complete configuration reference for all providers.
* **Tutorial repository** — progressive examples at [agent-client-tutorial](https://github.com/spring-ai-community/agent-client-tutorial).

## Overview

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

Agent Client provides a portable Java API for autonomous CLI agents. Build a model, create a client, run a goal — provider selection happens at construction time, everything after is portable.

```java theme={null}
// Provider-specific: build the model
ClaudeAgentModel model = ClaudeAgentModel.builder()
    .defaultOptions(ClaudeAgentOptions.builder()
        .model("claude-sonnet-4-5")
        .yolo(true)
        .build())
    .build();

// Portable: works with any provider
AgentClient client = AgentClient.create(model);
AgentClientResponse response = client.run("Create hello.txt with 'Hello!'");
```

No Spring Boot required. Optional Spring Boot starters provide auto-configuration for those who want it.

## Supported Providers

<CardGroup cols={3}>
  <Card title="Claude Code" icon="terminal" href="/agent-client/reference/claude-reference">
    Anthropic's autonomous coding agent — 18 configuration options
  </Card>

  <Card title="Codex" icon="code" href="/agent-client/reference/codex-reference">
    OpenAI's code generation agent — LOOSE mode for frictionless setup
  </Card>

  <Card title="Gemini CLI" icon="sparkles" href="/agent-client/reference/gemini-reference">
    Google's Gemini models via CLI
  </Card>

  <Card title="Amazon Q" icon="cloud">
    AWS developer assistant (beta)
  </Card>

  <Card title="Amp" icon="wand-magic">
    Sourcegraph's AI coding assistant (beta)
  </Card>

  <Card title="Custom" icon="puzzle-piece">
    Implement `AgentModel` for any CLI agent
  </Card>
</CardGroup>

## Documentation

<CardGroup cols={2}>
  <Card title="Getting Started" icon="rocket" href="/agent-client/howto/getting-started">
    Plain Java quick start — create your first agent task
  </Card>

  <Card title="Tutorial" icon="graduation-cap" href="/agent-client/tutorial/index">
    Step-by-step lessons from first task to multi-provider
  </Card>

  <Card title="Reference" icon="book" href="/agent-client/reference/portable-options">
    Configuration options, precedence rules, mode system
  </Card>

  <Card title="Switching Providers" icon="arrows-rotate" href="/agent-client/howto/switching-providers">
    Run the same task with different providers using Maven profiles
  </Card>
</CardGroup>

## Key Features

<CardGroup cols={2}>
  <Card title="Portable API" icon="plug">
    `AgentClient.create(model)` works with any provider. Switch by swapping the model.
  </Card>

  <Card title="LOOSE/STRICT Modes" icon="sliders" href="/agent-client/explanation/defaults-philosophy">
    Control default permissiveness. LOOSE works anywhere, STRICT requires opt-in.
  </Card>

  <Card title="Agent Sessions" icon="comments" href="/agent-client/reference/sessions">
    Persistent multi-turn conversations with session lifecycle management.
  </Card>

  <Card title="Portable MCP Servers" icon="server">
    Define MCP servers once, run on any provider. Client resolves, model translates.
  </Card>

  <Card title="Agent Advisors" icon="layer-group">
    Interception points for context engineering, evaluation, security, and observability.
  </Card>

  <Card title="Spring Boot Starters" icon="leaf">
    Optional auto-configuration with `agent-starter-claude`, `agent-starter-codex`, etc.
  </Card>
</CardGroup>

## Quick Start

```xml theme={null}
<dependency>
    <groupId>org.springaicommunity.agents</groupId>
    <artifactId>agent-claude</artifactId>
    <version>0.15.0</version>
</dependency>
```

```java theme={null}
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("Fix the failing test in UserServiceTest");
```

See the [Getting Started](/agent-client/howto/getting-started) guide for all three providers and the Spring Boot path.

## Portable MCP Servers

Define MCP servers once in a portable format. Agent Client translates to each provider's native configuration at execution time.

```java theme={null}
McpServerCatalog catalog = McpServerCatalog.fromJson(Path.of("mcp-servers.json"));

AgentClient client = AgentClient.builder(model)
    .mcpServerCatalog(catalog)
    .defaultMcpServers("weather")
    .build();

// Per-request MCP server selection
client.goal("Research recent Spring AI releases")
    .mcpServers("brave-search")
    .run();
```

| Provider | Native mechanism                                             |
| -------- | ------------------------------------------------------------ |
| Claude   | `--mcp-config <path>` — temporary JSON config file           |
| Gemini   | `.gemini/settings.json` — settings file in working directory |

## Agent Advisors

The same advisor pattern as Spring AI's ChatClient — powerful interception for context engineering, evaluation, and security:

```java theme={null}
AgentClient client = AgentClient.builder(model)
    .defaultAdvisor(new WorkspaceContextAdvisor())
    .defaultAdvisor(JudgeAdvisor.builder().judge(coverageJudge).build())
    .build();
```

## Related Projects

<CardGroup cols={2}>
  <Card title="Agent Judge" icon="gavel" href="/projects/incubating/agent-judge">
    Standalone evaluation framework — Judge, Jury, and Score APIs
  </Card>

  <Card title="Agent Sandbox" icon="box" href="/projects/incubating/agent-sandbox">
    Isolated execution — Local, Docker, and E2B backends
  </Card>

  <Card title="Claude Agent SDK" icon="robot" href="/claude-agent-sdk/index">
    Low-level Java SDK for Claude Code CLI
  </Card>

  <Card title="Agent Bench" icon="chart-bar" href="/projects/incubating/agent-bench">
    Benchmarking framework for agent evaluation
  </Card>
</CardGroup>

## License

Apache 2.0 — [View on GitHub](https://github.com/spring-ai-community/agent-client/blob/main/LICENSE)
