princeton-nlp / SWE-agent

SWE-agent takes a GitHub issue and tries to automatically fix it, using GPT-4, or your LM of choice. It solves 12.47% of bugs in the SWE-bench evaluation set and takes just 1 minute to run.
https://princeton-nlp.github.io/SWE-agent/
MIT License
11.9k stars 1.19k forks source link

Can SWE-agent run CURL commands? #632

Closed ivan4722 closed 5 days ago

ivan4722 commented 5 days ago

Describe the issue

Hi I'm trying to add some functionality to SWE agent in which the agent has to make a curl request, I was wondering if i can simply put the curl command format in config/default.yaml or if there is somewhere in the code I have to put an os style command.

Thanks!

Optional: Relevant documentation page

No response

klieret commented 5 days ago

yes you can add it, see docs https://princeton-nlp.github.io/SWE-agent/config/commands/

klieret commented 5 days ago

in fact, the LM can just run curl and it should work anyway

ivan4722 commented 4 days ago

in fact, the LM can just run curl and it should work anyway

Hi, I ran into some errors trying to run curl.

INFO     🎬 ACTION (primary)                                                    
         generate_graph pytest 7490 pytest-dev                                  

INFO     🤖 MODEL INPUT                                                         
         Payload: {"repo_name": "pytest", "pr_number": "7490", "repo_title":    
         "pytest-dev"}                                                          
         curl could not be found, attempting to install it...                   
         /root/commands/generate_graph: line 43: sudo: command not found        
         /root/commands/generate_graph: line 55: curl: command not found        
         Response:                                                              
         (Open file: /pytest-dev__pytest/test_xfail.py)                         
         (Current directory: /pytest-dev__pytest)                               
         bash-$                                                                 
INFO     input_tokens=11,790, output_tokens=175, instance_cost=0.58, cost=0.12  
INFO     total_tokens_sent=56,799, total_tokens_received=446, total_cost=0.58,  
         total_api_calls=5                                                      
INFO     💭 THOUGHT (primary)                                                   
         It seems that there was an issue with generating the dependency graph  
         due to the absence of `curl` and the inability to install it with      
         `sudo`. Since we cannot resolve this directly, let's proceed with the  
         next steps without the dependency graph. 

It seems the environment cannot run curl? Here is a snippet of the script I'm trying to run, I even tried adding a check to install curl but that did not work either.

    if ! command -v curl &> /dev/null; then
        echo "curl could not be found, attempting to install it..."
        if [ -x "$(command -v apt-get)" ]; then
            sudo apt-get update && sudo apt-get install -y curl
        elif [ -x "$(command -v yum)" ]; then
            sudo yum install -y curl
        else
            echo "Package manager not supported. Please install curl manually."
            return
        fi
    fi

    # Execute the curl command and print the response for debugging
    response=$(curl -L -X POST http://(IP ADDRESS):5000/generate_graph \
        -H "Content-Type: application/json" \
        -d "$payload")

    echo "Response: $response"

Anything I am missing? I assume the LM is using a linux environment so I am unsure why I can't run curl. I added the script as necessary per the docs.

klieret commented 4 days ago

you could build your own docker image instead of the default swe-agent one