diff --git a/specification/v1_0/json/renderer_to_agent.json b/specification/v1_0/json/renderer_to_agent.json index 8c121a3df..91f104250 100644 --- a/specification/v1_0/json/renderer_to_agent.json +++ b/specification/v1_0/json/renderer_to_agent.json @@ -46,7 +46,22 @@ "description": "Unique ID for this action call. Only needed if wantResponse is true." } }, - "required": ["name", "surfaceId", "sourceComponentId", "timestamp", "context"] + "required": ["name", "surfaceId", "sourceComponentId", "timestamp", "context"], + "allOf": [ + { + "if": { + "properties": { + "wantResponse": { + "const": true + } + }, + "required": ["wantResponse"] + }, + "then": { + "required": ["actionId"] + } + } + ] }, "functionResponse": { "properties": { diff --git a/specification/v1_0/test/cases/renderer_messages.json b/specification/v1_0/test/cases/renderer_messages.json index b2bf49793..0e1238775 100644 --- a/specification/v1_0/test/cases/renderer_messages.json +++ b/specification/v1_0/test/cases/renderer_messages.json @@ -17,6 +17,58 @@ } } }, + { + "description": "Valid action requesting a response with an actionId", + "valid": true, + "data": { + "version": "v1.0", + "action": { + "name": "submit", + "surfaceId": "main", + "sourceComponentId": "btn_submit", + "timestamp": "2023-10-27T10:00:00Z", + "context": { + "foo": "bar" + }, + "wantResponse": true, + "actionId": "submit-1" + } + } + }, + { + "description": "Invalid action requesting a response without an actionId", + "valid": false, + "data": { + "version": "v1.0", + "action": { + "name": "submit", + "surfaceId": "main", + "sourceComponentId": "btn_submit", + "timestamp": "2023-10-27T10:00:00Z", + "context": { + "foo": "bar" + }, + "wantResponse": true + } + } + }, + { + "description": "Valid action not requesting a response without an actionId", + "valid": true, + "data": { + "version": "v1.0", + "action": { + "name": "submit", + "surfaceId": "main", + "sourceComponentId": "btn_submit", + "timestamp": "2023-10-27T10:00:00Z", + "context": { + "foo": "bar" + }, + "wantResponse": false + } + } + }, { "description": "Valid error message (validation failed)", "valid": true,