OpenHands 通用软件开发智能体的 8 个用例
8 Use Cases for Generalist Software Development Agents | Jan 16, 2025
OpenHands 官方博客列出通用软件开发智能体的 8 个用例:修 Bug、实现新功能、从零创建程序、修复失败的 CI、解决合并冲突、写文档、执行部署,以及通过 GitHub API 查看 issue、浏览文件系统并运行代码。文中以修复 CloudFlare 阻断 LLM 请求导致重试的 Bug 为例,展示智能体先定位问题、装依赖、用测试复现再修复,最后开 PR 并自动修 CI。部分任务已作为 microagents 内置在 OpenHands 中。
正文
当前显示原文,中文全文译文尚未就绪。
We are developing OpenHands, an agent for software development that has the ability to write code, execute code, and browse the web. It is very general and can do a lot of tasks, which is a double-edged sword:
On the plus side, this makes the agent framework very powerful, and once you learn how to use it you can do most anything; On the minus side, it means that sometimes we've found users to be at a loss of how to start using it
This blog post is meant to showcase some great use cases that we've found for OpenHands and provide some sample prompts that we have used. We'd also like to point out that OpenHands has a flexible framework for prompt customization using "microagents", and some of these tasks are available as micro-agents within OpenHands itself as well.
Let's see what a generalist software development agent can do, and how to skillfully prompt it to do a good job!
Fix Bugs
All non-trivial software has bugs, and we want to squash them when we can find them. Here's an example of a bug from OpenHands (where LLM requests being blocked by CloudFlare caused the agent to make many futile retries) that we fixed using the OpenHands agent, resulting in this pull request.
OpenHands has the ability to view github issues through the github API, browse the file system, and run code so when I want to fix a bug with OpenHands, I will often first select the repo that I'm working on, then give it a prompt like the following:
Let's break this down a bit, it is in several steps:
Bug Localization: In step 1, we asked the agent to find the place to modify. It will do this by using search tools like find and grep to try to identify the appropriate location in the codebase; Environment Setup: Step 2 initializes the project environment by installing dependencies. Of course the instructions will be a little different for your own project; Test-driven Development: TDD is a practice where you develop tests first and then do implementation afterwards. In general it's a good practice for human developers as it lays out expectations and makes for fast iteration cycles, but unfortunately human developers don't really like writing tests, especially beforehand. Fortunately, agents have no such issues, so in step 3 and 4 we have them reproduce the error in tests first and then fix the bug; Implementation and Testing: In step 5, we ask the agent to fix the issue and confirm that everything works. Often the agent will go through several iterations here before getting a good working implementation; Pushing to Github: In step 6 we have the agent open a PR to github for human review; Checking and Fixing CI: One thing that developers often hate to do is fix up failing CI actions. Fortunately agents can do that for you too! The agent can monitor github actions, see if any are failing due to the PR, and go in and fix them autonomously until they pass
Implement Features
In addition to squashing bugs, you also often want to implement new features. Here's an example of a feature that was implemented by the OpenHands agent – tooltips for a sidebar in the OpenHands app. When implementing features, it's reasonable to use a prompt pretty similar to the one we use for fixing bugs, for similar reasons:
Create Programs from Scratch
While the two above use-cases are for improving apps that already exist, sometimes you want to build an app from scratch. This is also possible with OpenHands. The easiest way to do this is to create an empty github repo with just a README, open it, and then put in a prompt describing the app that you want to create. Here are a couple of examples from things I've created recently.
A frontend app for viewing github PRs:
A script for sending emails via resend.com:
One thing to note here is that I always ask the model to write tests and execute them to make sure that it works. This is good test-driven development practice, as I mentioned before, but also makes it fast for the agent to iterate and fix any syntax or logic errors involved without having to give the agent credentials or access to real data.
Fix Failing Continuous Integration
One task that software engineers dread is fixing failing continuous integration tests like these ones:
The reason why this is so annoying is because often you need to fix the issue then push to github, see that it's not passing, click through the interface, read the logs, fix the issue, push again, etc.
OpenHands has actually been pretty revolutionary for me in this department, because you can just ask it to do this process for you with a prompt like the one below:
More than half of the time, this solves my problem and I don't have to fix tests myself!
Fix Merge Conflicts
In addition to fixing continuous integration, another huge pain is fixing merge conflicts, where someone else has pushed to the main branch but it conflicts with your own files. Fortunately, OpenHands is pretty good at fixing these too, here's an example:
This is another huge developer pain that agents can really help with!
Write Documentation
Another task that all developers know needs to be done but often gets overlooked is writing documentation. It's pretty simple to request that OpenHands write documentation for you, and it's usually pretty good at creating a first draft.
Perform Deployments
For many, building frontend and backend apps is a lot of fun, but the fun stops when you have to actually deploy this app to the cloud. OpenHands can help with this too! I have used OpenHands to help with deployments in two ways.
First, you can use OpenHands to directly call cloud APIs to bring up a machine. For instance, when I wanted a GPU machine to use I just said:
As anyone who has done this through the AWS UI before can attest, this sort of thing requires a lot of clicks and can be a major time sink.
Another option for performing deployments is to use infrastructure as code, where you specify the type of infrastructure you want as code, and execute the code to actually create the infrastructure. One common language for specifying infrastructure as code is Terraform, which is a very nice and powerful language, but also requires learning somewhat esoteric syntax. Fortunately, OpenHands is also pretty good at writing this code, so you can ask something like this:
One big caveat to this is that bringing up cloud machines has serious implications for security, cost, etc., so before using this sort of technique in a production setting, the code should be carefully vetted by an experienced and responsible developer.
Perform Data Analysis
Finally, OpenHands is quite useful at performing random data analysis tasks. Here's an example where we wanted to see the number of commits and unique contributors to the OpenHands repo by week, including how frequently OpenHands itself has contributed to its own repo.
This was very easy to do with the following prompt:
And here is the resulting figure!
Conclusion
This blog post covered 8 common use cases where we've been using OpenHands a lot and found it to be pretty valuable. There are others of course, we have heard reports of using OpenHands to run machine learning experiments, create presentation slides, and do many other things as well!
What Is An AI Dark Factory? What Lights-Out Manufacturing Teaches Us About Software
Insights and updates from the OpenHands team
Thank you for your submission!
OpenHands is the foundation for secure, transparent, model-agnostic coding agents - empowering every software team to build faster with full control.