All-Hands-AI / OpenHands

🙌 OpenHands: Code Less, Make More
https://all-hands.dev
MIT License
34.42k stars 3.9k forks source link

[langchains agent] got an unexpected keyword argument 'content' #194

Closed borick closed 7 months ago

borick commented 7 months ago

Describe the bug

Steps to Reproduce

  1. start open-devin
  2. use it for a bit (see the log)

Expected behavior

PS C:\Users\boris\thirdparty\OpenDevin> uvicorn opendevin.server.listen:app --port 3000 INFO: Started server process [120364] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:3000 (Press CTRL+C to quit) INFO: ('127.0.0.1', 56342) - "WebSocket /ws" [accepted] INFO: connection open

============== STEP 0

    ACTION:
    CmdRunAction(command='ls', background=False)

    OBSERVATION:
    CONTRIBUTING.md
    LICENSE
    OpenDevinLogo.jpg
    README.md
    agenthub
    dev_config
    evaluation
    frontend
    opendevin
    requirements.txt
    workspace

============== STEP 1

    ACTION:
    AgentThinkAction(thought="It appears I don't have a project specifically related to creating a 2D roguelike game in the directory listing. I should consider starting from scratch. First step would be setting up a Python environment and checking if I have the necessary tools like Python and pip installed.", runnable=False)

    OBSERVATION:

============== STEP 2

    ACTION:
    CmdRunAction(command='python3 --version', background=False)

    OBSERVATION:
    Python 3.10.12

============== STEP 3

    ACTION:
    CmdRunAction(command='pip3 list', background=False)

    OBSERVATION:
    Package    Version
    ---------- -------
    pip        22.0.2
    setuptools 59.6.0
    wheel      0.37.1

============== STEP 4

    ACTION:
    AgentThinkAction(thought="Since Python and pip are installed, the next step should be creating a virtual environment to manage the game's dependencies separately. I'll need to use the `python3 -m venv` command to create the virtual environment.", runnable=False)

    OBSERVATION:

============== STEP 5

    ACTION:
    CmdRunAction(command='python3 -m venv roguelike-env', background=False)

    OBSERVATION:

============== STEP 6

    ACTION:
    AgentThinkAction(thought='With the virtual environment created, the next logical step is to activate it. This will ensure that any Python packages I install will be local to the project and not affect the global Python environment.', runnable=False)

    OBSERVATION:

============== STEP 7

    ACTION:
    CmdRunAction(command='source roguelike-env/bin/activate', background=False)

    OBSERVATION:

============== STEP 8

    ACTION:
    AgentThinkAction(thought='Now that the virtual environment is activated, I need to think about what libraries or tools could be helpful in creating a 2D roguelike game in Python. Libraries such as Pygame for game development or even curses for terminal based games could be very useful. I should decide which library to use and install it via pip.', runnable=False)

    OBSERVATION:

============== STEP 9

    ACTION:
    CmdRunAction(command='pip3 install pygame', background=False)

    OBSERVATION:
    Defaulting to user installation because normal site-packages is not writeable
    Collecting pygame
      Downloading pygame-2.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.0 MB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.0/14.0 MB 44.0 MB/s eta 0:00:00
    Installing collected packages: pygame
    Successfully installed pygame-2.5.2

============== STEP 10

    ACTION:
    AgentThinkAction(thought="Now that Pygame is installed, I should start by planning the basic structure of the roguelike game. I'll need to define how the game loop will work, design the player character, enemies, and power-ups. I also need to think about how the player will interact with these elements and how the game world will be represented. I believe using object-oriented programming concepts would be beneficial in organizing the code. Next, I'll start sketching out the classes and functions needed.", runnable=False)

    OBSERVATION:

============== STEP 11

    ACTION:
    FileWriteAction(path='game.py', contents='import pygame\nimport sys\n\npygame.init()\n\nsize = width, height = 640, 480\nscreen = pygame.display.set_mode(size)\n\nplayer = pygame.Rect(100, 100, 60, 60)\nplayer_speed = [2, 2]\nenemies = []\n\nwhile 1:\n    for event in pygame.event.get():\n        if event.type == pygame.QUIT: sys.exit()\n\n    player = player.move(player_speed)\n    if player.left < 0 or player.right > width:\n        player_speed[0] = -player_speed[0]\n    if player.top < 0 or player.bottom > height:\n        player_speed[1] = -player_speed[1]\n\n    screen.fill((0, 0, 0))\n    screen.fill((255, 0, 0), player)\n    pygame.display.flip()\n', base_path='')

FileWriteAction(path='game.py', contents='import pygame\nimport sys\n\npygame.init()\n\nsize = width, height = 640, 480\nscreen = pygame.display.set_mode(size)\n\nplayer = pygame.Rect(100, 100, 60, 60)\nplayer_speed = [2, 2]\nenemies = []\n\nwhile 1:\n for event in pygame.event.get():\n if event.type == pygame.QUIT: sys.exit()\n\n player = player.move(player_speed)\n if player.left < 0 or player.right > width:\n player_speed[0] = -player_speed[0]\n if player.top < 0 or player.bottom > height:\n player_speed[1] = -player_speed[1]\n\n screen.fill((0, 0, 0))\n screen.fill((255, 0, 0), player)\n pygame.display.flip()\n', base_path='.')

    OBSERVATION:
    File written to .\game.py

============== STEP 12

    ACTION:
    AgentThinkAction(thought='The basic game loop is now initialized with pygame, displaying a moving square which represents the player. However, to develop a roguelike game, I need to incorporate more components such as enemies, power-ups, and a method for level generation. Next, I should think about how to create a basic enemy class and how enemies will be introduced into the game. Additionally, adding collision detection between the player and enemies will be crucial for gameplay. Power-ups and their effects on the player should also be planned.', runnable=False)

    OBSERVATION:

============== STEP 13 Error in loop FileWriteAction.init() got an unexpected keyword argument 'content' Traceback (most recent call last): File "C:\Users\boris\thirdparty\OpenDevin\opendevin\controller__init.py", line 61, in start_loop finished = await self.step(i) File "C:\Users\boris\thirdparty\OpenDevin\opendevin\controller__init__.py", line 81, in step action: Action = self.agent.step(state) File "C:\Users\boris\thirdparty\OpenDevin\agenthub\langchains_agent__init__.py", line 177, in step action = prompts.parse_action_response(action_resp) File "C:\Users\boris\thirdparty\OpenDevin\agenthub\langchains_agent\utils\prompts.py", line 166, in parse_action_response action = ACTION_TYPE_TO_CLASSaction_dict["action"] TypeError: FileWriteAction.init__() got an unexpected keyword argument 'content' Exited before finishing Additional context It's all there, thank you

rbren commented 7 months ago

Looks like the LLM responded with JSON that's slightly off from what we expect (it used key content instead of contents).

We need better error handling here

rbren commented 7 months ago

Thanks for all the reports btw! This is super helpful.

PR opened here: https://github.com/OpenDevin/OpenDevin/pull/196

rbren commented 7 months ago

Should be fixed now!