diff --git a/.agents/skills/building-lambda-functions-with-powertools-python/references/idempotency.md b/.agents/skills/building-lambda-functions-with-powertools-python/references/idempotency.md index f097dcf1868..6799fba0bd4 100644 --- a/.agents/skills/building-lambda-functions-with-powertools-python/references/idempotency.md +++ b/.agents/skills/building-lambda-functions-with-powertools-python/references/idempotency.md @@ -2306,6 +2306,8 @@ For example, the `_put_record` method needs to raise an exception if a non-expir ### Manipulating the Idempotent Response +With a DynamoDB composite key, `DataRecord.idempotency_key` contains the sort key value identifying the operation, rather than the shared static partition key. Replayed records use this same key for local caching. + You can set up a `response_hook` in the `IdempotentConfig` class to manipulate the returned data when an operation is idempotent. The hook function will be called with the current deserialized response object and the Idempotency record. **Using an Idempotent Response Hook** @@ -2328,7 +2330,7 @@ from aws_lambda_powertools.utilities.typing import LambdaContext logger = Logger() def my_response_hook(response: dict, idempotent_data: DataRecord) -> dict: - # Return inserted Header data into the Idempotent Response + # With a composite key, this is the operation's sort key, not the shared partition key response["x-idempotent-key"] = idempotent_data.idempotency_key # expiry_timestamp can be None so include if set