AI Agent Stuck in Infinite Loop - Repeatedly Executes Same Terminal Command

Describe the Bug

The AI agent gets stuck in an infinite loop when executing terminal commands, repeatedly running the same command without recognizing that it has already been executed. This appears to be a context management issue where the AI loses track of its previous actions.

Steps to Reproduce

  1. Open a Flutter project in Cursor
  2. Ask the AI to run a test command (e.g., “Run the test file”)
  3. AI executes: dart run test/chatbot_api_test.dart
  4. After command completes, AI immediately runs the same command again
  5. This continues indefinitely until user clicks “Skip” button

Expected Behavior

  • AI should execute the command once
  • AI should recognize the command has completed
  • AI should proceed to next logical step or provide results

Screenshots / Screen Recordings

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.2.1 (user setup)
VSCode Version: 1.99.3
Commit: 031e7e0ff1e2eda9c1a0f5df67d44053b059c5d0
Date: 2025-07-03T06:16:02.610Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100

Additional Information

  • This happens specifically with terminal commands
  • The AI seems to lose context of what it has already executed
  • The issue appears to be related to the AI’s conversation memory/context management
  • Other users have reported similar issues with AI getting stuck in repetitive patterns

Does this stop you from using Cursor

No - Cursor works, but with this issue