aws-samples/sample-support-agent-with-agentcore

GitHub: aws-samples/sample-support-agent-with-agentcore

一个基于 AWS Bedrock AgentCore 构建的全栈式智能支持助手示例项目,集成了短期记忆、MCP 工具调用及交互式 Web 前端。

Stars: 1 | Forks: 0

# 基于 AWS AgentCore 的 SupportAgent 一个全面的 AWS Support Agent 实现,使用了具备短期记忆能力、MCP 集成以及 Web 前端的 AWS Bedrock AgentCore Runtime。 ![架构](/Architecture/architecture.png) ## 项目概述 该项目提供了一个完整的 AWS 支持解决方案,包含: - **AWS Support Agent**:由 AI 驱动,具备 AWS 文档访问、支持工具和 API 访问能力 - **短期记忆**:使用 AgentCore Memory 保留对话上下文 - **MCP Gateway**:用于 AWS re:Post 社区支持的自定义 Model Context Protocol 工具 - **Web 前端**:用于与 agent 交互的交互式聊天界面 - **基础设施**:完整的 AWS 部署自动化 ## 项目结构 ``` AgentCore_SupportAgent/ ├── AgentCore/ # Main agent implementation │ ├── agent.py # Agent implementation │ ├── deploy.sh # Automated deployment script │ ├── Dockerfile # ARM64 container configuration │ ├── requirements.txt # Python dependencies │ └── support-agent.yaml # AgentCore configuration ├── Architecture/ # Project architecture │ └── architecture.png # System architecture diagram ├── Infrastructure/ # AWS infrastructure setup │ └── lambda.py # Lambda function for MCP tools ├── frontend/ # Web interface │ └── support_agent_amplify_frontend.zip # Amplify frontend package └── README.md # This file ``` ## 前置条件 ### 系统要求 - **Git**:用于克隆代码仓库 - **AWS CLI**:已配置适当的凭证 - **Docker**:已安装并运行 - 在继续之前,请确保您的计算机上正在运行 Docker ### 所需的 AWS 权限 您的 AWS 凭证必须具有以下权限: - Amazon Bedrock 操作 - Amazon Bedrock AgentCore 操作 - AWS Lambda 操作 - Amazon ECR 操作 - AWS Cognito 操作 - IAM 角色的创建和管理 部署脚本将自动安装和配置所有其他依赖项,包括 Python、Docker 和所需的包。 ## 快速部署 要部署此项目,请按照以下简单步骤操作: ### 部署后端基础设施 **第 1 步:克隆此 Github 仓库** ``` git clone https://github.com/aws-samples/sample-support-agent-with-agentcore ``` **第 2 步:进入 AgentCore 目录** ``` cd sample-support-agent-with-agentcore ``` **第 3 步:配置 AWS 凭证** ``` aws configure ``` **第 4 步:使部署脚本可执行** ``` chmod +x deploy.sh ``` **第 5 步:部署项目** ``` ./deploy.sh --build-container ``` 部署脚本将处理所有必要的步骤,包括: - 基础设施部署 - Lambda 函数创建 - AgentCore Runtime 部署 - Docker 镜像构建与推送 - 所有必需的 AWS 资源配置 ### 部署 Amplify Web 应用程序 **第 6 步:下载 support-agent-frontend.zip** **第 7 步:进入 AWS Amplify 控制台** ``` Navigate to the AWS Amplify Console in the deployment region and click on the **support-agent-frontend** App. ``` **第 8 步:部署更新** ``` Click on the Deploy updates button in the main branch. ``` **第 9 步:上传前端包** ``` Choose Drag and drop as the Method and upload the Zip file using the Choose .Zip folder option. ``` **第 10 步:保存并部署** ``` Click Save and deploy. ``` ## 测试部署 ### 第 1 步:配置应用程序设置 在访问应用程序之前,您需要使用 CloudFormation 部署中的值来配置系统。您可以在 CLI 控制台上的 deploy.sh 输出中找到这些值,类似于以下内容: ``` +++++++++++++++++++++++++++ Frontend Configuration Values +++++++++++++++++++++++++++ SupportAgentPool User Pool ID: us-west-2_XXXXXXXXX support-agent-frontend-client Client ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxx Cognito Identity Pool ID: us-west-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Agent Runtime ARN: arn:aws:bedrock-agentcore:us-west-2:XXXXXXXXXXXX:runtime/support-agent-runtime-XXXXXX ++++++++++++++++++++++++++++++++++++++++++++++++++++++ ``` 使用这些值来配置您的 Amplify 前端应用程序设置。 ### 第 2 步:访问应用程序 Amplify 部署完成后,通过 Amplify 提供的 URL 访问您的应用程序,并开始与 Support Agent 交互。 ## 项目要求 ### 核心依赖项 ``` # AgentCore Agent [project] name = "agentcorememory" version = "0.1.0" description = "AWS Support Agent with AgentCore Memory" readme = "README.md" requires-python = ">=3.11" dependencies = [ "fastapi>=0.119.0", "httpx>=0.28.1", "pydantic>=2.12.2", "strands-agents>=1.12.0", "uvicorn[standard]>=0.37.0", "bedrock-agentcore>=0.1.0", "bedrock-agentcore-starter-toolkit>=0.1.0", "boto3>=1.35.0", ] ``` ### 基础设施依赖项 ``` # 基础设施部署 boto3>=1.35.0 bedrock-agentcore-starter-toolkit>=0.1.0 ``` ### 前端依赖项 ``` # Web interface (frontend/requirements.txt) streamlit>=1.28.0 boto3>=1.35.0 requests>=2.31.0 ``` ## 架构组件 ### AgentCore Support Agent - **FastAPI 应用程序**:处理 HTTP 请求和 agent 交互 - **Strands 框架**:使用 Nova Pro 模型进行 AI agent 编排 - **记忆集成**:使用 AgentCore Memory 进行短期对话存储 - **MCP 客户端**:多个 Model Context Protocol 集成 ### 基础设施 - **AgentCore Gateway**:带有 OAuth 身份验证的 MCP 网关 - **Lambda Target**:AWS re:Post 社区支持工具 - **Cognito OAuth**:身份验证与授权 - **Memory 服务**:对话上下文存储 ### 前端 - **Streamlit 界面**:交互式 Web 聊天界面 - **实时聊天**:与 AgentCore Runtime 直接集成 - **会话管理**:对话历史记录和上下文 ## 故障排除 ### 常见问题 1. **Lambda 部署失败** - 确保 IAM 角色存在并具有 Lambda 执行权限 - 验证部署包是否已正确创建 2. **基础设施部署失败** - 检查 AWS 凭证和权限 - 验证 deploy.py 中的 Lambda ARN 是否已正确更新 3. **Token 生成失败** - 确保 Client ID 和域名正确 - 检查您的 Cognito 配置是否需要 Client Secret 4. **Agent Runtime 部署失败** - 验证 ECR 镜像存在且可访问 - 检查 Bedrock AgentCore 的 IAM 角色权限 5. **Agent 调用失败** - 确保 Agent Runtime ARN 正确 - 验证身份验证 token 是否有效 - 检查网络连接和权限 ### 调试步骤 1. **检查 AWS CLI 配置**: ``` aws sts get-caller-identity ``` 2. **验证 ECR 镜像**: ``` aws ecr describe-images --repository-name support-agent --region us-west-2 ``` 3. **测试 Lambda 函数**: ``` aws lambda invoke --function-name AgentCoreGateway --payload '{"search_phrase":"S3"}' response.json ``` 4. **检查 Agent Runtime 状态**: ``` aws bedrock-agentcore describe-agent-runtime --agent-runtime-arn YOUR_AGENT_RUNTIME_ARN ``` ## 支持与文档 - **安全文档**:请参阅 [SECURITY.md](SECURITY.md) 了解威胁模型、特定于服务的安全指南、设计文档和风险评估 - **生产就绪**:请参阅 [PRODUCTION.md](PRODUCTION.md) 了解网络隔离、护栏调优、可观测性以及其他生产环境的注意事项 - **AgentCore 文档**:[AWS Bedrock AgentCore 开发人员指南](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/) - **Strands 框架**:有关 agent 开发,请参阅 Strands 文档 - **MCP 协议**:[Model Context Protocol 规范](https://modelcontextprotocol.io/) - **AWS re:Post**:[AWS 社区论坛](https://repost.aws/) - **许可证**:有关条款,请参阅 [LICENSE](LICENSE) ## 后续步骤 部署后: 1. **监控性能**:设置 CloudWatch 监控和警报 2. **扩展资源**:根据使用模式配置自动扩展 3. **增强安全性**:实施生产级的安全措施 4. **添加功能**:使用额外的 MCP 工具扩展 agent 能力 5. **集成应用程序**:在您的应用程序中使用 Agent Runtime ARN ## 贡献 在为该项目做贡献时: 1. 遵循现有的代码结构和模式 2. 为任何新功能更新文档 3. 彻底测试所有部署步骤 4. 确保维持安全最佳实践
标签:AI智能体, AWS, DLL 劫持, DPI, Kubernetes, MCP协议, 云端运维, 大语言模型, 对话机器人, 特权提升, 自动化部署, 请求拦截, 逆向工具