@@ -309,7 +309,7 @@ def setup_handlers(app):
309309
310310def is_duplicate_event (event_id ):
311311 """
312- Best-effort deduplication for Slack retries using DynamoDB conditional write .
312+ Check if we've already processed this event using DynamoDB conditional writes .
313313
314314 Key:
315315 pk = f"event#{event_id}", sk = "dedup", ttl = now + 1h
@@ -323,23 +323,23 @@ def is_duplicate_event(event_id):
323323 Item = {"pk" : f"event#{ event_id } " , "sk" : "dedup" , "ttl" : ttl , "timestamp" : int (time .time ())},
324324 ConditionExpression = "attribute_not_exists(pk)" ,
325325 )
326- return False
326+ return False # Not a duplicate
327327 except ClientError as e :
328328 if e .response .get ("Error" , {}).get ("Code" ) == "ConditionalCheckFailedException" :
329- return True
329+ return True # Duplicate
330330 logger .error (f"Error checking event duplication: { e } " )
331331 return False
332332
333333
334334def trigger_async_processing (event_data ):
335335 """
336- Asynchronously re-invoke this Lambda for long-running work (e.g., model calls) .
336+ Trigger asynchronous Lambda invocation to process Slack events .
337337
338- Slack requires responses within ~3 seconds. To avoid timeouts, we:
339- 1) ack immediately in the handler,
340- 2) self-invoke the Lambda with InvocationType='Event',
341- 3) perform the heavy work in the async path and post back to Slack.
338+ Slack requires responses within 3 seconds, but Bedrock queries can take longer.
339+ This function invokes the same Lambda function asynchronously to handle the
340+ actual AI processing without blocking the initial Slack response.
342341 """
342+ # incase we fail to re-invoke the lambda we should log an error
343343 try :
344344 lambda_client = boto3 .client ("lambda" )
345345 lambda_client .invoke (
0 commit comments