generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 398
Feat/agentcore multi agent #1413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
VincentV89
wants to merge
10
commits into
main
Choose a base branch
from
feat/agentcore-multi-agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e00cd47
Implemented Multi-Agent (Agents as Tools) capability to Agent Builder.
VincentV89 2e6ec75
Added subAgents config to agents invocation
VincentV89 70e3750
Updated generic agentcore runtime to take in dynamic sub-agent config…
VincentV89 c762b3f
Updated agent runtime retrieval to be dynamic
VincentV89 5297b82
Exclude the listing of generic runtime agents
VincentV89 25de8c4
Fixed linting from multi-agent feature
VincentV89 61730f8
Updated CDK snapshot
VincentV89 24c6fdd
fixed python linting
VincentV89 98effdd
# Commit Message
daisuke-awaji f56c16b
fixed cdk snapshot
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import * as lambda from 'aws-cdk-lib/aws-lambda'; | ||
|
|
||
| export const LAMBDA_RUNTIME_NODEJS = lambda.Runtime.NODEJS_22_X; | ||
| export const LAMBDA_RUNTIME_PYTHON = lambda.Runtime.PYTHON_3_12; | ||
|
|
||
| export const TAG_KEY = 'GenU'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
packages/cdk/lambda-python/list-agent-core-runtimes/list_agent_core_runtimes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| """Lambda function to list AgentCore Runtime agents.""" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the contribution! We are migrating most of typescript lambda behind ALB to lambda monolith in another PR. Can you implement it in TypeScript so it would be easier to merge conflict? |
||
|
|
||
| import json | ||
| import logging | ||
| import os | ||
| from typing import Any, Dict | ||
|
|
||
| import boto3 | ||
| from botocore.exceptions import ClientError | ||
|
|
||
| # Configure logging | ||
| logger = logging.getLogger() | ||
| logger.setLevel(logging.INFO) | ||
|
|
||
| # Get region from environment | ||
| REGION = os.environ.get("REGION", "us-east-1") | ||
|
|
||
|
|
||
| def handler(event: Dict[str, Any], context: Any) -> Dict[str, Any]: | ||
| """ | ||
| List all available AgentCore Runtime agents. | ||
|
|
||
| Args: | ||
| event: API Gateway event | ||
| context: Lambda context | ||
|
|
||
| Returns: | ||
| API Gateway response with list of runtimes | ||
| """ | ||
| logger.info(f"Event: {json.dumps(event)}") | ||
|
|
||
| try: | ||
| # Initialize Bedrock Agent Runtime client | ||
| client = boto3.client("bedrock-agentcore-control", region_name=REGION) | ||
|
|
||
| # List all agent runtimes | ||
| response = client.list_agent_runtimes() | ||
|
|
||
| # Format the response | ||
| runtimes = [] | ||
| for runtime in response.get("agentRuntimes", []): | ||
| runtime_name = runtime.get("agentRuntimeName", "Unnamed Runtime") | ||
| if runtime_name not in ("GenUGenericRuntime", "GenUAgentBuilderRuntime"): | ||
| runtimes.append({ | ||
| "name": runtime_name, | ||
| "description": runtime.get("description", "No description available"), | ||
| "arn": runtime.get("agentRuntimeArn", ""), | ||
| "status": runtime.get("status", "UNKNOWN"), | ||
| "createdAt": runtime.get("createdAt").isoformat() if runtime.get("createdAt") else None, | ||
| "updatedAt": runtime.get("updatedAt").isoformat() if runtime.get("updatedAt") else None, | ||
| }) | ||
|
|
||
| logger.info(f"Found {len(runtimes)} AgentCore runtimes") | ||
|
|
||
| return { | ||
| "statusCode": 200, | ||
| "headers": { | ||
| "Content-Type": "application/json", | ||
| "Access-Control-Allow-Origin": "*", | ||
| }, | ||
| "body": json.dumps({ | ||
| "runtimes": runtimes, | ||
| "count": len(runtimes), | ||
| }), | ||
| } | ||
|
|
||
| except ClientError as e: | ||
| error_code = e.response.get("Error", {}).get("Code", "Unknown") | ||
| error_message = e.response.get("Error", {}).get("Message", str(e)) | ||
|
|
||
| logger.error(f"AWS ClientError ({error_code}): {error_message}") | ||
|
|
||
| return { | ||
| "statusCode": 500, | ||
| "headers": { | ||
| "Content-Type": "application/json", | ||
| "Access-Control-Allow-Origin": "*", | ||
| }, | ||
| "body": json.dumps({ | ||
| "error": "Failed to list AgentCore runtimes", | ||
| "message": error_message, | ||
| "code": error_code, | ||
| "runtimes": [], | ||
| "count": 0, | ||
| }), | ||
| } | ||
|
|
||
| except Exception as e: | ||
| logger.error(f"Unexpected error: {str(e)}", exc_info=True) | ||
|
|
||
| return { | ||
| "statusCode": 500, | ||
| "headers": { | ||
| "Content-Type": "application/json", | ||
| "Access-Control-Allow-Origin": "*", | ||
| }, | ||
| "body": json.dumps({ | ||
| "error": "Failed to list AgentCore runtimes", | ||
| "message": str(e), | ||
| "runtimes": [], | ||
| "count": 0, | ||
| }), | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The region should be configurable
Suggestion: Use environment variable consistently