groundy
agents & frameworks

How to Build Your First Autonomous Coding Agent with OpenHands SDK

Build autonomous coding agents with the OpenHands SDK: architecture, deployment modes, benchmark standing, and where it fits the 2026 agentic-coding field.

10 min···6 sources ↓

The landscape of software development has shifted substantially since IDEs first automated compilation and debugging. According to recent GitHub surveys, 92% of developers are already using AI coding tools in some capacity, with autonomous agents representing the next evolutionary leap beyond simple autocomplete and chat interfaces. These agents don’t just suggest code: they plan, execute, debug, and iterate independently, changing how software teams allocate engineering time.

Enter OpenHands, the open-source framework (formerly OpenDevin, before All Hands AI renamed it) that has emerged as the community standard for autonomous coding agents. With more than 78,000 GitHub stars as of June 2026 [Updated June 2026] and adoption by major enterprises, OpenHands represents a shift from proprietary black-box solutions to transparent, extensible, and model-agnostic agent architectures. This guide walks you through building your first autonomous coding agent using the OpenHands Software Agent SDK, a composable Python framework designed for everything from quick prototyping to enterprise-scale deployments.

What Is OpenHands and Why It Matters

OpenHands is a full ecosystem for AI-driven development, not a single product. The project encompasses four primary interfaces: the Software Agent SDK (the composable engine), a CLI for terminal-based workflows, a Local GUI with REST API and React frontend, and OpenHands Cloud for hosted deployments. What distinguishes OpenHands from alternatives is its architectural philosophy: stateless, immutable components with type-safe Pydantic models, designed for portable local-to-remote execution.

The SDK’s emphasis on coding distinguishes it from general-purpose agent frameworks like LangChain. While LangChain excels at chat-based support and back-office automation, OpenHands is purpose-built for software engineering. This focus shows up in benchmark performance: OpenHands has long ranked among the stronger scaffolds on SWE-bench, SWT-bench, and multi-SWE-bench evaluations, though those scores are a property of the backbone model as much as the harness. In late January 2026 the team introduced the OpenHands Index [Updated June 2026], a broader evaluation that tests LLMs across five software engineering domains: issue resolution (SWE-bench Verified), greenfield development (Commit0), frontend work (SWE-bench Multimodal), software testing (SWT-bench Verified), and information gathering (GAIA). The Index has become a widely cited harness for ranking models on coding tasks, with contributions from academic groups including Carnegie Mellon.

Critically, OpenHands is MIT-licensed and model-agnostic. Unlike proprietary alternatives such as Claude Code or OpenAI’s Codex that lock users into specific models, OpenHands works with any LLM, from Anthropic’s Claude and OpenAI’s GPT to open-source alternatives like Qwen, DeepSeek, and Mistral’s Devstral. Given the pace of model evolution, this flexibility isn’t merely convenient; it’s strategically essential.

Architecture Overview

The OpenHands Software Agent SDK (at v1.29.3 as of late June 2026, on a roughly weekly release cadence) [Updated June 2026] organizes functionality into four distinct Python packages, enabling developers to import only what they need:

PackagePurposeRequired
openhands-sdkCore agent framework + base workspace classesAlways
openhands-toolsPre-built tools (bash, file editing, etc.)Optional
openhands-workspaceExtended workspace implementations (Docker, remote)Optional
openhands-agent-serverMulti-user API serverOptional

The SDK supports two deployment architectures. Local Development mode runs everything in a single process with LocalWorkspace, requiring no Docker, ideal for prototyping. Production/Sandboxed mode uses RemoteWorkspace to auto-spawn agent servers in containers, enabling sandboxed execution for security, multi-user deployments, and distributed systems on Kubernetes.

The core execution flow follows a reasoning-action loop: the Agent calls the LLM for decisions, executes Tools to perform actions, and manages state through immutable Events. Components include the Agent (reasoning-action loop), Conversation (state management), LLM interface (provider-agnostic with retry logic and async completion support), Tool System (typed Action/Observation/Executor pattern), and Security module (action risk assessment).

Step-by-Step Tutorial

Let’s build a basic autonomous coding agent. First, install the prerequisites:

Terminal window
# Install uv package manager
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install the SDK
uv tool install openhands --python 3.12

Set your LLM credentials:

Terminal window
export LLM_MODEL="anthropic/claude-sonnet-4-6"
export LLM_API_KEY="your-api-key-here"

Now create your first agent:

