Skip to content

Add minimal ACPAgent implementation for Agent-Client Protocol support - #1122

Closed
xingyaoww wants to merge 3 commits into
mainfrom
openhands-workspace-0owrps6e
Closed

xingyaoww wants to merge 3 commits into
mainfrom
openhands-workspace-0owrps6e

Conversation

@xingyaoww

@xingyaoww xingyaoww commented Nov 10, 2025 •

Copy link
Copy Markdown
Contributor

Summary

This PR implements a minimal ACPAgent that enables OpenHands to work with Agent-Client Protocol (ACP) servers like Claude-Code and Gemini CLI.

Key Features

Uses Official ACP Python SDK

  • Leverages the official agent-client-protocol Python SDK (https://github.com/agentclientprotocol/python-sdk)
  • Uses SDK's ClientSideConnection for process management and communication
  • Implements typed protocol models (InitializeRequest, NewSessionRequest, PromptRequest)
  • Benefits from SDK's JSON-RPC handling and protocol version management

LLM-Optional Architecture

  • ACPAgent does NOT require an LLM parameter (the ACP server manages its own LLM)
  • Inherits from AgentBase but bypasses OpenHands' LLM-based agent logic
  • Optional dependency: pip install openhands-sdk[acp]

Current Limitations

  • Does not yet support custom tools (raises NotImplementedError)
  • Does not yet support MCP config (raises NotImplementedError)
  • Does not yet support microagents
  • Does not yet support security analyzers

Implementation Details

  • ACPAgent class: Main agent implementation that spawns and communicates with ACP servers
  • _OpenHandsACPClient: Custom Client implementation for handling ACP protocol callbacks
  • Process Management: SDK's ClientSideConnection handles subprocess lifecycle
  • Message Handling: Converts OpenHands events ↔ ACP protocol messages

Testing

  • Added comprehensive unit tests for ACPAgent initialization and configuration
  • Tests verify unsupported features raise appropriate errors
  • All 65 agent tests passing
  • Tests handle optional SDK dependency gracefully

Example Usage

from openhands.sdk.agent import ACPAgent
from openhands.sdk.conversation import LocalConversation

# Create an ACPAgent that connects to Claude-Code
agent = ACPAgent(
    acp_command=["npx", "-y", "claude-code-acp"],
)

# Create a conversation
conversation = LocalConversation(agent=agent, workspace="/path/to/workspace")

# Send a message
conversation.send_message("Please analyze this codebase")
conversation.run()

Future Work

  • Add support for custom tools integration
  • Add support for microagents
  • Add support for security analyzers
  • Improve error handling and logging
  • Add integration tests with real ACP servers

Closes #590


Agent Server images for this PR

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.12-nodejs22 Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:b990b34-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-b990b34-python \
  ghcr.io/openhands/agent-server:b990b34-python

All tags pushed for this build

ghcr.io/openhands/agent-server:b990b34-golang-amd64
ghcr.io/openhands/agent-server:b990b34-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:b990b34-golang-arm64
ghcr.io/openhands/agent-server:b990b34-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:b990b34-java-amd64
ghcr.io/openhands/agent-server:b990b34-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:b990b34-java-arm64
ghcr.io/openhands/agent-server:b990b34-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:b990b34-python-amd64
ghcr.io/openhands/agent-server:b990b34-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-amd64
ghcr.io/openhands/agent-server:b990b34-python-arm64
ghcr.io/openhands/agent-server:b990b34-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-arm64
ghcr.io/openhands/agent-server:b990b34-golang
ghcr.io/openhands/agent-server:b990b34-java
ghcr.io/openhands/agent-server:b990b34-python

About Multi-Architecture Support

  • Each variant tag (e.g., b990b34-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., b990b34-python-amd64) are also available if needed

This commit introduces ACPAgent, a minimal Agent-Client Protocol (ACP)
client implementation that enables OpenHands SDK to communicate with ACP
servers like Claude-Code and Gemini CLI.

Key features:
- Implements AgentBase with ACP protocol support
- JSON-RPC 2.0 communication via stdin/stdout
- Subprocess management for ACP servers
- Session initialization and prompt/response flow
- Feature validation (raises NotImplementedError for unsupported features)

Files added:
- openhands-sdk/openhands/sdk/agent/acp_agent.py: Main implementation
- tests/sdk/agent/test_acp_agent.py: Unit tests
- examples/01_standalone_sdk/27_acp_agent_example.py: Usage example

Files modified:
- openhands-sdk/openhands/sdk/agent/__init__.py: Export ACPAgent

This is a minimal implementation focusing on basic protocol support.
Advanced features like microagents, custom tools, and security analyzers
are not yet supported.

Fixes #590

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Nov 10, 2025 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/agent
   acp_agent.py12810220%49, 60, 62, 70–72, 74–75, 77–78, 80–81, 83–84, 86–87, 89–90, 92–93, 95–96, 98, 100–102, 104, 106–115, 117, 119, 121–122, 124–125, 131, 187–188, 193–194, 199–200, 205–206, 211–212, 223–224, 229, 247, 255–256, 259–260, 264, 266, 279, 287, 295, 299–305, 319, 321–330, 332–335, 338, 341–342, 347, 352, 357, 360, 362–363, 365, 370, 375, 377
TOTAL12160570653% 

ACP servers like Claude-Code and Gemini CLI manage their own LLM
configuration internally, so the LLM parameter is not needed.

Changes:
- Override llm field in ACPAgent to be optional (default=None)
- Update all tests to not require LLM when creating ACPAgent
- Update example to remove LLM import and usage
- Add documentation explaining ACP servers manage their own LLM

All tests pass (5/5 ACPAgent tests, 65/65 agent tests total).

Co-authored-by: openhands <openhands@all-hands.dev>
- Replaced manual JSON-RPC implementation with official SDK's ClientSideConnection
- Added agent-client-protocol as optional dependency under [acp] extra
- Implemented _OpenHandsACPClient using SDK's Client interface
- Used SDK's typed protocol models (InitializeRequest, NewSessionRequest, PromptRequest)
- Simplified code by leveraging SDK's helper functions (text_block, PROTOCOL_VERSION)
- Updated tests to handle optional SDK dependency gracefully
- All 65 agent tests passing

The SDK-based implementation provides:
- Better type safety with official protocol models
- Automatic protocol version management
- Built-in JSON-RPC handling
- More maintainable codebase

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai

openhands-ai Bot commented Nov 10, 2025

Copy link
Copy Markdown

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Run tests
    • Check Documented Examples

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #1122 at branch `openhands-workspace-0owrps6e`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

@blacksmith-sh

blacksmith-sh Bot commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

[Automatic Post]: It has been a while since there was any activity on this PR. @xingyaoww, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up.

1 similar comment
@blacksmith-sh

blacksmith-sh Bot commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

[Automatic Post]: It has been a while since there was any activity on this PR. @xingyaoww, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up.

@xingyaoww xingyaoww closed this Dec 15, 2025
@simonrosenberg
simonrosenberg deleted the openhands-workspace-0owrps6e branch February 19, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a special ACPAgent which is a Agent-Client Protocol Client?

2 participants