Applies an AgentPayloadChangeRequest to a payload
The original payload to apply changes to
The change request from the AI agent
Optionaloptions: {Configuration options for the operation
Result object with the modified payload, operation counts, and any warnings
Applies a payload scope transformation to extract only the scoped portion.
The full payload to scope
The scope path (e.g., "/functionalRequirements" or "/PropA/SubProp1")
The scoped portion of the payload
Apply a change request to a sub-agent payload with upstream guardrails
This method first applies the change request, then enforces upstream path restrictions to ensure the sub-agent only modifies allowed paths.
ProtectedautoDetects and auto-corrects stray keys in a payloadChangeRequest. LLMs sometimes place payload properties as siblings of updateElements/newElements instead of nesting them inside. This method moves those stray keys into the appropriate bucket (updateElements if the key exists on the payload, newElements if not).
Only keys starting with a letter (a-z, A-Z) are considered — keys starting with underscore, dollar sign, or other non-letter characters are left alone as they may be internal markers.
OptionalagentName: stringDeep merges two objects, with source overriding destination.
This method preserves existing nested properties in the destination while adding or updating properties from the source. It handles nested objects recursively, ensuring that partial updates don't wipe out existing data.
A new merged object with all properties from both objects
Extracts only the allowed paths from a payload for downstream transmission.
The complete payload object
Array of path patterns defining what to extract
A new object containing only the allowed paths
Merges sub-agent results back into the parent payload, respecting write permissions.
A new merged payload object
const parent = { customer: { id: 1 }, analysis: { sentiment: null } };
const subResult = { customer: { id: 2 }, analysis: { sentiment: 'positive', score: 0.9 } };
const writePaths = ['analysis.*'];
const merged = mergeUpstreamPayload(parent, subResult, writePaths);
// Returns: { customer: { id: 1 }, analysis: { sentiment: 'positive', score: 0.9 } }
Reverses a payload scope transformation by wrapping the scoped content back into the full structure.
The scoped payload to wrap
The scope path used for extraction
A full payload structure with the scoped content at the correct path
Transforms paths in a change request to account for payload scoping. Prepends the scope path to all paths in the change request.
The change request with paths relative to the scoped view
The scope path to prepend
A new change request with transformed paths
Manages payload access control for agent hierarchies.
This class handles extracting specific paths from payloads when sending data downstream to sub-agents, and merging results back upstream while respecting write permissions.
Path syntax supports: