162 lines
6.6 KiB
Markdown
162 lines
6.6 KiB
Markdown
# Agentes NMP en Bedrock AgentCore
|
|
|
|
Este proyecto contiene los runtimes `NmpOnboardingAgent` y
|
|
`MyAgentAwsInfrastructureAgent`, los harnesses de infraestructura y el proxy
|
|
Lambda para invocar el agente de onboarding.
|
|
|
|
## Estructura del código
|
|
|
|
| Directorio | Responsabilidad |
|
|
| --- | --- |
|
|
| `app/NmpOnboardingAgent/` | Runtime de onboarding: entrada, modelo, cliente MCP y memoria |
|
|
| `app/MyAgentAwsInfrastructureAgent/` | Runtime de consulta de infraestructura AWS |
|
|
| `harnesses/` | `AwsInfraHarness` y `AwsInfraRestricted`, con sus configuraciones y prompts |
|
|
| `lambdas/agentcore_proxy/` | Proxy HTTP y documentación de empaquetado |
|
|
| `schemas/tools/` | Contratos MCP de clientes, KYC, PLD, documentos e infraestructura |
|
|
| `infra/iam/` | Políticas IAM y documentos de confianza |
|
|
| `examples/proxy/` | Solicitud y respuesta históricas del proxy |
|
|
| `artifacts/legacy/` | ZIP original conservado como referencia |
|
|
| `agentcore/` | Configuración declarativa, estado local y CDK generado |
|
|
|
|
Cada runtime conserva sus dependencias e imports dentro de su propio directorio
|
|
para que el empaquetado `CodeZip` sea independiente. Las rutas `toolSchemaFile`,
|
|
`codeLocation` y las entradas de `harnesses` en `agentcore/agentcore.json` son
|
|
relativas a la raíz de este proyecto. Los nombres de recursos AWS no cambian.
|
|
|
|
El código de la Lambda de infraestructura está en el componente hermano
|
|
[`nmpAWSInfraestructure`](../nmpAWSInfraestructure/README.md).
|
|
|
|
### Validación y uso
|
|
|
|
Los archivos `app/AwsInfraHarness/harness.json` y
|
|
`app/AwsInfraRestricted/harness.json` son copias de compatibilidad para el CLI
|
|
que busca los harnesses en `app/<nombre>/` durante la validación.
|
|
La configuración de CDK sigue apuntando a `harnesses/`; si se modifica un
|
|
`harness.json`, mantener su copia de `app/` idéntica antes de desplegar.
|
|
|
|
Ejecutar desde este directorio, con AgentCore CLI instalado:
|
|
|
|
```powershell
|
|
agentcore validate
|
|
agentcore dev
|
|
```
|
|
|
|
Para generar el ZIP del proxy, seguir
|
|
[`lambdas/agentcore_proxy/README.md`](lambdas/agentcore_proxy/README.md).
|
|
Los archivos de `artifacts/legacy/` y las respuestas de `examples/` son históricos.
|
|
|
|
## Referencia de AgentCore CLI
|
|
|
|
This project was created with the [AgentCore CLI](https://github.com/aws/agentcore-cli).
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
my-project/
|
|
├── AGENTS.md # AI coding assistant context
|
|
├── agentcore/
|
|
│ ├── agentcore.json # Project config (agents, memories, credentials, gateways, evaluators)
|
|
│ ├── aws-targets.json # Deployment targets (account + region)
|
|
│ ├── .env.local # Secrets — API keys (gitignored)
|
|
│ ├── .llm-context/ # TypeScript type definitions for AI assistants
|
|
│ │ ├── agentcore.ts # AgentCoreProjectSpec types
|
|
│ │ └── aws-targets.ts # Deployment target types
|
|
│ └── cdk/ # CDK infrastructure (@aws/agentcore-cdk)
|
|
├── app/ # Agent runtime application code
|
|
├── harnesses/ # Declarative harness configurations
|
|
├── lambdas/ # HTTP proxy Lambda
|
|
├── schemas/tools/ # Gateway tool contracts
|
|
├── infra/iam/ # IAM policies and trust documents
|
|
├── examples/ # Historical request/response examples
|
|
├── artifacts/legacy/ # Original ZIP packages
|
|
└── evaluators/ # Custom evaluator code (if any)
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- **Node.js** 20.x or later
|
|
- **Python 3.10+** and **uv** for Python agents ([install uv](https://docs.astral.sh/uv/getting-started/installation/))
|
|
- **AWS credentials** configured (`aws configure` or environment variables)
|
|
- **Docker** (only for Container build agents)
|
|
|
|
### Development
|
|
|
|
Run your agent locally:
|
|
|
|
```bash
|
|
agentcore dev
|
|
```
|
|
|
|
### Validate Invocation Input
|
|
|
|
Validate runtime invocation payloads before forwarding them to an agent framework. Keep user prompts typed as strings
|
|
and pass only prompt text to the agent.
|
|
|
|
### Deployment
|
|
|
|
Deploy to AWS:
|
|
|
|
```bash
|
|
agentcore deploy
|
|
```
|
|
|
|
## Commands
|
|
|
|
| Command | Description |
|
|
| --- | --- |
|
|
| `agentcore create` | Create a new AgentCore project |
|
|
| `agentcore add` | Add resources (agent, memory, credential, gateway, evaluator, policy) |
|
|
| `agentcore remove` | Remove resources |
|
|
| `agentcore dev` | Run agent locally with hot-reload |
|
|
| `agentcore deploy` | Deploy to AWS via CDK |
|
|
| `agentcore status` | Show deployment status |
|
|
| `agentcore invoke` | Invoke agent (local or deployed) |
|
|
| `agentcore logs` | View agent logs |
|
|
| `agentcore traces` | View agent traces |
|
|
| `agentcore eval` | Run evaluations |
|
|
| `agentcore package` | Package agent artifacts |
|
|
| `agentcore validate` | Validate configuration |
|
|
| `agentcore pause` | Pause a deployed agent |
|
|
| `agentcore resume` | Resume a paused agent |
|
|
| `agentcore fetch` | Fetch remote resource definitions |
|
|
| `agentcore import` | Import existing resources |
|
|
| `agentcore update` | Check for CLI updates |
|
|
|
|
## Configuration
|
|
|
|
Edit the JSON files in `agentcore/` to configure your project. See `agentcore/.llm-context/` for type definitions and validation constraints.
|
|
|
|
The project uses a **flat resource model** — agents, memories, credentials, gateways, evaluators, and policies are top-level arrays in `agentcore.json`. Resources are independent; agents discover memories and credentials at runtime via environment variables or SDK calls.
|
|
|
|
## Resources
|
|
|
|
| Resource | Purpose |
|
|
| --- | --- |
|
|
| Agent (runtime) | HTTP, MCP, or A2A agent deployed to AgentCore Runtime |
|
|
| Memory | Persistent context storage with configurable strategies |
|
|
| Credential | API key or OAuth credential providers |
|
|
| Gateway | MCP gateway that routes tool calls to targets |
|
|
| Gateway Target | Tool implementation (Lambda, MCP server, OpenAPI, Smithy, API Gateway) |
|
|
| Evaluator | Custom LLM-as-a-Judge or code-based evaluation |
|
|
| Online Eval Config | Continuous evaluation pipeline for deployed agents |
|
|
| Policy | Cedar authorization policies for gateway tools |
|
|
|
|
### Agent Types
|
|
|
|
- **Template agents**: Created from framework templates (Strands, LangChain/LangGraph, GoogleADK, OpenAI Agents, Autogen)
|
|
- **BYO agents**: Bring your own code with `agentcore add agent --type byo`
|
|
- **Import agents**: Import existing Bedrock agents with `agentcore import`
|
|
|
|
### Build Types
|
|
|
|
- **CodeZip**: Python source packaged as a zip and deployed directly to AgentCore Runtime
|
|
- **Container**: Docker image built via CodeBuild (ARM64), pushed to ECR, and deployed to AgentCore Runtime
|
|
|
|
## Documentation
|
|
|
|
- [AgentCore CLI](https://github.com/aws/agentcore-cli)
|
|
- [AgentCore CDK Constructs](https://github.com/aws/agentcore-l3-cdk-constructs)
|
|
- [Amazon Bedrock AgentCore](https://aws.amazon.com/bedrock/agentcore/)
|