John Yang 43b105854d Add docs for how to write your own commands | 6 月之前 | |
---|---|---|
.. | ||
README.md | 6 月之前 | |
_split_string.py | 6 月之前 | |
cursors_defaults.sh | 6 月之前 | |
cursors_edit_linting.sh | 6 月之前 | |
defaults.sh | 6 月之前 | |
edit_linting.sh | 6 月之前 | |
search.sh | 6 月之前 |
In this document, we describe how to implement your own commands for the SWE-agent ACI.
To see examples of command implementations, open the .sh
and .py
files in this folder.
Every command subscribes to the following skeleton code.
# @yaml
# signature: [command] [argument(s)]
# docstring: [Brief description of what your command does.]
# arguments:
# [argument 1 name]:
# type: [type (i.e. integer, string)]
# description: [Brief description of this argument]
# required: [true|false]
# [argument 2 name]:
# ...
[command]() {
# Implementation here
}
$1
).arguments
section.signature
and docstring
.config/commands/default.sh
, you'll see we define the CURRENT_LINE
variable for the file viewer. This variable is modified across multiple commands, including open
, goto
, scroll_up
, scroll_down
, and edit
.edit
in config/commands/edit_linting.sh
).echo
). SWE-agent is implemented such that it does not look for a return value from these commands.After you define a command, there are a small set of additional steps to making it available for the agent to use.
First, within your config file...
config/commands/<file name>.sh
file to the command_files
field.parse_command
field to ParseCommandBash
or ParseCommandDetailed
. This key points to the functionality that generates how command documentation is shown to the agent.{command_docs}
in.
{command_docs}
in the system_template
, which is the first message shown to the agent for every task instance episode.{command_docs}
to the format_error_template
, which is shown if the response provided by a model is malformed.python run.py --model human_thought ...
) or automatically (i.e. python run_replay --traj_path ...
)demonstrations
argument.demonstration_template
to control how the demonstration is displayed to the agent.If you're not familiar with how SWE-agent configuration files work, we recommend checking out the
config
README.
Next, run your configuration and see how your agent uses the commands!
python run.py --config_file config/[your config].yaml ...