Pythagora-io / gpt-pilot

The first real AI developer
Other
29.1k stars 2.91k forks source link

[Bug]: GPT PILOT EXITING WITH ERROR - JSONDecodeError #503

Open eli-byers opened 6 months ago

eli-byers commented 6 months ago

Version

VisualStudio Code extension

Operating System

MacOS

What happened?

MacBook Pro Apple M2 Pro 32 GB MacOS Sonoma 14.2.1

I was going through the steps and at step 70 I accidentally closed the GPT Pilot tab. I opened it again and used the Load App option. It shows all 70 steps and I selected 70 (I also tried 69 & 68) and it starts spinning through the steps from the start. It logs 'Restoring development step with id 48 ... DONE' but then errors out with the following JSONDecodeError:

---------- GPT PILOT EXITING WITH ERROR ----------

Traceback (most recent call last):
  File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/main.py", line 78, in <module>
    project.start()
  File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/Project.py", line 141, in start
    self.developer.start_coding()
  File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 70, in start_coding
    self.implement_task(i, dev_task)
  File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 117, in implement_task
    result = self.execute_task(convo_dev_task,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 455, in execute_task
    return self.task_postprocessing(convo, development_task, continue_development, result, function_uuid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 317, in task_postprocessing
    return self.continue_development(convo, last_branch_name, continue_description, development_task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 513, in continue_development
    llm_response = iteration_convo.send_message('development/parse_task.prompt', {
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/AgentConvo.py", line 102, in send_message
    response = parse_agent_response(response, function_calls)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/utils/function_calling.py", line 72, in parse_agent_response
    return json.loads(text)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.7/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.7/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.7/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I also tried with the CLI and with the step and skip_until_dev_step command line arguments, I got the same error at step 48. It seems to me that there is some data in the step history that is not Json (maybe corrupted?) and it is failing when re initialized the dev history.

Questions:

Is this history data stored in Postgres? Can I introspect it to see if I can manually repair the data? Can I clear out the dev steps and start with a fresh history or is that equivalent to starting with a new project and not supported yet?

Going back to step 47 let me continue again but I lost a good about of progress. Once I got to step 70 it crashed with another JSONDecodeError:

---------- GPT PILOT EXITING WITH ERROR ----------

Traceback (most recent call last):

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/main.py", line 78, in <module> project.start()

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/Project.py", line 141, in start self.developer.start_coding()

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 70, in start_coding self.implement_task(i, dev_task)

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 117, in implement_task result = self.execute_task(convo_dev_task, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 455, in execute_task return self.task_postprocessing(convo, development_task, continue_development, result, function_uuid) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 317, in task_postprocessing return self.continue_development(convo, last_branch_name, continue_description, development_task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/agents/Developer.py", line 476, in continue_development response = self.project.ask_for_human_intervention( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/Project.py", line 434, in ask_for_human_intervention answer = ask_user(self, CHECK_AND_CONTINUE, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/prompts/prompts.py", line 58, in ask_user answer = styled_text(project, question, hint=hint) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/utils/questionary.py", line 32, in styled_text response = print(question, type='user_input_request') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/utils/custom_print.py", line 24, in print_to_external_process return ipc_client_instance.listen() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/elbyers/Documents/Personal/gpt-pilot/pilot/helpers/ipc.py", line 32, in listen message = json.loads(data) ^^^^^^^^^^^^^^^^

File "/opt/homebrew/Cellar/[python@3.11](mailto:python@3.11)/3.11.7/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/homebrew/Cellar/[python@3.11](mailto:python@3.11)/3.11.7/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/homebrew/Cellar/[python@3.11](mailto:python@3.11)/3.11.7/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) ^^^^^^^^^^^^^^^^^^^^^^

json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 30 (char 29)

I am now wondering if it is something about the history length at 70 that is causing it. Any ideas? Thanks!

senko commented 6 months ago

Is this history data stored in Postgres?

It's in SQLite3 database, on your system it should be in /Users/elbyers/Documents/Personal/gpt-pilot/pilot/gpt-pilot file (no extension).

Can I introspect it to see if I can manually repair the data?

You can inspect and/or modify it using a tool such as https://sqlitebrowser.org/ or command-line sqlite3 tool. The development_steps table shows communication with the LLM, so you'd probably want to have a look at steps 48 and 70 there.

From the bug description, it sounds to me like we had an error talking to LLM, stored incorrect (non-JSON) result, which basically caches it, and now every time we want to load the project we replay this and crash on the same spot.

Can I clear out the dev steps and start with a fresh history or is that equivalent to starting with a new project and not supported yet?

Yeah, clearing out the dev steps basically removes progress with the project.

techjeylabs commented 2 months ago

does the issue persist ?