# States.ExecutionFailed: The execution of state machine exceeded the maximum execution history size of 25000 entries

- **ID:** `aws/stepfunctions-state-machine-execution-limit-exceeded`
- **Domain:** aws
- **Category:** resource_error
- **Error Code:** `States.ExecutionFailed`
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Step Functions state machine execution has generated more than 25,000 history entries (e.g., due to long-running loops or large input/output payloads), which exceeds the service limit.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Step Functions 2024-08-01 | active | — | — |
| AWS SDK v2 | active | — | — |
| Lambda 2023-11-01 | active | — | — |

## Workarounds

1. **Refactor the state machine to use a nested workflow or a callback pattern to break long-running executions into smaller chunks. Example: Use a Map state with a max concurrency to process items in parallel, reducing the number of steps.** (80% success)
   ```
   Refactor the state machine to use a nested workflow or a callback pattern to break long-running executions into smaller chunks. Example: Use a Map state with a max concurrency to process items in parallel, reducing the number of steps.
   ```
2. **Reduce input/output payload sizes by filtering or truncating data between states. Use a Pass state with ResultPath to trim unnecessary fields.** (75% success)
   ```
   Reduce input/output payload sizes by filtering or truncating data between states. Use a Pass state with ResultPath to trim unnecessary fields.
   ```
3. **Implement a loop with a counter and a maximum iteration limit to prevent infinite loops from generating too many history entries.** (85% success)
   ```
   Implement a loop with a counter and a maximum iteration limit to prevent infinite loops from generating too many history entries.
   ```

## Dead Ends

- **** — The 25,000 history entry limit is a hard limit that cannot be increased by AWS support. (95% fail)
- **** — This may reduce history entries but can make the state machine less maintainable and might not solve the root cause if loops are the issue. (50% fail)
- **** — The limit is on history entries, not time; increasing timeout does not reduce history entries. (80% fail)
