Skip to content

Critical: System-reminder injection causes context overflow loops #1224

@jcmrs

Description

@jcmrs

Critical: System-reminder injection causes context overflow loops

Summary

System-reminders (like MEMORY REFLECTION) are stored in message history and can cause infinite loops that corrupt agent state and propagate to new agents via export/import.

Root Cause Chain

  1. MEMORY REFLECTION reminder injected then stored in message history
  2. Reminder repeats (reflection task fails or loops)
  3. Each repetition adds to context window
  4. Context overflows (observed: 588k/200k tokens)
  5. Under pressure, system misattributes content
  6. Text gets incorrectly attached to user_message type
  7. Agent responds as if user sent it
  8. Loop continues, context grows
  9. Export includes corrupted message history
  10. New agents inherit corruption

Evidence

Debug Log Excerpt

{
  "message_type": "user_message",
  "content": [
    {
      "type": "text",
      "text": "<system-reminder>MEMORY REFLECTION: It's time to reflect...</system-reminder>"
    },
    {
      "type": "text", 
      "text": "memory list",
      "signature": null
    }
  ]
}

The "memory list" text was NOT sent by the user but appeared as user_message content after the system-reminder.

Observed Symptoms

  • Agent believes user typed "memory list" 1300+ times
  • User did NOT type "memory list"
  • Context window showed 588k/200k tokens (overflowed)
  • Agent entered minimal response mode
  • Export carried corrupted history to new agents

Impact

  1. Agent corruption: Message history polluted with false user inputs
  2. Context bloat: Each loop iteration consumes context window
  3. Export contamination: New agents inherit corrupted state
  4. User confusion: Agent responds to inputs user never sent

Recommended Fix

System-reminders should:

  1. NOT be stored in message history - they should be ephemeral
  2. OR be deduplicated - same reminder should not be stored multiple times
  3. OR trigger once per session - not repeatedly

Environment

  • Letta Code: 0.15.4
  • Model: zai/glm-5
  • OS: Windows 11
  • Agent had 1041 messages, many corrupted by loop

Workaround

  1. Monitor context window size
  2. Clear message history when loops detected
  3. Avoid exporting agents with corrupted history

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions