@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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +231 -106
  3. package/dist/assets/agents/AGENTS.md +13 -2
  4. package/dist/assets/container/python/Dockerfile +28 -0
  5. package/dist/assets/container/python/dockerignore.template +27 -0
  6. package/dist/assets/python/autogen/base/README.md +9 -11
  7. package/dist/assets/python/autogen/base/gitignore.template +1 -0
  8. package/dist/assets/python/autogen/base/mcp_client/__init__.py +1 -0
  9. package/dist/assets/python/autogen/base/model/__init__.py +1 -0
  10. package/dist/assets/python/autogen/base/pyproject.toml +0 -1
  11. package/dist/assets/python/crewai/base/README.md +9 -11
  12. package/dist/assets/python/crewai/base/gitignore.template +1 -0
  13. package/dist/assets/python/crewai/base/model/__init__.py +1 -0
  14. package/dist/assets/python/crewai/base/model/load.py +2 -2
  15. package/dist/assets/python/crewai/base/pyproject.toml +0 -1
  16. package/dist/assets/python/googleadk/base/README.md +9 -9
  17. package/dist/assets/python/googleadk/base/gitignore.template +1 -0
  18. package/dist/assets/python/googleadk/base/main.py +10 -3
  19. package/dist/assets/python/googleadk/base/mcp_client/__init__.py +1 -0
  20. package/dist/assets/python/googleadk/base/model/__init__.py +1 -0
  21. package/dist/assets/python/googleadk/base/pyproject.toml +0 -1
  22. package/dist/assets/python/langchain_langgraph/base/README.md +9 -11
  23. package/dist/assets/python/langchain_langgraph/base/gitignore.template +1 -0
  24. package/dist/assets/python/langchain_langgraph/base/main.py +8 -3
  25. package/dist/assets/python/langchain_langgraph/base/mcp_client/__init__.py +1 -0
  26. package/dist/assets/python/langchain_langgraph/base/model/__init__.py +1 -0
  27. package/dist/assets/python/langchain_langgraph/base/model/load.py +2 -2
  28. package/dist/assets/python/langchain_langgraph/base/pyproject.toml +0 -1
  29. package/dist/assets/python/openaiagents/base/README.md +9 -9
  30. package/dist/assets/python/openaiagents/base/gitignore.template +1 -0
  31. package/dist/assets/python/openaiagents/base/main.py +13 -6
  32. package/dist/assets/python/openaiagents/base/mcp_client/__init__.py +1 -0
  33. package/dist/assets/python/openaiagents/base/model/__init__.py +1 -0
  34. package/dist/assets/python/openaiagents/base/pyproject.toml +0 -1
  35. package/dist/assets/python/strands/base/README.md +9 -11
  36. package/dist/assets/python/strands/base/gitignore.template +1 -1
  37. package/dist/assets/python/strands/base/main.py +16 -9
  38. package/dist/assets/python/strands/base/mcp_client/__init__.py +1 -0
  39. package/dist/assets/python/strands/base/model/__init__.py +1 -0
  40. package/dist/assets/python/strands/base/model/load.py +2 -2
  41. package/dist/assets/python/strands/base/pyproject.toml +6 -6
  42. package/dist/assets/python/strands/capabilities/memory/__init__.py +1 -0
  43. package/dist/cli/index.mjs +306 -443
  44. package/dist/lib/constants.d.ts +12 -0
  45. package/dist/lib/constants.d.ts.map +1 -1
  46. package/dist/lib/constants.js +22 -1
  47. package/dist/lib/constants.js.map +1 -1
  48. package/dist/lib/index.d.ts +1 -1
  49. package/dist/lib/index.d.ts.map +1 -1
  50. package/dist/lib/index.js +7 -1
  51. package/dist/lib/index.js.map +1 -1
  52. package/dist/lib/packaging/container.d.ts +10 -0
  53. package/dist/lib/packaging/container.d.ts.map +1 -0
  54. package/dist/lib/packaging/container.js +78 -0
  55. package/dist/lib/packaging/container.js.map +1 -0
  56. package/dist/lib/packaging/index.d.ts +5 -1
  57. package/dist/lib/packaging/index.d.ts.map +1 -1
  58. package/dist/lib/packaging/index.js +10 -2
  59. package/dist/lib/packaging/index.js.map +1 -1
  60. package/dist/lib/packaging/node.d.ts +6 -1
  61. package/dist/lib/packaging/node.d.ts.map +1 -1
  62. package/dist/lib/packaging/node.js +2 -1
  63. package/dist/lib/packaging/node.js.map +1 -1
  64. package/dist/lib/packaging/python.d.ts +7 -1
  65. package/dist/lib/packaging/python.d.ts.map +1 -1
  66. package/dist/lib/packaging/python.js +6 -4
  67. package/dist/lib/packaging/python.js.map +1 -1
  68. package/dist/schema/constants.d.ts +5 -0
  69. package/dist/schema/constants.d.ts.map +1 -1
  70. package/dist/schema/constants.js +11 -1
  71. package/dist/schema/constants.js.map +1 -1
  72. package/dist/schema/schemas/agent-env.d.ts +6 -0
  73. package/dist/schema/schemas/agent-env.d.ts.map +1 -1
  74. package/dist/schema/schemas/agent-env.js +8 -2
  75. package/dist/schema/schemas/agent-env.js.map +1 -1
  76. package/dist/schema/schemas/agentcore-project.d.ts +6 -0
  77. package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
  78. package/dist/schema/schemas/mcp.d.ts.map +1 -1
  79. package/dist/schema/schemas/mcp.js +3 -1
  80. package/dist/schema/schemas/mcp.js.map +1 -1
  81. package/package.json +29 -2
  82. 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. Only Python offers a zip based direct code deploy option.
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
- There is one directory with generated application code, `src/` . At the root, there is a `.gitignore` file, a
6
- `.agentcore` folder which represents the configurations and state associated with this project. Other `agentcore`
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
- ## src/
9
+ ## Agent Root
10
10
 
