generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: replace ADAPTIVE_EMPTY_RESULT with ReplayChildren flag #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Use ContextOptions.ReplayChildren instead of magic string marker - Add summaryGenerator config for custom payload summaries - Default to empty string for large payloads without summaryGenerator - Update tests to match new ReplayChildren behavior - Improve observability and maintainability of large payload handling
yaythomas
approved these changes
Sep 3, 2025
Member
yaythomas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
ParidelPooya
added a commit
that referenced
this pull request
Oct 10, 2025
# ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous `ADAPTIVE_EMPTY_RESULT` marker
approach with `ReplayChildren` flag mechanism for handling large
payloads in child context operations.
## Key Changes
### 1. **ChildConfig Interface Enhancement**
- Added `summaryGenerator?: (result: T) => string` option
- summaryGenerator Will be used internall to create a summary for
ctx.map and ctx.parallel when result is big
- **Note**: `summaryGenerator` receives the **raw result** (before
serialization)
### 2. **Checkpoint Behavior Update**
- **Before**: Used magic string `"__LARGE_PAYLOAD__"` as payload marker
- **After**: Uses `ContextOptions: { ReplayChildren: true }` flag with
empty string payload (or custom summary)
### 3. **Replay Detection Logic**
- **Before**: `if (result === ADAPTIVE_EMPTY_RESULT)`
- **After**: `if (stepData?.ContextDetails?.ReplayChildren)`
### 4. **Data Flow Details**
- **Size Check**: Uses **serialized result** (after
`serdes.serialize()`) to determine if payload > 256KB
- **summaryGenerator**: Receives **raw result** (before serialization)
for flexible summary creation
## Workflow Diagram
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Child Context Execution Flow │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────┐
│ Execute Child │
│ Context │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Raw Result (T) │
│ │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Apply Serdes │
│ Serialization │
│ result → string │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Check Serialized│
│ Payload Size │
│ > 256KB? │
└─────┬───────┬───┘
│ │
NO │ │ YES
│ │
┌───────────────▼─┐ ┌─▼──────────────────┐
│ Normal │ │ Large Payload │
│ Checkpoint │ │ Handling │
│ │ │ │
│ Payload: │ │ ReplayChildren: │
│ serialized data │ │ true │
│ ReplayChildren: │ │ │
│ undefined │ │ │
└───────────────┬─┘ └─┬──────────────────┘
│ │
│ ┌───▼──────────────────┐
│ │ summaryGenerator │
│ │ provided? │
│ │ (gets RAW result) │
│ └───┬──────────┬───────┘
│ │ │
│ YES │ │ NO
│ │ │
│ ┌───▼────┐ ┌───▼────┐
│ │Custom │ │Empty │
│ │Summary │ │String │
│ │from │ │"" │
│ │raw data│ │ │
│ └───┬────┘ └───┬────┘
│ │ │
└───────┼──────────┘
│
┌─────────────▼─────────────┐
│ Checkpoint Saved │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ On Replay... │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Check ReplayChildren │
│ flag in ContextDetails │
└─────┬───────────┬─────────┘
│ │
FALSE│ │TRUE
│ │
┌───────────────▼─┐ ┌─────▼──────────────┐
│ Return Cached │ │ Re-execute Child │
│ Result from │ │ Context Function │
│ Checkpoint │ │ (Reconstruct │
│ (deserialize) │ │ Full Result) │
└─────────────────┘ └────────────────────┘
```
## Data Flow Summary
1. **Execute** child context function → Raw result `T`
2. **Serialize** result using serdes → `string`
3. **Check size** of serialized string
4. **If large**: Call `summaryGenerator(rawResult)` → custom summary
5. **Checkpoint** with ReplayChildren flag and summary/empty payload
6. **On replay**: Check ReplayChildren flag to decide re-execution
### Checklist
- [Y] I have filled out every section of the PR template
- [Y] I have thoroughly tested this change
### Testing
#### Unit Tests
Yes
Co-authored-by: Pooya Paridel <parpooya@amazon.com>
ParidelPooya
added a commit
that referenced
this pull request
Oct 12, 2025
# ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous `ADAPTIVE_EMPTY_RESULT` marker
approach with `ReplayChildren` flag mechanism for handling large
payloads in child context operations.
## Key Changes
### 1. **ChildConfig Interface Enhancement**
- Added `summaryGenerator?: (result: T) => string` option
- summaryGenerator Will be used internall to create a summary for
ctx.map and ctx.parallel when result is big
- **Note**: `summaryGenerator` receives the **raw result** (before
serialization)
### 2. **Checkpoint Behavior Update**
- **Before**: Used magic string `"__LARGE_PAYLOAD__"` as payload marker
- **After**: Uses `ContextOptions: { ReplayChildren: true }` flag with
empty string payload (or custom summary)
### 3. **Replay Detection Logic**
- **Before**: `if (result === ADAPTIVE_EMPTY_RESULT)`
- **After**: `if (stepData?.ContextDetails?.ReplayChildren)`
### 4. **Data Flow Details**
- **Size Check**: Uses **serialized result** (after
`serdes.serialize()`) to determine if payload > 256KB
- **summaryGenerator**: Receives **raw result** (before serialization)
for flexible summary creation
## Workflow Diagram
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Child Context Execution Flow │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────┐
│ Execute Child │
│ Context │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Raw Result (T) │
│ │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Apply Serdes │
│ Serialization │
│ result → string │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Check Serialized│
│ Payload Size │
│ > 256KB? │
└─────┬───────┬───┘
│ │
NO │ │ YES
│ │
┌───────────────▼─┐ ┌─▼──────────────────┐
│ Normal │ │ Large Payload │
│ Checkpoint │ │ Handling │
│ │ │ │
│ Payload: │ │ ReplayChildren: │
│ serialized data │ │ true │
│ ReplayChildren: │ │ │
│ undefined │ │ │
└───────────────┬─┘ └─┬──────────────────┘
│ │
│ ┌───▼──────────────────┐
│ │ summaryGenerator │
│ │ provided? │
│ │ (gets RAW result) │
│ └───┬──────────┬───────┘
│ │ │
│ YES │ │ NO
│ │ │
│ ┌───▼────┐ ┌───▼────┐
│ │Custom │ │Empty │
│ │Summary │ │String │
│ │from │ │"" │
│ │raw data│ │ │
│ └───┬────┘ └───┬────┘
│ │ │
└───────┼──────────┘
│
┌─────────────▼─────────────┐
│ Checkpoint Saved │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ On Replay... │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Check ReplayChildren │
│ flag in ContextDetails │
└─────┬───────────┬─────────┘
│ │
FALSE│ │TRUE
│ │
┌───────────────▼─┐ ┌─────▼──────────────┐
│ Return Cached │ │ Re-execute Child │
│ Result from │ │ Context Function │
│ Checkpoint │ │ (Reconstruct │
│ (deserialize) │ │ Full Result) │
└─────────────────┘ └────────────────────┘
```
## Data Flow Summary
1. **Execute** child context function → Raw result `T`
2. **Serialize** result using serdes → `string`
3. **Check size** of serialized string
4. **If large**: Call `summaryGenerator(rawResult)` → custom summary
5. **Checkpoint** with ReplayChildren flag and summary/empty payload
6. **On replay**: Check ReplayChildren flag to decide re-execution
### Checklist
- [Y] I have filled out every section of the PR template
- [Y] I have thoroughly tested this change
### Testing
#### Unit Tests
Yes
Co-authored-by: Pooya Paridel <parpooya@amazon.com>
ParidelPooya
added a commit
that referenced
this pull request
Oct 24, 2025
# ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous `ADAPTIVE_EMPTY_RESULT` marker
approach with `ReplayChildren` flag mechanism for handling large
payloads in child context operations.
## Key Changes
### 1. **ChildConfig Interface Enhancement**
- Added `summaryGenerator?: (result: T) => string` option
- summaryGenerator Will be used internall to create a summary for
ctx.map and ctx.parallel when result is big
- **Note**: `summaryGenerator` receives the **raw result** (before
serialization)
### 2. **Checkpoint Behavior Update**
- **Before**: Used magic string `"__LARGE_PAYLOAD__"` as payload marker
- **After**: Uses `ContextOptions: { ReplayChildren: true }` flag with
empty string payload (or custom summary)
### 3. **Replay Detection Logic**
- **Before**: `if (result === ADAPTIVE_EMPTY_RESULT)`
- **After**: `if (stepData?.ContextDetails?.ReplayChildren)`
### 4. **Data Flow Details**
- **Size Check**: Uses **serialized result** (after
`serdes.serialize()`) to determine if payload > 256KB
- **summaryGenerator**: Receives **raw result** (before serialization)
for flexible summary creation
## Workflow Diagram
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Child Context Execution Flow │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────┐
│ Execute Child │
│ Context │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Raw Result (T) │
│ │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Apply Serdes │
│ Serialization │
│ result → string │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Check Serialized│
│ Payload Size │
│ > 256KB? │
└─────┬───────┬───┘
│ │
NO │ │ YES
│ │
┌───────────────▼─┐ ┌─▼──────────────────┐
│ Normal │ │ Large Payload │
│ Checkpoint │ │ Handling │
│ │ │ │
│ Payload: │ │ ReplayChildren: │
│ serialized data │ │ true │
│ ReplayChildren: │ │ │
│ undefined │ │ │
└───────────────┬─┘ └─┬──────────────────┘
│ │
│ ┌───▼──────────────────┐
│ │ summaryGenerator │
│ │ provided? │
│ │ (gets RAW result) │
│ └───┬──────────┬───────┘
│ │ │
│ YES │ │ NO
│ │ │
│ ┌───▼────┐ ┌───▼────┐
│ │Custom │ │Empty │
│ │Summary │ │String │
│ │from │ │"" │
│ │raw data│ │ │
│ └───┬────┘ └───┬────┘
│ │ │
└───────┼──────────┘
│
┌─────────────▼─────────────┐
│ Checkpoint Saved │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ On Replay... │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Check ReplayChildren │
│ flag in ContextDetails │
└─────┬───────────┬─────────┘
│ │
FALSE│ │TRUE
│ │
┌───────────────▼─┐ ┌─────▼──────────────┐
│ Return Cached │ │ Re-execute Child │
│ Result from │ │ Context Function │
│ Checkpoint │ │ (Reconstruct │
│ (deserialize) │ │ Full Result) │
└─────────────────┘ └────────────────────┘
```
## Data Flow Summary
1. **Execute** child context function → Raw result `T`
2. **Serialize** result using serdes → `string`
3. **Check size** of serialized string
4. **If large**: Call `summaryGenerator(rawResult)` → custom summary
5. **Checkpoint** with ReplayChildren flag and summary/empty payload
6. **On replay**: Check ReplayChildren flag to decide re-execution
### Checklist
- [Y] I have filled out every section of the PR template
- [Y] I have thoroughly tested this change
### Testing
#### Unit Tests
Yes
Co-authored-by: Pooya Paridel <parpooya@amazon.com>
ParidelPooya
added a commit
that referenced
this pull request
Oct 26, 2025
# ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous `ADAPTIVE_EMPTY_RESULT` marker
approach with `ReplayChildren` flag mechanism for handling large
payloads in child context operations.
## Key Changes
### 1. **ChildConfig Interface Enhancement**
- Added `summaryGenerator?: (result: T) => string` option
- summaryGenerator Will be used internall to create a summary for
ctx.map and ctx.parallel when result is big
- **Note**: `summaryGenerator` receives the **raw result** (before
serialization)
### 2. **Checkpoint Behavior Update**
- **Before**: Used magic string `"__LARGE_PAYLOAD__"` as payload marker
- **After**: Uses `ContextOptions: { ReplayChildren: true }` flag with
empty string payload (or custom summary)
### 3. **Replay Detection Logic**
- **Before**: `if (result === ADAPTIVE_EMPTY_RESULT)`
- **After**: `if (stepData?.ContextDetails?.ReplayChildren)`
### 4. **Data Flow Details**
- **Size Check**: Uses **serialized result** (after
`serdes.serialize()`) to determine if payload > 256KB
- **summaryGenerator**: Receives **raw result** (before serialization)
for flexible summary creation
## Workflow Diagram
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Child Context Execution Flow │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────┐
│ Execute Child │
│ Context │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Raw Result (T) │
│ │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Apply Serdes │
│ Serialization │
│ result → string │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Check Serialized│
│ Payload Size │
│ > 256KB? │
└─────┬───────┬───┘
│ │
NO │ │ YES
│ │
┌───────────────▼─┐ ┌─▼──────────────────┐
│ Normal │ │ Large Payload │
│ Checkpoint │ │ Handling │
│ │ │ │
│ Payload: │ │ ReplayChildren: │
│ serialized data │ │ true │
│ ReplayChildren: │ │ │
│ undefined │ │ │
└───────────────┬─┘ └─┬──────────────────┘
│ │
│ ┌───▼──────────────────┐
│ │ summaryGenerator │
│ │ provided? │
│ │ (gets RAW result) │
│ └───┬──────────┬───────┘
│ │ │
│ YES │ │ NO
│ │ │
│ ┌───▼────┐ ┌───▼────┐
│ │Custom │ │Empty │
│ │Summary │ │String │
│ │from │ │"" │
│ │raw data│ │ │
│ └───┬────┘ └───┬────┘
│ │ │
└───────┼──────────┘
│
┌─────────────▼─────────────┐
│ Checkpoint Saved │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ On Replay... │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Check ReplayChildren │
│ flag in ContextDetails │
└─────┬───────────┬─────────┘
│ │
FALSE│ │TRUE
│ │
┌───────────────▼─┐ ┌─────▼──────────────┐
│ Return Cached │ │ Re-execute Child │
│ Result from │ │ Context Function │
│ Checkpoint │ │ (Reconstruct │
│ (deserialize) │ │ Full Result) │
└─────────────────┘ └────────────────────┘
```
## Data Flow Summary
1. **Execute** child context function → Raw result `T`
2. **Serialize** result using serdes → `string`
3. **Check size** of serialized string
4. **If large**: Call `summaryGenerator(rawResult)` → custom summary
5. **Checkpoint** with ReplayChildren flag and summary/empty payload
6. **On replay**: Check ReplayChildren flag to decide re-execution
### Checklist
- [Y] I have filled out every section of the PR template
- [Y] I have thoroughly tested this change
### Testing
#### Unit Tests
Yes
Co-authored-by: Pooya Paridel <parpooya@amazon.com>
ParidelPooya
added a commit
that referenced
this pull request
Nov 2, 2025
# ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous `ADAPTIVE_EMPTY_RESULT` marker
approach with `ReplayChildren` flag mechanism for handling large
payloads in child context operations.
## Key Changes
### 1. **ChildConfig Interface Enhancement**
- Added `summaryGenerator?: (result: T) => string` option
- summaryGenerator Will be used internall to create a summary for
ctx.map and ctx.parallel when result is big
- **Note**: `summaryGenerator` receives the **raw result** (before
serialization)
### 2. **Checkpoint Behavior Update**
- **Before**: Used magic string `"__LARGE_PAYLOAD__"` as payload marker
- **After**: Uses `ContextOptions: { ReplayChildren: true }` flag with
empty string payload (or custom summary)
### 3. **Replay Detection Logic**
- **Before**: `if (result === ADAPTIVE_EMPTY_RESULT)`
- **After**: `if (stepData?.ContextDetails?.ReplayChildren)`
### 4. **Data Flow Details**
- **Size Check**: Uses **serialized result** (after
`serdes.serialize()`) to determine if payload > 256KB
- **summaryGenerator**: Receives **raw result** (before serialization)
for flexible summary creation
## Workflow Diagram
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Child Context Execution Flow │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────┐
│ Execute Child │
│ Context │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Raw Result (T) │
│ │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Apply Serdes │
│ Serialization │
│ result → string │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Check Serialized│
│ Payload Size │
│ > 256KB? │
└─────┬───────┬───┘
│ │
NO │ │ YES
│ │
┌───────────────▼─┐ ┌─▼──────────────────┐
│ Normal │ │ Large Payload │
│ Checkpoint │ │ Handling │
│ │ │ │
│ Payload: │ │ ReplayChildren: │
│ serialized data │ │ true │
│ ReplayChildren: │ │ │
│ undefined │ │ │
└───────────────┬─┘ └─┬──────────────────┘
│ │
│ ┌───▼──────────────────┐
│ │ summaryGenerator │
│ │ provided? │
│ │ (gets RAW result) │
│ └───┬──────────┬───────┘
│ │ │
│ YES │ │ NO
│ │ │
│ ┌───▼────┐ ┌───▼────┐
│ │Custom │ │Empty │
│ │Summary │ │String │
│ │from │ │"" │
│ │raw data│ │ │
│ └───┬────┘ └───┬────┘
│ │ │
└───────┼──────────┘
│
┌─────────────▼─────────────┐
│ Checkpoint Saved │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ On Replay... │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Check ReplayChildren │
│ flag in ContextDetails │
└─────┬───────────┬─────────┘
│ │
FALSE│ │TRUE
│ │
┌───────────────▼─┐ ┌─────▼──────────────┐
│ Return Cached │ │ Re-execute Child │
│ Result from │ │ Context Function │
│ Checkpoint │ │ (Reconstruct │
│ (deserialize) │ │ Full Result) │
└─────────────────┘ └────────────────────┘
```
## Data Flow Summary
1. **Execute** child context function → Raw result `T`
2. **Serialize** result using serdes → `string`
3. **Check size** of serialized string
4. **If large**: Call `summaryGenerator(rawResult)` → custom summary
5. **Checkpoint** with ReplayChildren flag and summary/empty payload
6. **On replay**: Check ReplayChildren flag to decide re-execution
### Checklist
- [Y] I have filled out every section of the PR template
- [Y] I have thoroughly tested this change
### Testing
#### Unit Tests
Yes
Co-authored-by: Pooya Paridel <parpooya@amazon.com>
ParidelPooya
added a commit
that referenced
this pull request
Nov 6, 2025
# ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous `ADAPTIVE_EMPTY_RESULT` marker
approach with `ReplayChildren` flag mechanism for handling large
payloads in child context operations.
## Key Changes
### 1. **ChildConfig Interface Enhancement**
- Added `summaryGenerator?: (result: T) => string` option
- summaryGenerator Will be used internall to create a summary for
ctx.map and ctx.parallel when result is big
- **Note**: `summaryGenerator` receives the **raw result** (before
serialization)
### 2. **Checkpoint Behavior Update**
- **Before**: Used magic string `"__LARGE_PAYLOAD__"` as payload marker
- **After**: Uses `ContextOptions: { ReplayChildren: true }` flag with
empty string payload (or custom summary)
### 3. **Replay Detection Logic**
- **Before**: `if (result === ADAPTIVE_EMPTY_RESULT)`
- **After**: `if (stepData?.ContextDetails?.ReplayChildren)`
### 4. **Data Flow Details**
- **Size Check**: Uses **serialized result** (after
`serdes.serialize()`) to determine if payload > 256KB
- **summaryGenerator**: Receives **raw result** (before serialization)
for flexible summary creation
## Workflow Diagram
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Child Context Execution Flow │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────┐
│ Execute Child │
│ Context │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Raw Result (T) │
│ │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Apply Serdes │
│ Serialization │
│ result → string │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Check Serialized│
│ Payload Size │
│ > 256KB? │
└─────┬───────┬───┘
│ │
NO │ │ YES
│ │
┌───────────────▼─┐ ┌─▼──────────────────┐
│ Normal │ │ Large Payload │
│ Checkpoint │ │ Handling │
│ │ │ │
│ Payload: │ │ ReplayChildren: │
│ serialized data │ │ true │
│ ReplayChildren: │ │ │
│ undefined │ │ │
└───────────────┬─┘ └─┬──────────────────┘
│ │
│ ┌───▼──────────────────┐
│ │ summaryGenerator │
│ │ provided? │
│ │ (gets RAW result) │
│ └───┬──────────┬───────┘
│ │ │
│ YES │ │ NO
│ │ │
│ ┌───▼────┐ ┌───▼────┐
│ │Custom │ │Empty │
│ │Summary │ │String │
│ │from │ │"" │
│ │raw data│ │ │
│ └───┬────┘ └───┬────┘
│ │ │
└───────┼──────────┘
│
┌─────────────▼─────────────┐
│ Checkpoint Saved │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ On Replay... │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Check ReplayChildren │
│ flag in ContextDetails │
└─────┬───────────┬─────────┘
│ │
FALSE│ │TRUE
│ │
┌───────────────▼─┐ ┌─────▼──────────────┐
│ Return Cached │ │ Re-execute Child │
│ Result from │ │ Context Function │
│ Checkpoint │ │ (Reconstruct │
│ (deserialize) │ │ Full Result) │
└─────────────────┘ └────────────────────┘
```
## Data Flow Summary
1. **Execute** child context function → Raw result `T`
2. **Serialize** result using serdes → `string`
3. **Check size** of serialized string
4. **If large**: Call `summaryGenerator(rawResult)` → custom summary
5. **Checkpoint** with ReplayChildren flag and summary/empty payload
6. **On replay**: Check ReplayChildren flag to decide re-execution
### Checklist
- [Y] I have filled out every section of the PR template
- [Y] I have thoroughly tested this change
### Testing
#### Unit Tests
Yes
Co-authored-by: Pooya Paridel <parpooya@amazon.com>
ParidelPooya
added a commit
that referenced
this pull request
Nov 6, 2025
# ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous `ADAPTIVE_EMPTY_RESULT` marker
approach with `ReplayChildren` flag mechanism for handling large
payloads in child context operations.
## Key Changes
### 1. **ChildConfig Interface Enhancement**
- Added `summaryGenerator?: (result: T) => string` option
- summaryGenerator Will be used internall to create a summary for
ctx.map and ctx.parallel when result is big
- **Note**: `summaryGenerator` receives the **raw result** (before
serialization)
### 2. **Checkpoint Behavior Update**
- **Before**: Used magic string `"__LARGE_PAYLOAD__"` as payload marker
- **After**: Uses `ContextOptions: { ReplayChildren: true }` flag with
empty string payload (or custom summary)
### 3. **Replay Detection Logic**
- **Before**: `if (result === ADAPTIVE_EMPTY_RESULT)`
- **After**: `if (stepData?.ContextDetails?.ReplayChildren)`
### 4. **Data Flow Details**
- **Size Check**: Uses **serialized result** (after
`serdes.serialize()`) to determine if payload > 256KB
- **summaryGenerator**: Receives **raw result** (before serialization)
for flexible summary creation
## Workflow Diagram
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Child Context Execution Flow │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────┐
│ Execute Child │
│ Context │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Raw Result (T) │
│ │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Apply Serdes │
│ Serialization │
│ result → string │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Check Serialized│
│ Payload Size │
│ > 256KB? │
└─────┬───────┬───┘
│ │
NO │ │ YES
│ │
┌───────────────▼─┐ ┌─▼──────────────────┐
│ Normal │ │ Large Payload │
│ Checkpoint │ │ Handling │
│ │ │ │
│ Payload: │ │ ReplayChildren: │
│ serialized data │ │ true │
│ ReplayChildren: │ │ │
│ undefined │ │ │
└───────────────┬─┘ └─┬──────────────────┘
│ │
│ ┌───▼──────────────────┐
│ │ summaryGenerator │
│ │ provided? │
│ │ (gets RAW result) │
│ └───┬──────────┬───────┘
│ │ │
│ YES │ │ NO
│ │ │
│ ┌───▼────┐ ┌───▼────┐
│ │Custom │ │Empty │
│ │Summary │ │String │
│ │from │ │"" │
│ │raw data│ │ │
│ └───┬────┘ └───┬────┘
│ │ │
└───────┼──────────┘
│
┌─────────────▼─────────────┐
│ Checkpoint Saved │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ On Replay... │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Check ReplayChildren │
│ flag in ContextDetails │
└─────┬───────────┬─────────┘
│ │
FALSE│ │TRUE
│ │
┌───────────────▼─┐ ┌─────▼──────────────┐
│ Return Cached │ │ Re-execute Child │
│ Result from │ │ Context Function │
│ Checkpoint │ │ (Reconstruct │
│ (deserialize) │ │ Full Result) │
└─────────────────┘ └────────────────────┘
```
## Data Flow Summary
1. **Execute** child context function → Raw result `T`
2. **Serialize** result using serdes → `string`
3. **Check size** of serialized string
4. **If large**: Call `summaryGenerator(rawResult)` → custom summary
5. **Checkpoint** with ReplayChildren flag and summary/empty payload
6. **On replay**: Check ReplayChildren flag to decide re-execution
### Checklist
- [Y] I have filled out every section of the PR template
- [Y] I have thoroughly tested this change
### Testing
#### Unit Tests
Yes
Co-authored-by: Pooya Paridel <parpooya@amazon.com>
ParidelPooya
added a commit
that referenced
this pull request
Nov 6, 2025
# ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous `ADAPTIVE_EMPTY_RESULT` marker
approach with `ReplayChildren` flag mechanism for handling large
payloads in child context operations.
## Key Changes
### 1. **ChildConfig Interface Enhancement**
- Added `summaryGenerator?: (result: T) => string` option
- summaryGenerator Will be used internall to create a summary for
ctx.map and ctx.parallel when result is big
- **Note**: `summaryGenerator` receives the **raw result** (before
serialization)
### 2. **Checkpoint Behavior Update**
- **Before**: Used magic string `"__LARGE_PAYLOAD__"` as payload marker
- **After**: Uses `ContextOptions: { ReplayChildren: true }` flag with
empty string payload (or custom summary)
### 3. **Replay Detection Logic**
- **Before**: `if (result === ADAPTIVE_EMPTY_RESULT)`
- **After**: `if (stepData?.ContextDetails?.ReplayChildren)`
### 4. **Data Flow Details**
- **Size Check**: Uses **serialized result** (after
`serdes.serialize()`) to determine if payload > 256KB
- **summaryGenerator**: Receives **raw result** (before serialization)
for flexible summary creation
## Workflow Diagram
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Child Context Execution Flow │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────┐
│ Execute Child │
│ Context │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Raw Result (T) │
│ │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Apply Serdes │
│ Serialization │
│ result → string │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Check Serialized│
│ Payload Size │
│ > 256KB? │
└─────┬───────┬───┘
│ │
NO │ │ YES
│ │
┌───────────────▼─┐ ┌─▼──────────────────┐
│ Normal │ │ Large Payload │
│ Checkpoint │ │ Handling │
│ │ │ │
│ Payload: │ │ ReplayChildren: │
│ serialized data │ │ true │
│ ReplayChildren: │ │ │
│ undefined │ │ │
└───────────────┬─┘ └─┬──────────────────┘
│ │
│ ┌───▼──────────────────┐
│ │ summaryGenerator │
│ │ provided? │
│ │ (gets RAW result) │
│ └───┬──────────┬───────┘
│ │ │
│ YES │ │ NO
│ │ │
│ ┌───▼────┐ ┌───▼────┐
│ │Custom │ │Empty │
│ │Summary │ │String │
│ │from │ │"" │
│ │raw data│ │ │
│ └───┬────┘ └───┬────┘
│ │ │
└───────┼──────────┘
│
┌─────────────▼─────────────┐
│ Checkpoint Saved │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ On Replay... │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Check ReplayChildren │
│ flag in ContextDetails │
└─────┬───────────┬─────────┘
│ │
FALSE│ │TRUE
│ │
┌───────────────▼─┐ ┌─────▼──────────────┐
│ Return Cached │ │ Re-execute Child │
│ Result from │ │ Context Function │
│ Checkpoint │ │ (Reconstruct │
│ (deserialize) │ │ Full Result) │
└─────────────────┘ └────────────────────┘
```
## Data Flow Summary
1. **Execute** child context function → Raw result `T`
2. **Serialize** result using serdes → `string`
3. **Check size** of serialized string
4. **If large**: Call `summaryGenerator(rawResult)` → custom summary
5. **Checkpoint** with ReplayChildren flag and summary/empty payload
6. **On replay**: Check ReplayChildren flag to decide re-execution
### Checklist
- [Y] I have filled out every section of the PR template
- [Y] I have thoroughly tested this change
### Testing
#### Unit Tests
Yes
Co-authored-by: Pooya Paridel <parpooya@amazon.com>
ParidelPooya
added a commit
that referenced
this pull request
Nov 7, 2025
# ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous `ADAPTIVE_EMPTY_RESULT` marker
approach with `ReplayChildren` flag mechanism for handling large
payloads in child context operations.
## Key Changes
### 1. **ChildConfig Interface Enhancement**
- Added `summaryGenerator?: (result: T) => string` option
- summaryGenerator Will be used internall to create a summary for
ctx.map and ctx.parallel when result is big
- **Note**: `summaryGenerator` receives the **raw result** (before
serialization)
### 2. **Checkpoint Behavior Update**
- **Before**: Used magic string `"__LARGE_PAYLOAD__"` as payload marker
- **After**: Uses `ContextOptions: { ReplayChildren: true }` flag with
empty string payload (or custom summary)
### 3. **Replay Detection Logic**
- **Before**: `if (result === ADAPTIVE_EMPTY_RESULT)`
- **After**: `if (stepData?.ContextDetails?.ReplayChildren)`
### 4. **Data Flow Details**
- **Size Check**: Uses **serialized result** (after
`serdes.serialize()`) to determine if payload > 256KB
- **summaryGenerator**: Receives **raw result** (before serialization)
for flexible summary creation
## Workflow Diagram
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Child Context Execution Flow │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────┐
│ Execute Child │
│ Context │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Raw Result (T) │
│ │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Apply Serdes │
│ Serialization │
│ result → string │
└─────────┬───────┘
│
┌─────────▼───────┐
│ Check Serialized│
│ Payload Size │
│ > 256KB? │
└─────┬───────┬───┘
│ │
NO │ │ YES
│ │
┌───────────────▼─┐ ┌─▼──────────────────┐
│ Normal │ │ Large Payload │
│ Checkpoint │ │ Handling │
│ │ │ │
│ Payload: │ │ ReplayChildren: │
│ serialized data │ │ true │
│ ReplayChildren: │ │ │
│ undefined │ │ │
└───────────────┬─┘ └─┬──────────────────┘
│ │
│ ┌───▼──────────────────┐
│ │ summaryGenerator │
│ │ provided? │
│ │ (gets RAW result) │
│ └───┬──────────┬───────┘
│ │ │
│ YES │ │ NO
│ │ │
│ ┌───▼────┐ ┌───▼────┐
│ │Custom │ │Empty │
│ │Summary │ │String │
│ │from │ │"" │
│ │raw data│ │ │
│ └───┬────┘ └───┬────┘
│ │ │
└───────┼──────────┘
│
┌─────────────▼─────────────┐
│ Checkpoint Saved │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ On Replay... │
└─────────────┬─────────────┘
│
┌─────────────▼─────────────┐
│ Check ReplayChildren │
│ flag in ContextDetails │
└─────┬───────────┬─────────┘
│ │
FALSE│ │TRUE
│ │
┌───────────────▼─┐ ┌─────▼──────────────┐
│ Return Cached │ │ Re-execute Child │
│ Result from │ │ Context Function │
│ Checkpoint │ │ (Reconstruct │
│ (deserialize) │ │ Full Result) │
└─────────────────┘ └────────────────────┘
```
## Data Flow Summary
1. **Execute** child context function → Raw result `T`
2. **Serialize** result using serdes → `string`
3. **Check size** of serialized string
4. **If large**: Call `summaryGenerator(rawResult)` → custom summary
5. **Checkpoint** with ReplayChildren flag and summary/empty payload
6. **On replay**: Check ReplayChildren flag to decide re-execution
### Checklist
- [Y] I have filled out every section of the PR template
- [Y] I have thoroughly tested this change
### Testing
#### Unit Tests
Yes
Co-authored-by: Pooya Paridel <parpooya@amazon.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ReplayChildren Implementation for Run-in-Child-Context Handler
This change replaces the previous
ADAPTIVE_EMPTY_RESULTmarker approach withReplayChildrenflag mechanism for handling large payloads in child context operations.Key Changes
1. ChildConfig Interface Enhancement
summaryGenerator?: (result: T) => stringoptionsummaryGeneratorreceives the raw result (before serialization)2. Checkpoint Behavior Update
"__LARGE_PAYLOAD__"as payload markerContextOptions: { ReplayChildren: true }flag with empty string payload (or custom summary)3. Replay Detection Logic
if (result === ADAPTIVE_EMPTY_RESULT)if (stepData?.ContextDetails?.ReplayChildren)4. Data Flow Details
serdes.serialize()) to determine if payload > 256KBWorkflow Diagram
Data Flow Summary
TstringsummaryGenerator(rawResult)→ custom summaryChecklist
Testing
Unit Tests
Yes