---
title: "Java API Reference Code Agent SDK"
source: https://docs.autohand.ai/agent-sdk/java-api
---

# Java API Reference

Complete API reference for the Autohand SDK Java. The SDK spawns the Autohand CLI as a subprocess and communicates over JSON-RPC.

## Installation

Add the dependency to your `pom.xml`:

## High-Level API

### Agent

#### Agent Methods

### Run

## Low-Level API

### AutohandSDK

#### Key Methods

## CLI Runtime Control

Core lifecycle and auto-mode operations are available on `Agent`, `AutohandSDK`, and `RPCClient`. Use `AutohandSDK` or `RPCClient` for the complete approval, session, MCP, learning, tool-registry, and context surface.

-   **Conversation and handoff:** `reset`, `createBrowserHandoff`, `attachBrowserHandoff`, `attachLatestBrowserHandoff`
-   **Auto-mode:** `startAutoMode`, `getAutoModeStatus`, `pauseAutoMode`, `resumeAutoMode`, `cancelAutoMode`, `getAutoModeLog`
-   **Approvals and sessions:** `acknowledgePermission`, `respondDirectoryAccess`, `acknowledgeDirectoryAccess`, `decideChanges`, `getHistory`, `getSession`, `attachSession`
-   **Integrations and context:** `setYoloMode`, `setYoloModeAlias`, `setVscodeMcpTools`, `respondMcpInvocation`, `recommendLearn`, `updateLearn`, `generateLearn`, `getToolsRegistry`, `setContextCompact`

See [Control the CLI runtime](concepts/cli-runtime-control.html) for behavior, safety contracts, object placement, and the equivalent names in every CLI-backed SDK.

## Example Reference

Source-backed examples pulled from `/agentsdk/tin-wrapper/java/examples`.

## Events

Events are delivered through a `Consumer<Event>` callback. Key types:

-   `MessageUpdateEvent` - Streaming assistant text delta
-   `ToolStartEvent` - Tool execution started
-   `ToolEndEvent` - Tool execution completed
-   `PermissionRequestEvent` - Runtime pause for approval
-   `automode_iteration`, `automode_complete`, and `automode_error` - Auto-mode lifecycle
-   `ErrorEvent` - Error occurred

See [Hooks and events](concepts/hooks-and-events.html) for the complete normalized event contract.

## Error Handling

The SDK uses structured exceptions:

## See Also

-   [Java SDK Overview](java.html)
-   [CLI Quick Start](../guides/cli-quick-start.html)