11
- The main entrypoint to your app is defined in `src/main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
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
- `src/model/load.py` instantiates your chosen model provider.
14
+ `model/load.py` instantiates your chosen model provider.
15
15
 
16
16
  ## Environment Variables
17
17
 
18
- | Variable | Required | Description |
19
- | ------------------------------ | --------------- | ---------------------------------------------------------------- |
20
- | `AGENTCORE_IDENTITY_OPENAI` | Yes (OpenAI) | OpenAI API key (local) or Identity provider name (deployed) |
21
- | `AGENTCORE_IDENTITY_ANTHROPIC` | Yes (Anthropic) | Anthropic API key (local) or Identity provider name (deployed) |
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
 
@@ -24,6 +24,7 @@ wheels/
24
24
  *.egg
25
25
 
26
26
  # Virtual environments
27
+ .venv/
27
28
  venv/
28
29
  ENV/
29
30
  env/
@@ -0,0 +1 @@
1
+ # Package marker
@@ -0,0 +1 @@
1
+ # Package marker
@@ -15,7 +15,6 @@ dependencies = [
15
15
  "opentelemetry-exporter-otlp",
16
16
  "bedrock-agentcore >= 1.0.3",
17
17
  "botocore[crt] >= 1.35.0",
18
- "python-dotenv >= 1.0.1",
19
18
  "tiktoken",
20
19
  {{#if (eq modelProvider "Bedrock")}}
21
20
  "autogen-ext[anthropic] >= 0.7.5",
@@ -2,25 +2,23 @@ This is a project generated by the agentcore create CLI tool!
2
2
 
3
3
  # Layout
4
4
 
5
- There is one directory with generated application code, `src/` . At the root, there is a `.gitignore` file, a
6
- `.agentcore` folder which represents the configurations and state associated with this project. Other `agentcore`
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
- ## src/
9
+ ## Agent Root
10
10
 
11
- The main entrypoint to your app is defined in `src/main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
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
- `src/model/load.py` instantiates your chosen model provider.
14
+ `model/load.py` instantiates your chosen model provider.
15
15
 
16
16
  ## Environment Variables
17
17
 
