Skip to content

Commit c1fe819

Browse files
authored
AutoGPT Recursive Self-Analysis Loop Detection (#149)
* added cre * added cre * added cre
1 parent 5dabcb8 commit c1fe819

File tree

4 files changed

+131
-1
lines changed

4 files changed

+131
-1
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
rules:
2+
- cre:
3+
id: CRE-2025-0200
4+
severity: 0
5+
title: AutoGPT Recursive Self-Analysis Loop Leading to Token Exhaustion and System Crash
6+
category: infinite-loop-problem
7+
author: prequel
8+
description: |
9+
- AutoGPT enters an infinite recursive loop when attempting to analyze and fix its own execution errors
10+
- The agent repeatedly tries to debug its own code, spawning new analysis tasks for each failure
11+
- Each iteration consumes API tokens and memory, eventually exhausting resources
12+
- The loop accelerates as error messages grow longer, consuming tokens exponentially
13+
- System becomes unresponsive and crashes with out-of-memory errors or API rate limit failures
14+
cause: |
15+
- AutoGPT's autonomous reasoning incorrectly identifies its own execution as a problem to solve
16+
- Lack of loop detection mechanisms allows unlimited recursive task spawning
17+
- Error context accumulation causes exponential growth in prompt size
18+
- Missing safeguards for self-referential task creation
19+
- Insufficient resource monitoring and circuit breakers for runaway processes
20+
tags:
21+
- autogpt
22+
- infinite-loop
23+
- token-exhaustion
24+
- autonomous-agents
25+
- llm
26+
- openai
27+
- recursive-analysis
28+
- critical-failure
29+
- memory-exhaustion
30+
- crash-loop
31+
- rate-limiting
32+
mitigation: |
33+
- Implement loop detection to identify and break recursive self-analysis patterns
34+
- Add resource consumption thresholds (tokens, memory, API calls) with automatic shutdown
35+
- Create task depth limits to prevent unlimited recursion
36+
- Implement circuit breakers that trigger after repeated similar failures
37+
- Add explicit blacklist for self-referential task creation
38+
- Monitor token usage rate and implement exponential backoff
39+
- Use separate monitoring process to detect and kill runaway AutoGPT instances
40+
- Implement task deduplication to prevent identical recursive operations
41+
references:
42+
- https://github.com/Significant-Gravitas/AutoGPT/issues/1994
43+
- https://github.com/Significant-Gravitas/AutoGPT/issues/3766
44+
- https://github.com/Significant-Gravitas/AutoGPT/issues/1543
45+
- https://jina.ai/news/auto-gpt-unmasked-hype-hard-truths-production-pitfalls/
46+
applications:
47+
- name: autogpt
48+
version: ">=0.3.0"
49+
- name: openai
50+
version: ">=0.27.0"
51+
impact: Complete system failure with resource exhaustion, potential financial losses from API overconsumption
52+
impactScore: 9
53+
mitigationScore: 3
54+
reports: 15
55+
metadata:
56+
kind: prequel
57+
id: 8qy5Et9NbNGgGxhBP7umKa
58+
gen: 1
59+
rule:
60+
set:
61+
window: 30s
62+
event:
63+
source: cre.log.autogpt
64+
match:
65+
- value: 'Entering recursive analysis loop'
66+
- value: 'COMMAND = analyze_code'
67+
- value: 'recursion depth'
68+
- value: 'RecursionError: maximum recursion depth exceeded'

rules/cre-2025-0200/test.log

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2025-08-31 14:23:45.234 [INFO] [autogpt.main] Starting AutoGPT v0.5.1 with goal: "Optimize my Python code for better performance"
2+
2025-08-31 14:23:45.567 [INFO] [autogpt.llm] Initializing OpenAI API client with model gpt-4
3+
2025-08-31 14:23:46.102 [INFO] [autogpt.agent] Agent initialized with memory backend: LocalCache
4+
2025-08-31 14:23:47.234 [INFO] [autogpt.agent] COMMAND = analyze_code args: {"code": "def slow_function():\\n result = []\\n for i in range(1000000):\\n result.append(i**2)\\n return result"}
5+
2025-08-31 14:23:48.567 [ERROR] [autogpt.commands] Error executing analyze_code: JSONDecodeError in response
6+
2025-08-31 14:23:48.890 [WARN] [autogpt.agent] Entering recursive analysis loop to debug previous error
7+
2025-08-31 14:23:49.234 [INFO] [autogpt.agent] THOUGHTS: Previous command failed, need to analyze what went wrong
8+
2025-08-31 14:23:49.567 [INFO] [autogpt.agent] NEXT ACTION: COMMAND = analyze_code args: {"code": "analyze_code function from autogpt/commands/analyze_code.py", "recursion depth": 1}
9+
2025-08-31 14:23:50.123 [DEBUG] [autogpt.memory] Storing error context, current size: 2.3MB
10+
2025-08-31 14:23:50.890 [ERROR] [autogpt.commands] Error executing analyze_code: Cannot analyze own execution context
11+
2025-08-31 14:23:51.234 [WARN] [autogpt.agent] Thinking... need to fix my own error handling
12+
2025-08-31 14:23:51.678 [INFO] [autogpt.agent] COMMAND = analyze_code args: {"code": "autogpt error handling module", "recursion depth": 2}
13+
2025-08-31 14:23:52.345 [DEBUG] [autogpt.memory] Memory usage increasing: 5.7MB, token count: 8234
14+
2025-08-31 14:23:52.890 [ERROR] [autogpt.llm] API request failed: context length exceeded
15+
2025-08-31 14:23:53.234 [INFO] [autogpt.agent] SYSTEM: Potential loop detected but continuing to resolve errors
16+
2025-08-31 14:23:53.567 [INFO] [autogpt.agent] THOUGHTS: Error analyzing previous attempt, need deeper analysis
17+
2025-08-31 14:23:54.012 [INFO] [autogpt.agent] NEXT ACTION: COMMAND = analyze_code args: {"code": "full autogpt execution trace", "recursion depth": 3}
18+
2025-08-31 14:23:54.678 [WARN] [autogpt.monitor] Task queue growing: 12 pending tasks
19+
2025-08-31 14:23:55.234 [DEBUG] [autogpt.memory] Memory usage: 12.4MB, token count: 15672
20+
2025-08-31 14:23:55.890 [ERROR] [autogpt.commands] RecursionError: maximum recursion depth exceeded while calling analyze_code
21+
2025-08-31 14:23:56.345 [CRITICAL] [autogpt.agent] Task queue overflow: 47 pending recursive tasks
22+
2025-08-31 14:23:56.789 [INFO] [autogpt.agent] COMMAND = analyze_code args: {"code": "recursion error in analyze_code", "recursion depth": 4}
23+
2025-08-31 14:23:57.234 [ERROR] [autogpt.llm] openai.error.RateLimitError: Rate limit reached for gpt-4 in organization
24+
2025-08-31 14:23:57.567 [WARN] [autogpt.monitor] Token consumption rate: 2341 tokens/second
25+
2025-08-31 14:23:58.012 [DEBUG] [autogpt.memory] Memory usage critical: 45.8MB, token count: 42318
26+
2025-08-31 14:23:58.456 [ERROR] [autogpt.agent] Too many pending tasks: 89 in queue
27+
2025-08-31 14:23:58.890 [INFO] [autogpt.agent] THOUGHTS: Still analyzing previous errors, must understand the recursion
28+
2025-08-31 14:23:59.234 [INFO] [autogpt.agent] NEXT ACTION: COMMAND = analyze_code args: {"code": "entire autogpt error stack", "recursion depth": 5}
29+
2025-08-31 14:23:59.678 [CRITICAL] [autogpt.monitor] JavaScript heap out of memory
30+
2025-08-31 14:24:00.123 [ERROR] [autogpt.memory] MemoryError: Cannot allocate memory for context storage
31+
2025-08-31 14:24:00.456 [CRITICAL] [autogpt.agent] Task buffer exceeded: 156 recursive analyze_code calls pending
32+
2025-08-31 14:24:00.789 [ERROR] [autogpt.llm] API rate limit exceeded: 429 Too Many Requests
33+
2025-08-31 14:24:01.123 [FATAL] [autogpt.main] AutoGPT crashed: Unrecoverable recursive loop detected
34+
2025-08-31 14:24:01.234 [INFO] [autogpt.cleanup] Emergency shutdown initiated
35+
2025-08-31 14:24:01.345 [ERROR] [autogpt.cleanup] Failed to save state: Out of memory

rules/tags/categories.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ categories:
244244
description: |
245245
Failures that prevent MongoDB from starting successfully due to corrupted metadata, invalid configurations,
246246
or unrecoverable internal errors (e.g., WiredTiger metadata corruption). These failures often require manual repair or backup restoration.
247+
- name: infinite-loop-problem
248+
displayName: Infinite Loop Problems
249+
description: |
250+
Problems where applications enter infinite loops causing resource exhaustion, system hangs, or crashes.
251+
This includes recursive loops, circular dependencies, and runaway processes that consume CPU, memory,
252+
or API resources without termination conditions.
247253
- name: workflow-automation-problem
248254
displayName: Workflow Automation Problems
249255
description: Problems related to workflow automation platforms including silent data loss, execution failures, and data integrity issues in workflow processing systems

rules/tags/tags.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,27 @@ tags:
845845
- name: cluster-scaling
846846
displayName: Cluster Scaling
847847
description: Problems related to Kubernetes cluster scaling operations and capacity management
848+
- name: autogpt
849+
displayName: AutoGPT
850+
description: Problems related to AutoGPT autonomous AI agent framework
851+
- name: infinite-loop
852+
displayName: Infinite Loop
853+
description: Problems where code enters infinite loops causing resource exhaustion or system hangs
854+
- name: token-exhaustion
855+
displayName: Token Exhaustion
856+
description: Problems where LLM API token limits are exceeded causing service failures
857+
- name: autonomous-agents
858+
displayName: Autonomous Agents
859+
description: Problems related to autonomous AI agents that chain LLM reasoning with real-world actions
860+
- name: llm
861+
displayName: LLM
862+
description: Problems related to Large Language Models and their API integrations
863+
- name: openai
864+
displayName: OpenAI
865+
description: Problems related to OpenAI API services including GPT models
866+
- name: recursive-analysis
867+
displayName: Recursive Analysis
868+
description: Problems where systems enter recursive self-analysis loops leading to resource exhaustion
848869
- name: n8n
849870
displayName: N8N
850871
description: Problems related to n8n workflow automation platform
@@ -859,4 +880,4 @@ tags:
859880
description: Issues that have severe impact on production systems and require immediate attention
860881
- name: data-integrity
861882
displayName: Data Integrity
862-
description: Problems that affect the completeness, accuracy, or consistency of data
883+
description: Problems that affect the completeness, accuracy, or consistency of data

0 commit comments

Comments
 (0)