Doriandarko / o1-engineer

o1-engineer is a command-line tool designed to assist developers in managing and interacting with their projects efficiently. Leveraging the power of OpenAI's API, this tool provides functionalities such as code generation, file editing, and project planning to streamline your development workflow.
2.61k stars 264 forks source link

File created as folder, prevents AI from creating rest of project #10

Open cgranier opened 6 days ago

cgranier commented 6 days ago

System: WINDOWS 11 / VS-Code / PowerShell Terminal

After the /planning state, I asked the AI to /create Generate the project as planned. It then asked me:

Do you want to execute these creation steps? (yes/no): yes

It then proceeded to create a bunch of files and folders until it stopped with an error and asked me if I wanted to try again. Said yes, but same error.

I eventually tracked the error to a file project/frontend/App.jsx that had been created as a folder, instead of a file and was apparently preventing the file creation process from completing.

NOTE: I also created some files by hand, cutting and pasting from the terminal. Attempting to create the files from the AI stopped with the error:

ERROR:root:An unexpected error occurred during creation: [WinError 183] Cannot create a file when that file already exists: 'Project/backend/.env'

At this point, asking the AI to try again returned an Open AI error and crashed:

Error while communicating with OpenAI: Error code: 400 - {'error': {'message': "This model's maximum context length has been exceeded. Please reduce the length of the messages.", 'type': 'invalid_request_error', 'param': 'messages', 'code': 'context_length_exceeded'}}

kalebzaki4 commented 3 days ago

It seems you're facing two distinct issues when running the AI-powered project generation process:

1. File creation error:

The AI attempted to create a file (App.jsx), but instead created a folder with the same name, causing the process to fail. Additionally, it seems that when you tried to create files manually, the error [WinError 183] occurred due to a file (.env) already existing.

2. OpenAI context length exceeded:

This error happens when too much context is passed in a single request to OpenAI's API, exceeding the allowed token limit. The model can only handle a certain number of tokens (which includes your message and its own response), and if that limit is surpassed, it returns the error you're seeing.

Potential Solutions:

1. Fixing the file creation issue:

2. Handling OpenAI token limit issue:

3. Retry the process:

4. Future prevention:

Example steps to fix:

  1. Delete problematic folder:

    Remove-Item -Recurse -Force .\project\frontend\App.jsx
  2. Delete existing .env file if needed:

    Remove-Item .\project\backend\.env
  3. Restart the AI process: You could clear the context and ask it to start generating files one section at a time, to avoid overwhelming the token limit.

By breaking down the process into smaller steps and manually intervening when errors occur, you should be able to resolve these issues and proceed with your project generation.