-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
314 lines (299 loc) · 9.38 KB
/
template.yaml
File metadata and controls
314 lines (299 loc) · 9.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Hierarchical Multi-Agent System API
Globals:
Function:
Timeout: 900 # 15 minutes for complex agent processing
MemorySize: 2048
Runtime: python3.12
Architectures:
- x86_64
Environment:
Variables:
AWS_BEDROCK_MODEL_ID: !Ref BedrockModelId
DEBUG: !Ref DebugMode
USE_IAM_ROLE: !Ref UseIAMRole
Parameters:
BedrockApiKey:
Type: String
Description: AWS Bedrock API Key (optional, leave empty to use IAM Role authentication)
NoEcho: true
Default: ""
BedrockModelId:
Type: String
Description: AWS Bedrock Model ID
Default: us.anthropic.claude-sonnet-4-20250514-v1:0
DebugMode:
Type: String
Description: Enable debug mode
Default: "false"
AllowedValues:
- "true"
- "false"
UseIAMRole:
Type: String
Description: Use IAM Role authentication instead of API Key (recommended for production)
Default: "true"
AllowedValues:
- "true"
- "false"
Resources:
# Lambda Function for Agent Execution
HierarchicalAgentsFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: hierarchical-agents-api
CodeUri: .
Handler: src.lambda.handler.lambda_handler
Description: Execute hierarchical multi-agent systems
Environment:
Variables:
AWS_BEDROCK_API_KEY: !Ref BedrockApiKey
Policies:
- AWSLambdaBasicExecutionRole
- Statement:
- Effect: Allow
Action:
- bedrock:InvokeModel
- bedrock:InvokeModelWithResponseStream
Resource: "*"
Events:
ExecuteAgents:
Type: Api
Properties:
Path: /execute
Method: POST
RestApiId: !Ref HierarchicalAgentsApi
OptionsExecute:
Type: Api
Properties:
Path: /execute
Method: OPTIONS
RestApiId: !Ref HierarchicalAgentsApi
Tags:
Service: hierarchical-agents
Environment: !Ref DebugMode
# Lambda Function for Health Check
HealthCheckFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: hierarchical-agents-health
CodeUri: .
Handler: src.lambda.handler.health_check_handler
Description: Health check endpoint
Timeout: 30
MemorySize: 256
Policies:
- AWSLambdaBasicExecutionRole
Events:
HealthCheck:
Type: Api
Properties:
Path: /health
Method: GET
RestApiId: !Ref HierarchicalAgentsApi
Tags:
Service: hierarchical-agents
Environment: !Ref DebugMode
# API Gateway
HierarchicalAgentsApi:
Type: AWS::Serverless::Api
Properties:
Name: hierarchical-agents-api
StageName: prod
Cors:
AllowMethods: "'POST, GET, OPTIONS'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
AllowOrigin: "'*'"
DefinitionBody:
swagger: "2.0"
info:
title: "Hierarchical Multi-Agent System API"
version: "1.0.0"
paths:
/execute:
post:
summary: Execute hierarchical agent system
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
required: true
schema:
$ref: "#/definitions/ExecutionRequest"
responses:
"200":
description: Successful execution
schema:
$ref: "#/definitions/ExecutionResponse"
"400":
description: Invalid request
"500":
description: Internal server error
x-amazon-apigateway-integration:
uri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HierarchicalAgentsFunction.Arn}/invocations"
httpMethod: POST
type: aws_proxy
options:
summary: CORS preflight
responses:
"200":
description: CORS headers
x-amazon-apigateway-integration:
type: mock
requestTemplates:
application/json: '{"statusCode": 200}'
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
method.response.header.Access-Control-Allow-Origin: "'*'"
/health:
get:
summary: Health check
produces:
- application/json
responses:
"200":
description: Service is healthy
x-amazon-apigateway-integration:
uri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HealthCheckFunction.Arn}/invocations"
httpMethod: POST
type: aws_proxy
definitions:
ExecutionRequest:
type: object
required:
- global_prompt
- teams
- task
properties:
global_prompt:
type: string
description: System prompt for global supervisor
teams:
type: array
description: List of team configurations
items:
$ref: "#/definitions/TeamConfig"
task:
type: string
description: Task to execute
execution_mode:
type: string
enum: [sequential, parallel]
default: sequential
enable_context_sharing:
type: boolean
default: false
TeamConfig:
type: object
required:
- name
- supervisor_prompt
- workers
properties:
name:
type: string
supervisor_prompt:
type: string
workers:
type: array
items:
$ref: "#/definitions/WorkerConfig"
prevent_duplicate:
type: boolean
default: true
share_context:
type: boolean
default: false
WorkerConfig:
type: object
required:
- name
- role
- system_prompt
properties:
name:
type: string
role:
type: string
system_prompt:
type: string
tools:
type: array
items:
type: string
temperature:
type: number
default: 0.7
max_tokens:
type: integer
default: 2048
ExecutionResponse:
type: object
properties:
success:
type: boolean
topology:
$ref: "#/definitions/TopologyInfo"
events:
type: array
items:
$ref: "#/definitions/StreamEvent"
result:
type: string
error:
type: string
statistics:
type: object
TopologyInfo:
type: object
properties:
global_supervisor_id:
type: string
teams:
type: array
StreamEvent:
type: object
properties:
event_type:
type: string
timestamp:
type: string
data:
type: object
topology_metadata:
type: object
# CloudWatch Log Groups
HierarchicalAgentsFunctionLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${HierarchicalAgentsFunction}
RetentionInDays: 7
HealthCheckFunctionLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${HealthCheckFunction}
RetentionInDays: 7
Outputs:
ApiEndpoint:
Description: API Gateway endpoint URL
Value: !Sub "https://${HierarchicalAgentsApi}.execute-api.${AWS::Region}.amazonaws.com/prod"
ExecuteEndpoint:
Description: Execute endpoint URL
Value: !Sub "https://${HierarchicalAgentsApi}.execute-api.${AWS::Region}.amazonaws.com/prod/execute"
HealthCheckEndpoint:
Description: Health check endpoint URL
Value: !Sub "https://${HierarchicalAgentsApi}.execute-api.${AWS::Region}.amazonaws.com/prod/health"
HierarchicalAgentsFunctionArn:
Description: Lambda function ARN
Value: !GetAtt HierarchicalAgentsFunction.Arn
HierarchicalAgentsFunctionName:
Description: Lambda function name
Value: !Ref HierarchicalAgentsFunction