Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sdk/guides/agent-stuck-detector.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import RunExampleCode from "/sdk/shared-snippets/how-to-run-example.mdx";
The Stuck Detector automatically identifies when an agent enters unproductive patterns such as repeating the same actions, encountering repeated errors, or engaging in monologues. By analyzing the conversation history after the last user message, it detects five types of stuck patterns:

1. **Repeating Action-Observation Cycles**: The same action produces the same observation repeatedly (4+ times)
2. **Repeating Action-Error Cycles**: The same action repeatedly results in errors (3+ times)
2. **Repeating Action-Error Cycles**: The same action repeatedly results in errors. By default, the conversation sends a corrective nudge after 3 failures and stops if the next identical call also fails.
3. **Agent Monologue**: The agent sends multiple consecutive messages without user input or meaningful progress (3+ messages)
4. **Alternating Patterns**: Two different action-observation pairs alternate in a ping-pong pattern (6+ cycles)
5. **Context Window Errors**: Repeated context window errors that indicate memory management issues
Expand All @@ -35,6 +35,9 @@ stuck status at any point using `conversation.stuck_detector.is_stuck()`.

## Pattern Detection

The `action_error` threshold controls the corrective nudge for repeated tool errors; one additional failed call triggers the hard stop. The `action_observation` threshold applies to regular tool observations and does not shorten this error-recovery window. Other enabled stuck patterns can still stop the run independently.


The stuck detector compares events based on their semantic content rather than object identity. For example:
- **Actions** are compared by their tool name, action content, and thought (ignoring IDs and metrics)
- **Observations** are compared by their observation content and tool name
Expand Down