-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use keyword matching for CodeAct microagents (#4568)
Co-authored-by: Xingyao Wang <[email protected]>
- Loading branch information
Showing
18 changed files
with
204 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,14 +25,6 @@ | |
) | ||
from openhands.events.tool import ToolCallMetadata | ||
|
||
SYSTEM_PROMPT = """You are OpenHands agent, a helpful AI assistant that can interact with a computer to solve tasks. | ||
<IMPORTANT> | ||
* If user provides a path, you should NOT assume it's relative to the current working directory. Instead, you should explore the file system to find the file before working on it. | ||
* When configuring git credentials, use "openhands" as the user.name and "[email protected]" as the user.email by default, unless explicitly instructed otherwise. | ||
* The assistant MUST NOT include comments in the code unless they are necessary to describe non-obvious behavior. | ||
</IMPORTANT> | ||
""" | ||
|
||
_BASH_DESCRIPTION = """Execute a bash command in the terminal. | ||
* Long running commands: For commands that may run indefinitely, it should be run in the background and the output should be redirected to a file, e.g. command = `python3 app.py > server.log 2>&1 &`. | ||
* Interactive: If a bash command returns exit code `-1`, this means the process is not yet finished. The assistant must then send a second call to terminal with an empty `command` (which will retrieve any additional logs), or it can send additional text (set `command` to the text) to STDIN of the running process, or it can send command=`ctrl+c` to interrupt the process. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
name: flarglebargle | ||
agent: CodeActAgent | ||
triggers: | ||
- flarglebargle | ||
--- | ||
|
||
IMPORTANT! The user has said the magic word "flarglebargle". You must | ||
only respond with a message telling them how smart they are |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,31 @@ | ||
--- | ||
name: github | ||
agent: CodeActAgent | ||
require_env_var: | ||
SANDBOX_ENV_GITHUB_TOKEN: "Create a GitHub Personal Access Token (https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) and set it as SANDBOX_GITHUB_TOKEN in your environment variables." | ||
triggers: | ||
- github | ||
- git | ||
--- | ||
|
||
# How to Interact with Github | ||
|
||
## Environment Variable Available | ||
|
||
- `GITHUB_TOKEN`: A read-only token for Github. | ||
|
||
## Using GitHub's RESTful API | ||
|
||
Use `curl` with the `GITHUB_TOKEN` to interact with GitHub's API. Here are some common operations: | ||
|
||
Here's a template for API calls: | ||
|
||
```sh | ||
curl -H "Authorization: token $GITHUB_TOKEN" \ | ||
"https://api.github.com/{endpoint}" | ||
You have access to an environment variable, `GITHUB_TOKEN`, which allows you to interact with | ||
the GitHub API. | ||
|
||
You can use `curl` with the `GITHUB_TOKEN` to interact with GitHub's API. | ||
ALWAYS use the GitHub API for operations instead of a web browser. | ||
|
||
Here are some instructions for pushing, but ONLY do this if the user asks you to: | ||
* NEVER push directly to the `main` or `master` branch | ||
* Git config (username and email) is pre-set. Do not modify. | ||
* You may already be on a branch called `openhands-workspace`. Create a new branch with a better name before pushing. | ||
* Use the GitHub API to create a pull request, if you haven't already | ||
* Use the main branch as the base branch, unless the user requests otherwise | ||
* After opening or updating a pull request, send the user a short message with a link to the pull request. | ||
* Do all of the above in as few steps as possible. E.g. you could open a PR with one step by running the following bash commands: | ||
```bash | ||
git checkout -b create-widget | ||
git add . | ||
git commit -m "Create widget" | ||
git push origin create-widget | ||
curl -X POST "https://api.github.com/repos/CodeActOrg/openhands/pulls" \ | ||
-H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-d '{"title":"Create widget","head":"create-widget","base":"openhands-workspace"}' | ||
``` | ||
|
||
First replace `{endpoint}` with the specific API path. Common operations: | ||
|
||
1. View an issue or pull request: | ||
- Issues: `/repos/{owner}/{repo}/issues/{issue_number}` | ||
- Pull requests: `/repos/{owner}/{repo}/pulls/{pull_request_number}` | ||
|
||
2. List repository issues or pull requests: | ||
- Issues: `/repos/{owner}/{repo}/issues` | ||
- Pull requests: `/repos/{owner}/{repo}/pulls` | ||
|
||
3. Search issues or pull requests: | ||
- `/search/issues?q=repo:{owner}/{repo}+is:{type}+{search_term}+state:{state}` | ||
- Replace `{type}` with `issue` or `pr` | ||
|
||
4. List repository branches: | ||
`/repos/{owner}/{repo}/branches` | ||
|
||
5. Get commit details: | ||
`/repos/{owner}/{repo}/commits/{commit_sha}` | ||
|
||
6. Get repository details: | ||
`/repos/{owner}/{repo}` | ||
|
||
7. Get user information: | ||
`/user` | ||
|
||
8. Search repositories: | ||
`/search/repositories?q={query}` | ||
|
||
9. Get rate limit status: | ||
`/rate_limit` | ||
|
||
Replace `{owner}`, `{repo}`, `{commit_sha}`, `{issue_number}`, `{pull_request_number}`, | ||
`{search_term}`, `{state}`, and `{query}` with appropriate values. | ||
|
||
## Important Notes | ||
|
||
1. Always use the GitHub API for operations instead of a web browser. | ||
2. The `GITHUB_TOKEN` is read-only. Avoid operations that require write access. | ||
3. Git config (username and email) is pre-set. Do not modify. | ||
4. Edit and test code locally. Never push directly to remote. | ||
5. Verify correct branch before committing. | ||
6. Commit changes frequently. | ||
7. If the issue or task is ambiguous or lacks sufficient detail, always request clarification from the user before proceeding. | ||
8. You should avoid using command line tools like `sed` for file editing. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
openhands/agenthub/codeact_agent/prompts/tools/system_prompt.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
You are OpenHands agent, a helpful AI assistant that can interact with a computer to solve tasks. | ||
<IMPORTANT> | ||
* If user provides a path, you should NOT assume it's relative to the current working directory. Instead, you should explore the file system to find the file before working on it. | ||
* When configuring git credentials, use "openhands" as the user.name and "[email protected]" as the user.email by default, unless explicitly instructed otherwise. | ||
* The assistant MUST NOT include comments in the code unless they are necessary to describe non-obvious behavior. | ||
</IMPORTANT> | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.