18
- | Variable | Required | Description |
19
- | ------------------------------ | --------------- | ---------------------------------------------------------------- |
20
- | `AGENTCORE_IDENTITY_OPENAI` | Yes (OpenAI) | OpenAI API key (local) or Identity provider name (deployed) |
21
- | `AGENTCORE_IDENTITY_ANTHROPIC` | Yes (Anthropic) | Anthropic API key (local) or Identity provider name (deployed) |
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
 
@@ -24,6 +24,7 @@ wheels/
24
24
  *.egg
25
25
 
26
26
  # Virtual environments
27
+ .venv/
27
28
  venv/
28
29
  ENV/
29
30
  env/
@@ -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-4o",
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.0-flash",
130
+ model="gemini/gemini-2.5-flash",
131
131
  api_key=api_key
132
132
  )
133
133
  {{/if}}
@@ -13,7 +13,6 @@ dependencies = [
13
13
  "opentelemetry-exporter-otlp",
14
14
  "bedrock-agentcore >= 1.0.3",
15
15
  "botocore[crt] >= 1.35.0",
16
- "python-dotenv >= 1.0.1",
17
16
  {{#if (eq modelProvider "Bedrock")}}
18
17
  "crewai[tools,bedrock] >= 1.3.0",
19
18
  {{/if}}
@@ -2,23 +2,23 @@ This is a project generated by the agentcore create CLI tool!
2
2
 
3
3
  # Layout
4
4
 
5
- There is one directory with generated application code, `src/` . At the root, there is a `.gitignore` file, a
6
- `.agentcore` folder which represents the configurations and state associated with this project. Other `agentcore`
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
- ## src/
9
+ ## Agent Root
10
10
 
11
- The main entrypoint to your app is defined in `src/main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
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
- `src/model/load.py` instantiates your chosen model provider (Gemini).
14
+ `model/load.py` instantiates your chosen model provider (Gemini).
15
15
 
16
16
  ## Environment Variables
17
17
 
18
- | Variable | Required | Description |
19
- | --------------------------- | -------- | ---------------------------------------------------------------- |
20
- | `AGENTCORE_IDENTITY_GEMINI` | Yes | Gemini API key (local) or Identity provider name (deployed) |
21
- | `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 |
22
22
 
23
23
  # Developing locally
24
24
 
@@ -24,6 +24,7 @@ wheels/
24
24
  *.egg
25
25
 
26
26
  # Virtual environments
27
+ .venv/
27
28
  venv/
28
29
  ENV/
29
30
  env/
@@ -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
@@ -14,7 +14,6 @@ dependencies = [
14
14
  "google-adk >= 1.17.0",
15
15
  "bedrock-agentcore >= 1.0.3",
16
16
  "botocore[crt] >= 1.35.0",
17
- "python-dotenv >= 1.0.1",
18
17
  ]
19
18
 
20
19
  [tool.hatch.build.targets.wheel]
@@ -2,25 +2,23 @@ This is a project generated by the agentcore create CLI tool!
2
2
 
3
3
  # Layout
4
4
 
5
- There is one directory with generated application code, `src/` . At the root, there is a `.gitignore` file, a
6
- `.agentcore` folder which represents the configurations and state associated with this project. Other `agentcore`
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
- ## src/
9
+ ## Agent Root
10
10
 
11
- The main entrypoint to your app is defined in `src/main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
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
- `src/model/load.py` instantiates your chosen model provider.
14
+ `model/load.py` instantiates your chosen model provider.
15
15
 
16
16
  ## Environment Variables
17
17
 
18
- | Variable | Required | Description |
19
- | ------------------------------ | --------------- | ---------------------------------------------------------------- |
20
- | `AGENTCORE_IDENTITY_OPENAI` | Yes (OpenAI) | OpenAI API key (local) or Identity provider name (deployed) |
21
- | `AGENTCORE_IDENTITY_ANTHROPIC` | Yes (Anthropic) | Anthropic API key (local) or Identity provider name (deployed) |
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
 
@@ -24,6 +24,7 @@ wheels/
24
24
  *.egg
25
25
 
26
26
  # Virtual environments
27
+ .venv/
27
28
  venv/
28
29
  ENV/
29
30
  env/
@@ -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
- # Instantiate model
13
- llm = load_model()
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(llm, tools=mcp_tools + tools)
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?")
@@ -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-4o",
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.0-flash",
120
+ model="gemini-2.5-flash",
121
121
  api_key=_get_api_key()
122
122
  )
123
123
  {{/if}}
@@ -18,7 +18,6 @@ dependencies = [
18
18
  "tiktoken == 0.11.0",
19
19
  "bedrock-agentcore >= 1.0.3",
20
20
  "botocore[crt] >= 1.35.0",
21
- "python-dotenv >= 1.0.1",
22
21
  {{#if (eq modelProvider "Bedrock")}}
23
22
  "langchain-aws >= 1.0.0",
24
23
  {{/if}}
@@ -2,23 +2,23 @@ This is a project generated by the agentcore create CLI tool!
2
2
 
3
3
  # Layout
4
4
 
5
- There is one directory with generated application code, `src/` . At the root, there is a `.gitignore` file, a
6
- `.agentcore` folder which represents the configurations and state associated with this project. Other `agentcore`
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
- ## src/
9
+ ## Agent Root
10
10
 
11
- The main entrypoint to your app is defined in `src/main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
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
- `src/model/load.py` instantiates your chosen model provider (OpenAI).
14
+ `model/load.py` instantiates your chosen model provider (OpenAI).
15
15
 
16
16
  ## Environment Variables
17
17
 
18
- | Variable | Required | Description |
19
- | --------------------------- | -------- | ---------------------------------------------------------------- |
20
- | `AGENTCORE_IDENTITY_OPENAI` | Yes | OpenAI API key (local) or Identity provider name (deployed) |
21
- | `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 |
22
22
 
23
23
  # Developing locally
24
24
 
@@ -24,6 +24,7 @@ wheels/
24
24
  *.egg
25
25
 
26
26
  # Virtual environments
27
+ .venv/
27
28
  venv/
28
29
  ENV/
29
30
  env/
@@ -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 }}", mcp_servers=active_servers, tools=[add_numbers]
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
@@ -13,7 +13,6 @@ dependencies = [
13
13
  "openai-agents >= 0.4.2",
14
14
  "bedrock-agentcore >= 1.0.3",
15
15
  "botocore[crt] >= 1.35.0",
16
- "python-dotenv >= 1.0.1",
17
16
  ]
18
17
 
19
18
  [tool.hatch.build.targets.wheel]
@@ -2,25 +2,23 @@ This is a project generated by the agentcore create basic CLI tool!
2
2
 
3
3
  # Layout
4
4
 
5
- There is one directory with generated application code, `src/` . At the root, there is a `.gitignore` file, a
6
- `.agentcore` folder which represents the configurations and state associated with this project. Other `agentcore`
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
- ## src/
9
+ ## Agent Root
10
10
 
11
- The main entrypoint to your app is defined in `src/main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
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
- `src/model/load.py` instantiates your chosen model provider.
14
+ `model/load.py` instantiates your chosen model provider.
15
15
 
16
16
  ## Environment Variables
17
17
 
18
- | Variable | Required | Description |
19
- | ------------------------------ | --------------- | ---------------------------------------------------------------- |
20
- | `AGENTCORE_IDENTITY_OPENAI` | Yes (OpenAI) | OpenAI API key (local) or Identity provider name (deployed) |
21
- | `AGENTCORE_IDENTITY_ANTHROPIC` | Yes (Anthropic) | Anthropic API key (local) or Identity provider name (deployed) |
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
 
@@ -1,6 +1,5 @@
1
1
  # Environment variables
2
2
  .env
3
- .env
4
3
 
5
4
  # Python
6
5
  __pycache__/
@@ -25,6 +24,7 @@ wheels/
25
24
  *.egg
26
25
 
27
26
  # Virtual environments
27
+ .venv/
28
28
  venv/
29
29
  ENV/
30
30
  env/
@@ -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
- # Create agent
46
- agent = Agent(
47
- model=load_model(),
48
- system_prompt="""
49
- You are a helpful assistant. Use tools when appropriate.
50
- """,
51
- tools=tools+[mcp_client]
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