import os
from openhands.sdk import LLM, Agent, Conversation, Tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.task_tracker import TaskTrackerTool
from openhands.tools.terminal import TerminalTool
# Configure the LLM
llm = LLM(
model=os.getenv("LLM_MODEL", "anthropic/claude-sonnet-4-6"),
api_key=os.getenv("LLM_API_KEY"),
base_url=os.getenv("LLM_BASE_URL", None),
)
# Create the agent with tools
agent = Agent(
llm=llm,
tools=[
Tool(name=TerminalTool.name),
Tool(name=FileEditorTool.name),
Tool(name=TaskTrackerTool.name),
],
)
# Set up workspace and conversation
cwd = os.getcwd()
conversation = Conversation(agent=agent, workspace=cwd)
# Send a task and run
conversation.send_message("Write 3 facts about the current project into FACTS.txt.")
conversation.run()
print("All done!")

For sandboxed execution, wrap the workspace in a Docker container:

from openhands.workspace import DockerWorkspace
from openhands.tools.preset.default import get_default_agent
with DockerWorkspace(
server_image="ghcr.io/openhands/agent-server:latest-python",
host_port=8010,
platform="linux/amd64", # or linux/arm64 for Apple Silicon
) as workspace:
agent = get_default_agent(llm=llm, cli_mode=True)
conversation = Conversation(agent=agent, workspace=workspace)
conversation.send_message("Refactor the codebase to use type hints.")
conversation.run()

The SDK provides 24+ examples covering custom tools, MCP integration, microagents, browser automation, and GitHub workflows. Each follows the same pattern: configure LLM → create Agent → add Tools → start Conversation → send message → run.

Comparison with Alternatives

The autonomous coding agent space features several notable contenders. Devin from Cognition AI made headlines as the first autonomous AI software engineer, but remains a closed commercial product with waitlist access. Claude Code from Anthropic offers a polished terminal experience but requires Claude models exclusively. GitHub Copilot provides excellent inline suggestions but lacks autonomous planning and execution capabilities.

OpenHands differentiates through openness and flexibility. Devin and Claude Code offer superior out-of-box polish, but lock users into proprietary ecosystems. OpenHands’ model-agnostic design lets teams switch between Claude, GPT, Gemini, DeepSeek, or local models like Devstral without rewriting agent logic. The SDK approach also enables deeper customization: teams can build entirely new developer experiences rather than being confined to pre-built interfaces.

Performance benchmarks need a caveat that vendor marketing usually drops: a coding agent’s score is mostly a function of the model behind it, not the scaffold alone. OpenHands has posted competitive numbers on SWE-bench Verified, reaching roughly 72.8% resolve rate with a Claude Sonnet backbone in late-2025 published runs, while the harness contributes task planning and decomposition, automatic context compression, and security analysis on top of whatever model is wired in. Frontier proprietary configurations now sit higher on the raw SWE-bench Verified leaderboard (Claude Opus 4.7 reported around 87.6% in April 2026), so OpenHands is best read as a strong, transparent harness rather than the single highest score on any one board. [Updated June 2026]

Where the OpenHands Index Stands in June 2026

The OpenHands Index is more useful than a single SWE-bench number because it spreads the test across tasks that fail in different ways. A model can resolve GitHub issues well and still flail at greenfield scaffolding or at the GAIA-style information-gathering tasks that reward patient tool use over raw code generation. The macro-average across the five categories is what the public leaderboard reports.

As of late June 2026, the top of that leaderboard is almost entirely Anthropic: Claude Fable 5 leads at roughly 81.0%, followed by Claude Opus 4.8 near 71.9%, Claude Opus 4.7 (Adaptive) around 69.7%, and Claude Opus 4.6 near 66.7%. The strongest non-Anthropic entry in the published snapshot is GPT-5.5 at roughly 65.9%. [Updated June 2026] The gap between Fable 5 and the rest is wider than the gap among the next four, which is the kind of separation that usually narrows once competitors tune their own agent scaffolds against the same tasks. Treat the absolute numbers as a snapshot, not a constant: the Index is re-run as new models ship, and a 36-day-old reading can move several points.

Two caveats matter when reading any of this. First, the harness that produces these scores is the same project that publishes the benchmark, which is a structural conflict worth naming even when the methodology is open. Second, agentic scores are sensitive to scaffolding choices (context-compression policy, tool set, retry budget) in ways that a base-model eval is not, so a one-point difference between two models on the Index is closer to noise than signal. The value of the Index is the shape of the per-category breakdown, not the leaderboard rank.

The 2026 Agentic-Coding Field

OpenHands does not compete in a vacuum, and the field around it consolidated hard over the first half of 2026. On the proprietary side, Cognition absorbed Windsurf and folded Devin-style autonomous review into more products, while Cursor pushed its own in-house models to reduce its dependence on any single frontier vendor. The practical effect for teams is that the Claude Code, Cursor, and Copilot tier now ships genuinely autonomous multi-step execution, not just inline completion, which erodes the feature gap that made open frameworks distinctive a year ago. The Windsurf-to-Cognition and Cursor-to-SpaceX talent moves also reshuffled who owns which agent stack.

