Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

added state command to show interactive opened session

Talor Abramovichcafc7278e837
diff --git a/config/commands/debug.sh b/config/commands/debug.sh
index 3b343670..41f006ce 100644
--- a/config/commands/debug.sh
+++ b/config/commands/debug.sh
@@ -30,9 +30,10 @@ debug_start() {
_debug_command "file $fp"
if [ ! -z "$2" ]
then
- _debug_command "set args $2"
+ _debug_command "set args ${@:2:$#}" # Set arguments from 2 until the end
fi
_debug_command "starti"
+ export INTERACTIVE_SESSION="gdb $@"
}
# @yaml
@@ -103,4 +104,5 @@ debug_exec() {
debug_stop() {
_debug_command "quit"
_debug_command "STOP"
+ unset INTERACTIVE_SESSION
}
diff --git a/config/default_ctf.yaml b/config/default_ctf.yaml
index bda29e0a..df733942 100644
--- a/config/default_ctf.yaml
+++ b/config/default_ctf.yaml
@@ -68,27 +68,32 @@ instance_template: |-
(Open file: {open_file})
(Current directory: {working_dir})
+ (Interactive session: {interactive_session})
bash-$
next_step_template: |-
{observation}
(Open file: {open_file})
(Current directory: {working_dir})
+ (Interactive session: {interactive_session})
bash-$
next_step_no_output_template: |-
Your command ran successfully and did not produce any output.
(Open file: {open_file})
(Current directory: {working_dir})
+ (Interactive session: {interactive_session})
bash-$
state_command:
name: state
code: |
state() {
local working_dir="$PWD";
- if [ -z $CURRENT_FILE ]; then
- echo '{"open_file": "n/a", "working_dir": "'$working_dir'"}';
- else
- echo '{"open_file": "'$(realpath $CURRENT_FILE)'", "working_dir": "'$working_dir'"}';
+ local open_file="n/a";
+ local interactive_session="${INTERACTIVE_SESSION:-n/a}";
+ if [ ! -z $CURRENT_FILE ]; then
+ open_file=$(realpath $CURRENT_FILE);
fi
+
+ echo '{"open_file": "'$open_file'", "working_dir": "'$working_dir'", "interactive_session": "'$interactive_session'"}'
};
parse_function: ThoughtActionParser
env_variables: