@aws/agentcore 0.3.0-preview.1.0 → 0.3.0-preview.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +231 -106
- package/dist/assets/agents/AGENTS.md +13 -2
- package/dist/assets/container/python/Dockerfile +28 -0
- package/dist/assets/container/python/dockerignore.template +27 -0
- package/dist/assets/python/autogen/base/README.md +9 -11
- package/dist/assets/python/autogen/base/gitignore.template +1 -0
- package/dist/assets/python/autogen/base/mcp_client/__init__.py +1 -0
- package/dist/assets/python/autogen/base/model/__init__.py +1 -0
- package/dist/assets/python/autogen/base/pyproject.toml +0 -1
- package/dist/assets/python/crewai/base/README.md +9 -11
- package/dist/assets/python/crewai/base/gitignore.template +1 -0
- package/dist/assets/python/crewai/base/model/__init__.py +1 -0
- package/dist/assets/python/crewai/base/model/load.py +2 -2
- package/dist/assets/python/crewai/base/pyproject.toml +0 -1
- package/dist/assets/python/googleadk/base/README.md +9 -9
- package/dist/assets/python/googleadk/base/gitignore.template +1 -0
- package/dist/assets/python/googleadk/base/main.py +10 -3
- package/dist/assets/python/googleadk/base/mcp_client/__init__.py +1 -0
- package/dist/assets/python/googleadk/base/model/__init__.py +1 -0
- package/dist/assets/python/googleadk/base/pyproject.toml +0 -1
- package/dist/assets/python/langchain_langgraph/base/README.md +9 -11
- package/dist/assets/python/langchain_langgraph/base/gitignore.template +1 -0
- package/dist/assets/python/langchain_langgraph/base/main.py +8 -3
- package/dist/assets/python/langchain_langgraph/base/mcp_client/__init__.py +1 -0
- package/dist/assets/python/langchain_langgraph/base/model/__init__.py +1 -0
- package/dist/assets/python/langchain_langgraph/base/model/load.py +2 -2
- package/dist/assets/python/langchain_langgraph/base/pyproject.toml +0 -1
- package/dist/assets/python/openaiagents/base/README.md +9 -9
- package/dist/assets/python/openaiagents/base/gitignore.template +1 -0
- package/dist/assets/python/openaiagents/base/main.py +13 -6
- package/dist/assets/python/openaiagents/base/mcp_client/__init__.py +1 -0
- package/dist/assets/python/openaiagents/base/model/__init__.py +1 -0
- package/dist/assets/python/openaiagents/base/pyproject.toml +0 -1
- package/dist/assets/python/strands/base/README.md +9 -11
- package/dist/assets/python/strands/base/gitignore.template +1 -1
- package/dist/assets/python/strands/base/main.py +16 -9
- package/dist/assets/python/strands/base/mcp_client/__init__.py +1 -0
- package/dist/assets/python/strands/base/model/__init__.py +1 -0
- package/dist/assets/python/strands/base/model/load.py +2 -2
- package/dist/assets/python/strands/base/pyproject.toml +6 -6
- package/dist/assets/python/strands/capabilities/memory/__init__.py +1 -0
- package/dist/cli/index.mjs +306 -443
- package/dist/lib/constants.d.ts +12 -0
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +22 -1
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +7 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/packaging/container.d.ts +10 -0
- package/dist/lib/packaging/container.d.ts.map +1 -0
- package/dist/lib/packaging/container.js +78 -0
- package/dist/lib/packaging/container.js.map +1 -0
- package/dist/lib/packaging/index.d.ts +5 -1
- package/dist/lib/packaging/index.d.ts.map +1 -1
- package/dist/lib/packaging/index.js +10 -2
- package/dist/lib/packaging/index.js.map +1 -1
- package/dist/lib/packaging/node.d.ts +6 -1
- package/dist/lib/packaging/node.d.ts.map +1 -1
- package/dist/lib/packaging/node.js +2 -1
- package/dist/lib/packaging/node.js.map +1 -1
- package/dist/lib/packaging/python.d.ts +7 -1
- package/dist/lib/packaging/python.d.ts.map +1 -1
- package/dist/lib/packaging/python.js +6 -4
- package/dist/lib/packaging/python.js.map +1 -1
- package/dist/schema/constants.d.ts +5 -0
- package/dist/schema/constants.d.ts.map +1 -1
- package/dist/schema/constants.js +11 -1
- package/dist/schema/constants.js.map +1 -1
- package/dist/schema/schemas/agent-env.d.ts +6 -0
- package/dist/schema/schemas/agent-env.d.ts.map +1 -1
- package/dist/schema/schemas/agent-env.js +8 -2
- package/dist/schema/schemas/agent-env.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +6 -0
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.js +3 -1
- package/dist/schema/schemas/mcp.js.map +1 -1
- package/package.json +29 -2
- package/scripts/bump-version.ts +31 -7
|
@@ -60,21 +60,32 @@ file maps to a JSON config file and includes validation constraints as comments.
|
|
|
60
60
|
|
|
61
61
|
### Common Enum Values
|
|
62
62
|
|
|
63
|
-
- **BuildType**: `'CodeZip'`
|
|
63
|
+
- **BuildType**: `'CodeZip'` | `'Container'`
|
|
64
64
|
- **NetworkMode**: `'PUBLIC'`
|
|
65
65
|
- **RuntimeVersion**: `'PYTHON_3_10'` | `'PYTHON_3_11'` | `'PYTHON_3_12'` | `'PYTHON_3_13'`
|
|
66
66
|
- **MemoryStrategyType**: `'SEMANTIC'` | `'SUMMARIZATION'` | `'USER_PREFERENCE'`
|
|
67
67
|
|
|
68
|
+
### Build Types
|
|
69
|
+
|
|
70
|
+
- **CodeZip**: Python source is packaged as a zip artifact and deployed directly to AgentCore Runtime.
|
|
71
|
+
- **Container**: Agent code is built as a Docker container image. Requires a `Dockerfile` in the agent's `codeLocation`
|
|
72
|
+
directory. At deploy time, the source is uploaded to S3, built in CodeBuild (ARM64), pushed to a per-agent ECR
|
|
73
|
+
repository, and the container URI is provided to the AgentCore Runtime. For local development (`agentcore dev`), the
|
|
74
|
+
container is built and run locally with volume-mounted hot-reload.
|
|
75
|
+
|
|
68
76
|
### Supported Frameworks (for template agents)
|
|
69
77
|
|
|
70
78
|
- **Strands** - Works with Bedrock, Anthropic, OpenAI, Gemini
|
|
71
79
|
- **LangChain_LangGraph** - Works with Bedrock, Anthropic, OpenAI, Gemini
|
|
80
|
+
- **CrewAI** - Works with Bedrock, Anthropic, OpenAI, Gemini
|
|
72
81
|
- **GoogleADK** - Gemini only
|
|
73
82
|
- **OpenAIAgents** - OpenAI only
|
|
83
|
+
- **AutoGen** - Works with Bedrock, Anthropic, OpenAI, Gemini
|
|
74
84
|
|
|
75
85
|
### Specific Context
|
|
76
86
|
|
|
77
|
-
Directory pathing to local projects is required for runtimes.
|
|
87
|
+
Directory pathing to local projects is required for runtimes. Both CodeZip (Python zip) and Container (Docker image)
|
|
88
|
+
deployment options are available.
|
|
78
89
|
|
|
79
90
|
## Deployment
|
|
80
91
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
ENV UV_SYSTEM_PYTHON=1 \
|
|
6
|
+
UV_COMPILE_BYTECODE=1 \
|
|
7
|
+
UV_NO_PROGRESS=1 \
|
|
8
|
+
PYTHONUNBUFFERED=1 \
|
|
9
|
+
DOCKER_CONTAINER=1
|
|
10
|
+
|
|
11
|
+
RUN useradd -m -u 1000 bedrock_agentcore
|
|
12
|
+
|
|
13
|
+
COPY pyproject.toml uv.lock ./
|
|
14
|
+
RUN uv sync --frozen --no-dev --no-install-project
|
|
15
|
+
|
|
16
|
+
COPY --chown=bedrock_agentcore:bedrock_agentcore . .
|
|
17
|
+
RUN uv sync --frozen --no-dev
|
|
18
|
+
|
|
19
|
+
USER bedrock_agentcore
|
|
20
|
+
|
|
21
|
+
# AgentCore Runtime service contract ports
|
|
22
|
+
# https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html
|
|
23
|
+
# 8080: HTTP Mode
|
|
24
|
+
# 8000: MCP Mode
|
|
25
|
+
# 9000: A2A Mode
|
|
26
|
+
EXPOSE 8080 8000 9000
|
|
27
|
+
|
|
28
|
+
CMD ["opentelemetry-instrument", "python", "-m", "{{entrypoint}}"]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.venv/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
|
|
9
|
+
# IDE
|
|
10
|
+
.vscode/
|
|
11
|
+
.idea/
|
|
12
|
+
|
|
13
|
+
# Testing
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.coverage
|
|
16
|
+
htmlcov/
|
|
17
|
+
|
|
18
|
+
# Secrets and environment files
|
|
19
|
+
.env
|
|
20
|
+
.env.*
|
|
21
|
+
|
|
22
|
+
# Version control
|
|
23
|
+
.git/
|
|
24
|
+
|
|
25
|
+
# AgentCore build artifacts
|
|
26
|
+
.agentcore/artifacts/
|
|
27
|
+
*.zip
|
|
@@ -2,25 +2,23 @@ This is a project generated by the agentcore create CLI tool!
|
|
|
2
2
|
|
|
3
3
|
# Layout
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The generated application code lives at the agent root directory. At the root, there is a `.gitignore` file, an
|
|
6
|
+
`agentcore/` folder which represents the configurations and state associated with this project. Other `agentcore`
|
|
7
7
|
commands like `deploy`, `dev`, and `invoke` rely on the configuration stored here.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Agent Root
|
|
10
10
|
|
|
11
|
-
The main entrypoint to your app is defined in `
|
|
11
|
+
The main entrypoint to your app is defined in `main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
|
|
12
12
|
file defines a Starlette ASGI app with the AutoGen framework running within.
|
|
13
13
|
|
|
14
|
-
`
|
|
14
|
+
`model/load.py` instantiates your chosen model provider.
|
|
15
15
|
|
|
16
16
|
## Environment Variables
|
|
17
17
|
|
|
18
|
-
| Variable
|
|
19
|
-
|
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `AGENTCORE_IDENTITY_GEMINI` | Yes (Gemini) | Gemini API key (local) or Identity provider name (deployed) |
|
|
23
|
-
| `LOCAL_DEV` | No | Set to `1` to use `agentcore/.env` instead of AgentCore Identity |
|
|
18
|
+
| Variable | Required | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
{{#if hasIdentity}}| `{{identityProviders.[0].envVarName}}` | Yes | {{modelProvider}} API key (local) or Identity provider name (deployed) |
|
|
21
|
+
{{/if}}| `LOCAL_DEV` | No | Set to `1` to use `.env.local` instead of AgentCore Identity |
|
|
24
22
|
|
|
25
23
|
# Developing locally
|
|
26
24
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -2,25 +2,23 @@ This is a project generated by the agentcore create CLI tool!
|
|
|
2
2
|
|
|
3
3
|
# Layout
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The generated application code lives at the agent root directory. At the root, there is a `.gitignore` file, an
|
|
6
|
+
`agentcore/` folder which represents the configurations and state associated with this project. Other `agentcore`
|
|
7
7
|
commands like `deploy`, `dev`, and `invoke` rely on the configuration stored here.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Agent Root
|
|
10
10
|
|
|
11
|
-
The main entrypoint to your app is defined in `
|
|
11
|
+
The main entrypoint to your app is defined in `main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
|
|
12
12
|
file defines a Starlette ASGI app with the CrewAI framework running within.
|
|
13
13
|
|
|
14
|
-
`
|
|
14
|
+
`model/load.py` instantiates your chosen model provider.
|
|
15
15
|
|
|
16
16
|
## Environment Variables
|
|
17
17
|
|
|
18
|
-
| Variable
|
|
19
|
-
|
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `AGENTCORE_IDENTITY_GEMINI` | Yes (Gemini) | Gemini API key (local) or Identity provider name (deployed) |
|
|
23
|
-
| `LOCAL_DEV` | No | Set to `1` to use `agentcore/.env` instead of AgentCore Identity |
|
|
18
|
+
| Variable | Required | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
{{#if hasIdentity}}| `{{identityProviders.[0].envVarName}}` | Yes | {{modelProvider}} API key (local) or Identity provider name (deployed) |
|
|
21
|
+
{{/if}}| `LOCAL_DEV` | No | Set to `1` to use `.env.local` instead of AgentCore Identity |
|
|
24
22
|
|
|
25
23
|
# Developing locally
|
|
26
24
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -87,7 +87,7 @@ def load_model() -> LLM:
|
|
|
87
87
|
# CrewAI requires OPENAI_API_KEY env var (ignores api_key parameter)
|
|
88
88
|
os.environ["OPENAI_API_KEY"] = api_key
|
|
89
89
|
return LLM(
|
|
90
|
-
model="openai/gpt-
|
|
90
|
+
model="openai/gpt-4.1",
|
|
91
91
|
api_key=api_key
|
|
92
92
|
)
|
|
93
93
|
{{/if}}
|
|
@@ -127,7 +127,7 @@ def load_model() -> LLM:
|
|
|
127
127
|
# CrewAI requires GEMINI_API_KEY env var (ignores api_key parameter)
|
|
128
128
|
os.environ["GEMINI_API_KEY"] = api_key
|
|
129
129
|
return LLM(
|
|
130
|
-
model="gemini/gemini-2.
|
|
130
|
+
model="gemini/gemini-2.5-flash",
|
|
131
131
|
api_key=api_key
|
|
132
132
|
)
|
|
133
133
|
{{/if}}
|
|
@@ -2,23 +2,23 @@ This is a project generated by the agentcore create CLI tool!
|
|
|
2
2
|
|
|
3
3
|
# Layout
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The generated application code lives at the agent root directory. At the root, there is a `.gitignore` file, an
|
|
6
|
+
`agentcore/` folder which represents the configurations and state associated with this project. Other `agentcore`
|
|
7
7
|
commands like `deploy`, `dev`, and `invoke` rely on the configuration stored here.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Agent Root
|
|
10
10
|
|
|
11
|
-
The main entrypoint to your app is defined in `
|
|
11
|
+
The main entrypoint to your app is defined in `main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
|
|
12
12
|
file defines a Starlette ASGI app with the Google ADK framework running within.
|
|
13
13
|
|
|
14
|
-
`
|
|
14
|
+
`model/load.py` instantiates your chosen model provider (Gemini).
|
|
15
15
|
|
|
16
16
|
## Environment Variables
|
|
17
17
|
|
|
18
|
-
| Variable
|
|
19
|
-
|
|
|
20
|
-
| `
|
|
21
|
-
| `LOCAL_DEV`
|
|
18
|
+
| Variable | Required | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
{{#if hasIdentity}}| `{{identityProviders.[0].envVarName}}` | Yes | {{modelProvider}} API key (local) or Identity provider name (deployed) |
|
|
21
|
+
{{/if}}| `LOCAL_DEV` | No | Set to `1` to use `.env.local` instead of AgentCore Identity |
|
|
22
22
|
|
|
23
23
|
# Developing locally
|
|
24
24
|
|
|
@@ -22,12 +22,18 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
22
22
|
return a + b
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
# Set environment variables for model authentication
|
|
26
|
-
load_model()
|
|
27
|
-
|
|
28
25
|
# Get MCP Toolset
|
|
29
26
|
mcp_toolset = [get_streamable_http_mcp_client()]
|
|
30
27
|
|
|
28
|
+
_credentials_loaded = False
|
|
29
|
+
|
|
30
|
+
def ensure_credentials_loaded():
|
|
31
|
+
global _credentials_loaded
|
|
32
|
+
if not _credentials_loaded:
|
|
33
|
+
load_model()
|
|
34
|
+
_credentials_loaded = True
|
|
35
|
+
|
|
36
|
+
|
|
31
37
|
# Agent Definition
|
|
32
38
|
agent = Agent(
|
|
33
39
|
model=MODEL_ID,
|
|
@@ -40,6 +46,7 @@ agent = Agent(
|
|
|
40
46
|
|
|
41
47
|
# Session and Runner
|
|
42
48
|
async def setup_session_and_runner(user_id, session_id):
|
|
49
|
+
ensure_credentials_loaded()
|
|
43
50
|
session_service = InMemorySessionService()
|
|
44
51
|
session = await session_service.create_session(
|
|
45
52
|
app_name=APP_NAME, user_id=user_id, session_id=session_id
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -2,25 +2,23 @@ This is a project generated by the agentcore create CLI tool!
|
|
|
2
2
|
|
|
3
3
|
# Layout
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The generated application code lives at the agent root directory. At the root, there is a `.gitignore` file, an
|
|
6
|
+
`agentcore/` folder which represents the configurations and state associated with this project. Other `agentcore`
|
|
7
7
|
commands like `deploy`, `dev`, and `invoke` rely on the configuration stored here.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Agent Root
|
|
10
10
|
|
|
11
|
-
The main entrypoint to your app is defined in `
|
|
11
|
+
The main entrypoint to your app is defined in `main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
|
|
12
12
|
file defines a Starlette ASGI app with the LangChain/LangGraph framework running within.
|
|
13
13
|
|
|
14
|
-
`
|
|
14
|
+
`model/load.py` instantiates your chosen model provider.
|
|
15
15
|
|
|
16
16
|
## Environment Variables
|
|
17
17
|
|
|
18
|
-
| Variable
|
|
19
|
-
|
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `AGENTCORE_IDENTITY_GEMINI` | Yes (Gemini) | Gemini API key (local) or Identity provider name (deployed) |
|
|
23
|
-
| `LOCAL_DEV` | No | Set to `1` to use `agentcore/.env` instead of AgentCore Identity |
|
|
18
|
+
| Variable | Required | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
{{#if hasIdentity}}| `{{identityProviders.[0].envVarName}}` | Yes | {{modelProvider}} API key (local) or Identity provider name (deployed) |
|
|
21
|
+
{{/if}}| `LOCAL_DEV` | No | Set to `1` to use `.env.local` instead of AgentCore Identity |
|
|
24
22
|
|
|
25
23
|
# Developing locally
|
|
26
24
|
|
|
@@ -9,8 +9,13 @@ from mcp_client.client import get_streamable_http_mcp_client
|
|
|
9
9
|
app = BedrockAgentCoreApp()
|
|
10
10
|
log = app.logger
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
_llm = None
|
|
13
|
+
|
|
14
|
+
def get_or_create_model():
|
|
15
|
+
global _llm
|
|
16
|
+
if _llm is None:
|
|
17
|
+
_llm = load_model()
|
|
18
|
+
return _llm
|
|
14
19
|
|
|
15
20
|
|
|
16
21
|
# Define a simple function tool
|
|
@@ -35,7 +40,7 @@ async def invoke(payload, context):
|
|
|
35
40
|
mcp_tools = await mcp_client.get_tools()
|
|
36
41
|
|
|
37
42
|
# Define the agent using create_react_agent
|
|
38
|
-
graph = create_react_agent(
|
|
43
|
+
graph = create_react_agent(get_or_create_model(), tools=mcp_tools + tools)
|
|
39
44
|
|
|
40
45
|
# Process the user prompt
|
|
41
46
|
prompt = payload.get("prompt", "What can you help me with?")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -80,7 +80,7 @@ def _get_api_key() -> str:
|
|
|
80
80
|
def load_model() -> ChatOpenAI:
|
|
81
81
|
"""Get authenticated OpenAI model client."""
|
|
82
82
|
return ChatOpenAI(
|
|
83
|
-
model="gpt-
|
|
83
|
+
model="gpt-4.1",
|
|
84
84
|
api_key=_get_api_key()
|
|
85
85
|
)
|
|
86
86
|
{{/if}}
|
|
@@ -117,7 +117,7 @@ def _get_api_key() -> str:
|
|
|
117
117
|
def load_model() -> ChatGoogleGenerativeAI:
|
|
118
118
|
"""Get authenticated Gemini model client."""
|
|
119
119
|
return ChatGoogleGenerativeAI(
|
|
120
|
-
model="gemini-2.
|
|
120
|
+
model="gemini-2.5-flash",
|
|
121
121
|
api_key=_get_api_key()
|
|
122
122
|
)
|
|
123
123
|
{{/if}}
|
|
@@ -2,23 +2,23 @@ This is a project generated by the agentcore create CLI tool!
|
|
|
2
2
|
|
|
3
3
|
# Layout
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The generated application code lives at the agent root directory. At the root, there is a `.gitignore` file, an
|
|
6
|
+
`agentcore/` folder which represents the configurations and state associated with this project. Other `agentcore`
|
|
7
7
|
commands like `deploy`, `dev`, and `invoke` rely on the configuration stored here.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Agent Root
|
|
10
10
|
|
|
11
|
-
The main entrypoint to your app is defined in `
|
|
11
|
+
The main entrypoint to your app is defined in `main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
|
|
12
12
|
file defines a Starlette ASGI app with the OpenAI Agents SDK framework running within.
|
|
13
13
|
|
|
14
|
-
`
|
|
14
|
+
`model/load.py` instantiates your chosen model provider (OpenAI).
|
|
15
15
|
|
|
16
16
|
## Environment Variables
|
|
17
17
|
|
|
18
|
-
| Variable
|
|
19
|
-
|
|
|
20
|
-
| `
|
|
21
|
-
| `LOCAL_DEV`
|
|
18
|
+
| Variable | Required | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
{{#if hasIdentity}}| `{{identityProviders.[0].envVarName}}` | Yes | {{modelProvider}} API key (local) or Identity provider name (deployed) |
|
|
21
|
+
{{/if}}| `LOCAL_DEV` | No | Set to `1` to use `.env.local` instead of AgentCore Identity |
|
|
22
22
|
|
|
23
23
|
# Developing locally
|
|
24
24
|
|
|
@@ -7,12 +7,17 @@ from mcp_client.client import get_streamable_http_mcp_client
|
|
|
7
7
|
app = BedrockAgentCoreApp()
|
|
8
8
|
log = app.logger
|
|
9
9
|
|
|
10
|
-
# Set environment variables for model authentication
|
|
11
|
-
load_model()
|
|
12
|
-
|
|
13
10
|
# Get MCP Server
|
|
14
11
|
mcp_server = get_streamable_http_mcp_client()
|
|
15
12
|
|
|
13
|
+
_credentials_loaded = False
|
|
14
|
+
|
|
15
|
+
def ensure_credentials_loaded():
|
|
16
|
+
global _credentials_loaded
|
|
17
|
+
if not _credentials_loaded:
|
|
18
|
+
load_model()
|
|
19
|
+
_credentials_loaded = True
|
|
20
|
+
|
|
16
21
|
|
|
17
22
|
# Define a simple function tool
|
|
18
23
|
@function_tool
|
|
@@ -23,13 +28,15 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
23
28
|
|
|
24
29
|
# Define the agent execution
|
|
25
30
|
async def main(query):
|
|
31
|
+
ensure_credentials_loaded()
|
|
26
32
|
try:
|
|
27
33
|
async with mcp_server as server:
|
|
28
34
|
active_servers = [server] if server else []
|
|
29
|
-
# Currently defaults to GPT-4.1
|
|
30
|
-
# https://openai.github.io/openai-agents-python/models/
|
|
31
35
|
agent = Agent(
|
|
32
|
-
name="{{ name }}",
|
|
36
|
+
name="{{ name }}",
|
|
37
|
+
model="gpt-4.1",
|
|
38
|
+
mcp_servers=active_servers,
|
|
39
|
+
tools=[add_numbers]
|
|
33
40
|
)
|
|
34
41
|
result = await Runner.run(agent, query)
|
|
35
42
|
return result
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -2,25 +2,23 @@ This is a project generated by the agentcore create basic CLI tool!
|
|
|
2
2
|
|
|
3
3
|
# Layout
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The generated application code lives at the agent root directory. At the root, there is a `.gitignore` file, an
|
|
6
|
+
`agentcore/` folder which represents the configurations and state associated with this project. Other `agentcore`
|
|
7
7
|
commands like `deploy`, `dev`, and `invoke` rely on the configuration stored here.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Agent Root
|
|
10
10
|
|
|
11
|
-
The main entrypoint to your app is defined in `
|
|
11
|
+
The main entrypoint to your app is defined in `main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
|
|
12
12
|
file defines a Starlette ASGI app with the chosen Agent framework SDK running within.
|
|
13
13
|
|
|
14
|
-
`
|
|
14
|
+
`model/load.py` instantiates your chosen model provider.
|
|
15
15
|
|
|
16
16
|
## Environment Variables
|
|
17
17
|
|
|
18
|
-
| Variable
|
|
19
|
-
|
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `AGENTCORE_IDENTITY_GEMINI` | Yes (Gemini) | Gemini API key (local) or Identity provider name (deployed) |
|
|
23
|
-
| `LOCAL_DEV` | No | Set to `1` to use `agentcore/.env` instead of AgentCore Identity |
|
|
18
|
+
| Variable | Required | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
{{#if hasIdentity}}| `{{identityProviders.[0].envVarName}}` | Yes | {{modelProvider}} API key (local) or Identity provider name (deployed) |
|
|
21
|
+
{{/if}}| `LOCAL_DEV` | No | Set to `1` to use `.env.local` instead of AgentCore Identity |
|
|
24
22
|
|
|
25
23
|
# Developing locally
|
|
26
24
|
|
|
@@ -42,14 +42,19 @@ def agent_factory():
|
|
|
42
42
|
return get_or_create_agent
|
|
43
43
|
get_or_create_agent = agent_factory()
|
|
44
44
|
{{else}}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
_agent = None
|
|
46
|
+
|
|
47
|
+
def get_or_create_agent():
|
|
48
|
+
global _agent
|
|
49
|
+
if _agent is None:
|
|
50
|
+
_agent = Agent(
|
|
51
|
+
model=load_model(),
|
|
52
|
+
system_prompt="""
|
|
53
|
+
You are a helpful assistant. Use tools when appropriate.
|
|
54
|
+
""",
|
|
55
|
+
tools=tools+[mcp_client]
|
|
56
|
+
)
|
|
57
|
+
return _agent
|
|
53
58
|
{{/if}}
|
|
54
59
|
|
|
55
60
|
|
|
@@ -61,8 +66,10 @@ async def invoke(payload, context):
|
|
|
61
66
|
session_id = getattr(context, 'session_id', 'default-session')
|
|
62
67
|
user_id = getattr(context, 'user_id', 'default-user')
|
|
63
68
|
agent = get_or_create_agent(session_id, user_id)
|
|
64
|
-
|
|
69
|
+
{{else}}
|
|
70
|
+
agent = get_or_create_agent()
|
|
65
71
|
{{/if}}
|
|
72
|
+
|
|
66
73
|
# Execute and format response
|
|
67
74
|
stream = agent.stream_async(payload.get("prompt"))
|
|
68
75
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker
|