Sonnet 4 code rambling

When using Sonnet 4, it seems to overcomplicate sometimes.
It’s really hard to identify how much of this is the model, and how much is what queries are being sent by cursor.

e.g had a simple issue (caused by LLM edit I missed), where this link changed from
src={/api/images/${scene.image_path}}
to
src={${scene.image_path}}

The effect was images stop showing.
Lazily I prompted Sonnet 4 a 404 error…

  1. It build a new module, i asked it to stop, fix the bug
  2. It build new helper functions, i replied with it just needed to fix the link
  3. It built a data converter function… i replied with data is correct
    4, 5, 6… lmao

Sometimes I try to push the LLMs back on track to see if they are capable of solving a problem that I have already easily identified.

The agent in Cursor is amazing, but it goes berserk sometimes.

Do you have “Thinking” enabled? Back in 3.7 I found it would go way beyond what I asked it “Thinking” was enabled… so I run with it disabled.

Delete your conversation and delete your indexing:

Delete your Conversation:
Top of Prompt window, select the “X”.

Delete INDEXING:
“Cursor/Settings/Cursor Settings/Indexing”

  1. Turn off “Index new folders by default”
  2. Select “Delete Index”.
  3. Reboot Cursor

Rebooting is likely not needed, It’s what I choose to do.

1 Like

I’m gonna bump this again, agent mode.
Without visibility into the queries Cursor is sending to LLMs, getting quality responses is becoming challenging.

e.g. , giving it a simple task

  1. search for all the html buttons in our code
  2. make sure they are using our standard button css in or file.css

Sometimes it works.
Sometimes you get new pages, hundreds of lines of modified code, it goes on to looking up unrelated issues, once it hits a lint error its off the races.

The “language” returned from cursor / sonnet is sometimes unpredictable.
It will stuff whole new frameworks into code!
The other day, a whole node page turned into an .innerHTML + "… , which I missed at first glance because im dumb.

Yes, I can put tons of context into every request.
However, this issue is not a problem (usually) when using the LLMs from their respective web sites.

Please give visibility to the context being sent to LLMs, and the queries your generating. After all, this is just an automation tool :wink:

Does that happen also with a new chat?

If yes, please check rules (user, project, cursor) if they contain contradicting or too many requirements. This can confuse AI sometimes.

Its usually not necessary with Sonnet 4 (thinking or not) to attach too much, in many cases that would lead to the opposite effect, lots of info in context confuses AI.

Which Cursor version are you on?

(I cant comment on internal details as I’m not aware of those)

Latest version, just updated today in fact.

Simple example happened just now… adding a simple “status” on a button api request, this is the code it produced

generateBtn?.addEventListener('click', async function() {


with a lot of code behind that doing, something, that didnt work.

rather than

    <button onclick="generateVideo()"      

This was agent mode, sonnet 4, no context but the code page itself.

I paste the same code and request into Claude, it doesn’t do strange things.
Perhaps I’m misusing cursor…

Thanks

How would the model know it has to use generateVideo() ?

…because that was the function it generated. onclick is better than 20 lines of dynamic js after the page loads, unless there’s a reason. Plus it didnt actually work.

Another example…

< script >
const { showErrorAlert } = await import(‘../lib/utils/alerts’);

This is invalid code, node inside client side script.
This is 2 lines properly written, import, call alert, cursor gives me 20 that isn’t valid code.

This is not a complicated page, it has 1 button, 1 api call.

Not sure why I’m getting these results.

Yes what you explain is logical and makes sense.

Do you see Agent using any rules in the Chat or do you have any attached?

Nope, checked. No rules, no .cursorrules in this project.

Just to be clear, I can get LLMs to do anything I need with well crafted prompts. Including in cursor. In fact, adding “simple, clean, working code” to prompts helps when using cursor. So I’m not complaining, just trying to help fine tune whatever magic your doing between me and the AI machine. It gets lost sometimes… as do we all

Thanks for the clarification. Since I dont have insight into Cursors internal workings I also work with same circumstances as you.

Here is how my usage of Cursor changed with Sonnet 4, detailed experience noted there:

Last pop on this topic… :slight_smile:
Just swapping out a lib in a docker project, opencv for ffmpeg, no big deal.

For some reason, Cursor created the MD readme file below. This is on top of the lengthy reply in the cursor tab, which does a good job of explaining what it did.
This was not in anyway requested, sonnet doesn’t do this by itself, its just… more stuff. Code rambling.

Documentation is fine, especially when asked for, but this is just wasted time and GPU.

Thanks for your hard work over there!


:rocket: MoviePy Deployment Verification Guide

Fixed Issues

:white_check_mark: Dockerfile Fixed: Removed non-existent libx264-163 package

:white_check_mark: OpenCV Environment: Removed OpenCV-specific environment variables

:white_check_mark: MoviePy Code: Updated video_creator.py to use MoviePy instead of OpenCV

Deployment Commands


# Stop containers

docker-compose down

# Build with fixed Dockerfile (should work now)

docker-compose build --no-cache

# Start updated containers

docker-compose up -d

# Monitor logs

docker-compose logs -f video-service

:white_check_mark: Success Indicators in Logs

OLD (OpenCV - BAD):


INFO videogen.video_creator:create_video:24 | Creating video...

[ERROR:[email protected]] global cap_ffmpeg_impl.hpp:3133 open Could not find encoder for codec_id=27

INFO videogen.video_creator:create_video:36 | - Codec: avc1

ERROR videogen.video_creator:create_video:40 | ❌ VideoWriter failed to initialize!

NEW (MoviePy - GOOD):


INFO videogen.video_creator:create_video:24 | Creating video...

INFO videogen.video_creator:create_video:135 | Generating frames in memory...

INFO videogen.video_creator:create_video:139 | Creating video file with MoviePy...

INFO videogen.video_creator:create_video:151 | ✅ Video file created successfully

:magnifying_glass_tilted_left: Key Changes Made

  1. requirements.txt: opencv-python-headlessffmpeg-python

  2. video_creator.py: cv2.VideoWritermoviepy.ImageSequenceClip

  3. util.py: Returns file paths instead of cv2.VideoCapture

  4. transition.py: Returns PIL Images instead of BGR arrays

  5. Dockerfile: Removed non-existent libx264-163 package

:police_car_light: If Still Seeing OpenCV Errors

The container is still using old cached code. Force rebuild:


docker-compose down

docker system prune -f

docker-compose build --no-cache --pull

docker-compose up -d

:bullseye: Test Video Creation

After deployment, test with a video request and look for:

  • No OpenCV error messages

  • “Creating video file with MoviePy…” message

  • Successful video generation without codec errors

1 Like