Where OpenHands still wins is the axis those products structurally cannot match: ownership. Because it is MIT-licensed and runs any LiteLLM-routable model, a team can pin a specific open-weight model, run the whole loop inside its own VPC, audit every tool call, and avoid per-seat pricing that scales with headcount rather than usage. For regulated environments and for teams that treat model choice as a hedge against vendor pricing changes, that is the entire value proposition. It is also why OpenHands reads less like a Devin competitor and more like the agent-framework layer, closer in spirit to where general-purpose orchestration tools such as CrewAI and AutoGen sit, except specialized for the edit-run-test loop instead of generic task graphs.

The mechanism that makes the SDK durable under model churn is its event model. State lives in immutable Events, actions and observations are typed, and the LLM interface is a thin provider-agnostic shim. When a new model ships with a different tool-calling format or a larger context window, the change is contained to the LLM layer and the tool schemas, not smeared across the agent logic. That is the difference between a framework and a wrapper: a wrapper breaks when the model API moves, a framework absorbs it. The async-completion support and context-compression policy added over the v1.2x releases exist precisely because long agent runs hit context limits and rate limits in ways that short chat completions never do.

The honest limitation is reliability on long-horizon tasks. Autonomous agents still fabricate success, loop on the same failing edit, or quietly skip steps on multi-file refactors, and OpenHands inherits all of those failure modes from the underlying model. The security module’s action-risk assessment and the sandboxed RemoteWorkspace mitigate the blast radius of a bad action, but they do not make the agent correct. Teams deploying OpenHands in CI/CD should gate its output behind the same review and test discipline they would apply to a junior engineer’s pull request, because that is roughly the trust level the current generation earns.

Deployment Options

OpenHands offers deployment flexibility spanning local development to enterprise Kubernetes clusters:

Local GUI: Run openhands serve to launch a web interface at localhost:3000, complete with VS Code integration and browser automation via VNC.

CLI Mode: Execute openhands for a terminal experience comparable to Claude Code, supporting both interactive sessions and scriptable automation.

OpenHands Cloud: The hosted SaaS offering has a free Individual tier: bring your own LLM key or use OpenHands’ provider at cost with no markup, capped at 10 conversations per day. GitHub/GitLab/Bitbucket integrations, Slack/Jira connectivity, and multi-agent task delegation via TaskToolSet are included. Enterprise accounts get unlimited concurrent conversations, SAML/SSO, and private VPC deployment at custom pricing.

Self-Hosted Enterprise: For organizations requiring on-premise deployment, OpenHands Enterprise offers Kubernetes-based self-hosting with extended support and research team access. The enterprise version is source-available, with licensing required beyond one month of use.

SDK-First Deployment: For custom applications, the SDK enables programmatic deployment: embed agents in CI/CD pipelines, build internal developer tools, or create specialized coding assistants.

Conclusion and Future Outlook

The OpenHands Software Agent SDK represents a maturation point for autonomous coding technology. By combining research-grade performance with production-ready architecture, it bridges the gap between experimental prototypes and reliable developer tools. The framework’s emphasis on composability, model-agnosticism, and transparent execution addresses the real-world concerns of engineering teams evaluating AI agents.

Looking ahead, several trends will shape this space. Multi-agent collaboration, where specialized agents handle different aspects of development, will become standard; OpenHands’ TaskToolSet already supports sub-agent delegation in the current release. The integration of browser automation, as demonstrated by OpenHands’ VNC capabilities, points toward agents that can navigate full-stack workflows including frontend testing and documentation review. Security sandboxing will move from optional to mandatory as organizations deploy agents with broader system access.

For developers and engineering leaders, the message is clear: autonomous coding agents are transitioning from novelty to necessity. The OpenHands SDK provides the most transparent, flexible path to adopting this technology, whether you’re automating dependency updates, refactoring legacy codebases, or building entirely new AI-powered development experiences. With its open-source foundation and active research community, OpenHands is a credible, well-maintained foundation for whatever the autonomous coding stack looks like two model generations from now.


Sources:

sources · 6 cited

  1. OpenHands GitHub repositorygithub.comprimaryaccessed 2026-06-26
  2. OpenHands software-agent-sdk releasesgithub.comprimaryaccessed 2026-06-26
  3. The OpenHands Software Agent SDK (arXiv 2511.03690)arxiv.orgprimaryaccessed 2026-06-26
  4. Introducing the OpenHands Indexopenhands.devvendoraccessed 2026-06-26
  5. OpenHands Index benchmark scoresbenchlm.aianalysisaccessed 2026-06-26
  6. OpenHands Pricingopenhands.devvendoraccessed 2026-06-26