@aws/agentcore 0.3.0-preview.1.0 → 0.3.0-preview.2.0
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 +173 -44
- package/dist/assets/agents/AGENTS.md +13 -2
- package/dist/assets/container/python/Dockerfile +24 -0
- package/dist/assets/container/python/dockerignore.template +20 -0
- 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/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/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/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/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/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 +5 -6
- package/dist/assets/python/strands/capabilities/memory/__init__.py +0 -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 +34 -1
- package/scripts/bump-version.ts +31 -7
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ agentcore invoke
|
|
|
56
56
|
|
|
57
57
|
| Framework | Notes |
|
|
58
58
|
| ------------------- | ----------------------------- |
|
|
59
|
-
| Strands
|
|
59
|
+
| Strands Agents | AWS-native, streaming support |
|
|
60
60
|
| LangChain/LangGraph | Graph-based workflows |
|
|
61
61
|
| Google ADK | Gemini models only |
|
|
62
62
|
| OpenAI Agents | OpenAI models only |
|
|
@@ -356,6 +356,8 @@ exports[`Assets Directory Snapshots > File listing > should match the expected f
|
|
|
356
356
|
"cdk/package.json",
|
|
357
357
|
"cdk/test/cdk.test.ts",
|
|
358
358
|
"cdk/tsconfig.json",
|
|
359
|
+
"container/python/Dockerfile",
|
|
360
|
+
"container/python/dockerignore.template",
|
|
359
361
|
"mcp/python-lambda/README.md",
|
|
360
362
|
"mcp/python-lambda/handler.py",
|
|
361
363
|
"mcp/python-lambda/pyproject.toml",
|
|
@@ -365,38 +367,50 @@ exports[`Assets Directory Snapshots > File listing > should match the expected f
|
|
|
365
367
|
"python/autogen/base/README.md",
|
|
366
368
|
"python/autogen/base/gitignore.template",
|
|
367
369
|
"python/autogen/base/main.py",
|
|
370
|
+
"python/autogen/base/mcp_client/__init__.py",
|
|
368
371
|
"python/autogen/base/mcp_client/client.py",
|
|
372
|
+
"python/autogen/base/model/__init__.py",
|
|
369
373
|
"python/autogen/base/model/load.py",
|
|
370
374
|
"python/autogen/base/pyproject.toml",
|
|
371
375
|
"python/crewai/base/README.md",
|
|
372
376
|
"python/crewai/base/gitignore.template",
|
|
373
377
|
"python/crewai/base/main.py",
|
|
378
|
+
"python/crewai/base/model/__init__.py",
|
|
374
379
|
"python/crewai/base/model/load.py",
|
|
375
380
|
"python/crewai/base/pyproject.toml",
|
|
376
381
|
"python/googleadk/base/README.md",
|
|
377
382
|
"python/googleadk/base/gitignore.template",
|
|
378
383
|
"python/googleadk/base/main.py",
|
|
384
|
+
"python/googleadk/base/mcp_client/__init__.py",
|
|
379
385
|
"python/googleadk/base/mcp_client/client.py",
|
|
386
|
+
"python/googleadk/base/model/__init__.py",
|
|
380
387
|
"python/googleadk/base/model/load.py",
|
|
381
388
|
"python/googleadk/base/pyproject.toml",
|
|
382
389
|
"python/langchain_langgraph/base/README.md",
|
|
383
390
|
"python/langchain_langgraph/base/gitignore.template",
|
|
384
391
|
"python/langchain_langgraph/base/main.py",
|
|
392
|
+
"python/langchain_langgraph/base/mcp_client/__init__.py",
|
|
385
393
|
"python/langchain_langgraph/base/mcp_client/client.py",
|
|
394
|
+
"python/langchain_langgraph/base/model/__init__.py",
|
|
386
395
|
"python/langchain_langgraph/base/model/load.py",
|
|
387
396
|
"python/langchain_langgraph/base/pyproject.toml",
|
|
388
397
|
"python/openaiagents/base/README.md",
|
|
389
398
|
"python/openaiagents/base/gitignore.template",
|
|
390
399
|
"python/openaiagents/base/main.py",
|
|
400
|
+
"python/openaiagents/base/mcp_client/__init__.py",
|
|
391
401
|
"python/openaiagents/base/mcp_client/client.py",
|
|
402
|
+
"python/openaiagents/base/model/__init__.py",
|
|
392
403
|
"python/openaiagents/base/model/load.py",
|
|
393
404
|
"python/openaiagents/base/pyproject.toml",
|
|
394
405
|
"python/strands/base/README.md",
|
|
395
406
|
"python/strands/base/gitignore.template",
|
|
396
407
|
"python/strands/base/main.py",
|
|
408
|
+
"python/strands/base/mcp_client/__init__.py",
|
|
397
409
|
"python/strands/base/mcp_client/client.py",
|
|
410
|
+
"python/strands/base/model/__init__.py",
|
|
398
411
|
"python/strands/base/model/load.py",
|
|
399
412
|
"python/strands/base/pyproject.toml",
|
|
413
|
+
"python/strands/capabilities/memory/__init__.py",
|
|
400
414
|
"python/strands/capabilities/memory/session.py",
|
|
401
415
|
"typescript/.gitkeep",
|
|
402
416
|
]
|
|
@@ -845,6 +859,7 @@ wheels/
|
|
|
845
859
|
*.egg
|
|
846
860
|
|
|
847
861
|
# Virtual environments
|
|
862
|
+
.venv/
|
|
848
863
|
venv/
|
|
849
864
|
ENV/
|
|
850
865
|
env/
|
|
@@ -918,6 +933,11 @@ if __name__ == "__main__":
|
|
|
918
933
|
"
|
|
919
934
|
`;
|
|
920
935
|
|
|
936
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/autogen/base/mcp_client/__init__.py should match snapshot 1`] = `
|
|
937
|
+
"
|
|
938
|
+
"
|
|
939
|
+
`;
|
|
940
|
+
|
|
921
941
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/autogen/base/mcp_client/client.py should match snapshot 1`] = `
|
|
922
942
|
"from typing import List
|
|
923
943
|
from autogen_ext.tools.mcp import (
|
|
@@ -940,6 +960,11 @@ async def get_streamable_http_mcp_tools() -> List[StreamableHttpMcpToolAdapter]:
|
|
|
940
960
|
"
|
|
941
961
|
`;
|
|
942
962
|
|
|
963
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/autogen/base/model/__init__.py should match snapshot 1`] = `
|
|
964
|
+
"
|
|
965
|
+
"
|
|
966
|
+
`;
|
|
967
|
+
|
|
943
968
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/autogen/base/model/load.py should match snapshot 1`] = `
|
|
944
969
|
"{{#if (eq modelProvider "Bedrock")}}
|
|
945
970
|
import os
|
|
@@ -1098,7 +1123,6 @@ dependencies = [
|
|
|
1098
1123
|
"opentelemetry-exporter-otlp",
|
|
1099
1124
|
"bedrock-agentcore >= 1.0.3",
|
|
1100
1125
|
"botocore[crt] >= 1.35.0",
|
|
1101
|
-
"python-dotenv >= 1.0.1",
|
|
1102
1126
|
"tiktoken",
|
|
1103
1127
|
{{#if (eq modelProvider "Bedrock")}}
|
|
1104
1128
|
"autogen-ext[anthropic] >= 0.7.5",
|
|
@@ -1191,6 +1215,7 @@ wheels/
|
|
|
1191
1215
|
*.egg
|
|
1192
1216
|
|
|
1193
1217
|
# Virtual environments
|
|
1218
|
+
.venv/
|
|
1194
1219
|
venv/
|
|
1195
1220
|
ENV/
|
|
1196
1221
|
env/
|
|
@@ -1267,6 +1292,11 @@ if __name__ == "__main__":
|
|
|
1267
1292
|
"
|
|
1268
1293
|
`;
|
|
1269
1294
|
|
|
1295
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/crewai/base/model/__init__.py should match snapshot 1`] = `
|
|
1296
|
+
"
|
|
1297
|
+
"
|
|
1298
|
+
`;
|
|
1299
|
+
|
|
1270
1300
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/crewai/base/model/load.py should match snapshot 1`] = `
|
|
1271
1301
|
"{{#if (eq modelProvider "Bedrock")}}
|
|
1272
1302
|
from crewai import LLM
|
|
@@ -1357,7 +1387,7 @@ def load_model() -> LLM:
|
|
|
1357
1387
|
# CrewAI requires OPENAI_API_KEY env var (ignores api_key parameter)
|
|
1358
1388
|
os.environ["OPENAI_API_KEY"] = api_key
|
|
1359
1389
|
return LLM(
|
|
1360
|
-
model="openai/gpt-
|
|
1390
|
+
model="openai/gpt-4.1",
|
|
1361
1391
|
api_key=api_key
|
|
1362
1392
|
)
|
|
1363
1393
|
{{/if}}
|
|
@@ -1397,7 +1427,7 @@ def load_model() -> LLM:
|
|
|
1397
1427
|
# CrewAI requires GEMINI_API_KEY env var (ignores api_key parameter)
|
|
1398
1428
|
os.environ["GEMINI_API_KEY"] = api_key
|
|
1399
1429
|
return LLM(
|
|
1400
|
-
model="gemini/gemini-2.
|
|
1430
|
+
model="gemini/gemini-2.5-flash",
|
|
1401
1431
|
api_key=api_key
|
|
1402
1432
|
)
|
|
1403
1433
|
{{/if}}
|
|
@@ -1420,7 +1450,6 @@ dependencies = [
|
|
|
1420
1450
|
"opentelemetry-exporter-otlp",
|
|
1421
1451
|
"bedrock-agentcore >= 1.0.3",
|
|
1422
1452
|
"botocore[crt] >= 1.35.0",
|
|
1423
|
-
"python-dotenv >= 1.0.1",
|
|
1424
1453
|
{{#if (eq modelProvider "Bedrock")}}
|
|
1425
1454
|
"crewai[tools,bedrock] >= 1.3.0",
|
|
1426
1455
|
{{/if}}
|
|
@@ -1510,6 +1539,7 @@ wheels/
|
|
|
1510
1539
|
*.egg
|
|
1511
1540
|
|
|
1512
1541
|
# Virtual environments
|
|
1542
|
+
.venv/
|
|
1513
1543
|
venv/
|
|
1514
1544
|
ENV/
|
|
1515
1545
|
env/
|
|
@@ -1552,12 +1582,18 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
1552
1582
|
return a + b
|
|
1553
1583
|
|
|
1554
1584
|
|
|
1555
|
-
# Set environment variables for model authentication
|
|
1556
|
-
load_model()
|
|
1557
|
-
|
|
1558
1585
|
# Get MCP Toolset
|
|
1559
1586
|
mcp_toolset = [get_streamable_http_mcp_client()]
|
|
1560
1587
|
|
|
1588
|
+
_credentials_loaded = False
|
|
1589
|
+
|
|
1590
|
+
def ensure_credentials_loaded():
|
|
1591
|
+
global _credentials_loaded
|
|
1592
|
+
if not _credentials_loaded:
|
|
1593
|
+
load_model()
|
|
1594
|
+
_credentials_loaded = True
|
|
1595
|
+
|
|
1596
|
+
|
|
1561
1597
|
# Agent Definition
|
|
1562
1598
|
agent = Agent(
|
|
1563
1599
|
model=MODEL_ID,
|
|
@@ -1570,6 +1606,7 @@ agent = Agent(
|
|
|
1570
1606
|
|
|
1571
1607
|
# Session and Runner
|
|
1572
1608
|
async def setup_session_and_runner(user_id, session_id):
|
|
1609
|
+
ensure_credentials_loaded()
|
|
1573
1610
|
session_service = InMemorySessionService()
|
|
1574
1611
|
session = await session_service.create_session(
|
|
1575
1612
|
app_name=APP_NAME, user_id=user_id, session_id=session_id
|
|
@@ -1615,6 +1652,11 @@ if __name__ == "__main__":
|
|
|
1615
1652
|
"
|
|
1616
1653
|
`;
|
|
1617
1654
|
|
|
1655
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/googleadk/base/mcp_client/__init__.py should match snapshot 1`] = `
|
|
1656
|
+
"
|
|
1657
|
+
"
|
|
1658
|
+
`;
|
|
1659
|
+
|
|
1618
1660
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/googleadk/base/mcp_client/client.py should match snapshot 1`] = `
|
|
1619
1661
|
"from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
|
|
1620
1662
|
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
|
|
@@ -1634,6 +1676,11 @@ def get_streamable_http_mcp_client() -> MCPToolset:
|
|
|
1634
1676
|
"
|
|
1635
1677
|
`;
|
|
1636
1678
|
|
|
1679
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/googleadk/base/model/__init__.py should match snapshot 1`] = `
|
|
1680
|
+
"
|
|
1681
|
+
"
|
|
1682
|
+
`;
|
|
1683
|
+
|
|
1637
1684
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/googleadk/base/model/load.py should match snapshot 1`] = `
|
|
1638
1685
|
"import os
|
|
1639
1686
|
from bedrock_agentcore.identity.auth import requires_api_key
|
|
@@ -1696,7 +1743,6 @@ dependencies = [
|
|
|
1696
1743
|
"google-adk >= 1.17.0",
|
|
1697
1744
|
"bedrock-agentcore >= 1.0.3",
|
|
1698
1745
|
"botocore[crt] >= 1.35.0",
|
|
1699
|
-
"python-dotenv >= 1.0.1",
|
|
1700
1746
|
]
|
|
1701
1747
|
|
|
1702
1748
|
[tool.hatch.build.targets.wheel]
|
|
@@ -1776,6 +1822,7 @@ wheels/
|
|
|
1776
1822
|
*.egg
|
|
1777
1823
|
|
|
1778
1824
|
# Virtual environments
|
|
1825
|
+
.venv/
|
|
1779
1826
|
venv/
|
|
1780
1827
|
ENV/
|
|
1781
1828
|
env/
|
|
@@ -1805,8 +1852,13 @@ from mcp_client.client import get_streamable_http_mcp_client
|
|
|
1805
1852
|
app = BedrockAgentCoreApp()
|
|
1806
1853
|
log = app.logger
|
|
1807
1854
|
|
|
1808
|
-
|
|
1809
|
-
|
|
1855
|
+
_llm = None
|
|
1856
|
+
|
|
1857
|
+
def get_or_create_model():
|
|
1858
|
+
global _llm
|
|
1859
|
+
if _llm is None:
|
|
1860
|
+
_llm = load_model()
|
|
1861
|
+
return _llm
|
|
1810
1862
|
|
|
1811
1863
|
|
|
1812
1864
|
# Define a simple function tool
|
|
@@ -1831,7 +1883,7 @@ async def invoke(payload, context):
|
|
|
1831
1883
|
mcp_tools = await mcp_client.get_tools()
|
|
1832
1884
|
|
|
1833
1885
|
# Define the agent using create_react_agent
|
|
1834
|
-
graph = create_react_agent(
|
|
1886
|
+
graph = create_react_agent(get_or_create_model(), tools=mcp_tools + tools)
|
|
1835
1887
|
|
|
1836
1888
|
# Process the user prompt
|
|
1837
1889
|
prompt = payload.get("prompt", "What can you help me with?")
|
|
@@ -1848,6 +1900,11 @@ if __name__ == "__main__":
|
|
|
1848
1900
|
"
|
|
1849
1901
|
`;
|
|
1850
1902
|
|
|
1903
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/langchain_langgraph/base/mcp_client/__init__.py should match snapshot 1`] = `
|
|
1904
|
+
"
|
|
1905
|
+
"
|
|
1906
|
+
`;
|
|
1907
|
+
|
|
1851
1908
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/langchain_langgraph/base/mcp_client/client.py should match snapshot 1`] = `
|
|
1852
1909
|
"from langchain_mcp_adapters.client import MultiServerMCPClient
|
|
1853
1910
|
|
|
@@ -1871,6 +1928,11 @@ def get_streamable_http_mcp_client() -> MultiServerMCPClient:
|
|
|
1871
1928
|
"
|
|
1872
1929
|
`;
|
|
1873
1930
|
|
|
1931
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/langchain_langgraph/base/model/__init__.py should match snapshot 1`] = `
|
|
1932
|
+
"
|
|
1933
|
+
"
|
|
1934
|
+
`;
|
|
1935
|
+
|
|
1874
1936
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/langchain_langgraph/base/model/load.py should match snapshot 1`] = `
|
|
1875
1937
|
"{{#if (eq modelProvider "Bedrock")}}
|
|
1876
1938
|
from langchain_aws import ChatBedrock
|
|
@@ -1954,7 +2016,7 @@ def _get_api_key() -> str:
|
|
|
1954
2016
|
def load_model() -> ChatOpenAI:
|
|
1955
2017
|
"""Get authenticated OpenAI model client."""
|
|
1956
2018
|
return ChatOpenAI(
|
|
1957
|
-
model="gpt-
|
|
2019
|
+
model="gpt-4.1",
|
|
1958
2020
|
api_key=_get_api_key()
|
|
1959
2021
|
)
|
|
1960
2022
|
{{/if}}
|
|
@@ -1991,7 +2053,7 @@ def _get_api_key() -> str:
|
|
|
1991
2053
|
def load_model() -> ChatGoogleGenerativeAI:
|
|
1992
2054
|
"""Get authenticated Gemini model client."""
|
|
1993
2055
|
return ChatGoogleGenerativeAI(
|
|
1994
|
-
model="gemini-2.
|
|
2056
|
+
model="gemini-2.5-flash",
|
|
1995
2057
|
api_key=_get_api_key()
|
|
1996
2058
|
)
|
|
1997
2059
|
{{/if}}
|
|
@@ -2019,7 +2081,6 @@ dependencies = [
|
|
|
2019
2081
|
"tiktoken == 0.11.0",
|
|
2020
2082
|
"bedrock-agentcore >= 1.0.3",
|
|
2021
2083
|
"botocore[crt] >= 1.35.0",
|
|
2022
|
-
"python-dotenv >= 1.0.1",
|
|
2023
2084
|
{{#if (eq modelProvider "Bedrock")}}
|
|
2024
2085
|
"langchain-aws >= 1.0.0",
|
|
2025
2086
|
{{/if}}
|
|
@@ -2109,6 +2170,7 @@ wheels/
|
|
|
2109
2170
|
*.egg
|
|
2110
2171
|
|
|
2111
2172
|
# Virtual environments
|
|
2173
|
+
.venv/
|
|
2112
2174
|
venv/
|
|
2113
2175
|
ENV/
|
|
2114
2176
|
env/
|
|
@@ -2136,12 +2198,17 @@ from mcp_client.client import get_streamable_http_mcp_client
|
|
|
2136
2198
|
app = BedrockAgentCoreApp()
|
|
2137
2199
|
log = app.logger
|
|
2138
2200
|
|
|
2139
|
-
# Set environment variables for model authentication
|
|
2140
|
-
load_model()
|
|
2141
|
-
|
|
2142
2201
|
# Get MCP Server
|
|
2143
2202
|
mcp_server = get_streamable_http_mcp_client()
|
|
2144
2203
|
|
|
2204
|
+
_credentials_loaded = False
|
|
2205
|
+
|
|
2206
|
+
def ensure_credentials_loaded():
|
|
2207
|
+
global _credentials_loaded
|
|
2208
|
+
if not _credentials_loaded:
|
|
2209
|
+
load_model()
|
|
2210
|
+
_credentials_loaded = True
|
|
2211
|
+
|
|
2145
2212
|
|
|
2146
2213
|
# Define a simple function tool
|
|
2147
2214
|
@function_tool
|
|
@@ -2152,13 +2219,15 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
2152
2219
|
|
|
2153
2220
|
# Define the agent execution
|
|
2154
2221
|
async def main(query):
|
|
2222
|
+
ensure_credentials_loaded()
|
|
2155
2223
|
try:
|
|
2156
2224
|
async with mcp_server as server:
|
|
2157
2225
|
active_servers = [server] if server else []
|
|
2158
|
-
# Currently defaults to GPT-4.1
|
|
2159
|
-
# https://openai.github.io/openai-agents-python/models/
|
|
2160
2226
|
agent = Agent(
|
|
2161
|
-
name="{{ name }}",
|
|
2227
|
+
name="{{ name }}",
|
|
2228
|
+
model="gpt-4.1",
|
|
2229
|
+
mcp_servers=active_servers,
|
|
2230
|
+
tools=[add_numbers]
|
|
2162
2231
|
)
|
|
2163
2232
|
result = await Runner.run(agent, query)
|
|
2164
2233
|
return result
|
|
@@ -2186,6 +2255,11 @@ if __name__ == "__main__":
|
|
|
2186
2255
|
"
|
|
2187
2256
|
`;
|
|
2188
2257
|
|
|
2258
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/openaiagents/base/mcp_client/__init__.py should match snapshot 1`] = `
|
|
2259
|
+
"
|
|
2260
|
+
"
|
|
2261
|
+
`;
|
|
2262
|
+
|
|
2189
2263
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/openaiagents/base/mcp_client/client.py should match snapshot 1`] = `
|
|
2190
2264
|
"from agents.mcp import MCPServerStreamableHttp
|
|
2191
2265
|
|
|
@@ -2204,6 +2278,11 @@ def get_streamable_http_mcp_client() -> MCPServerStreamableHttp:
|
|
|
2204
2278
|
"
|
|
2205
2279
|
`;
|
|
2206
2280
|
|
|
2281
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/openaiagents/base/model/__init__.py should match snapshot 1`] = `
|
|
2282
|
+
"
|
|
2283
|
+
"
|
|
2284
|
+
`;
|
|
2285
|
+
|
|
2207
2286
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/openaiagents/base/model/load.py should match snapshot 1`] = `
|
|
2208
2287
|
"import os
|
|
2209
2288
|
from bedrock_agentcore.identity.auth import requires_api_key
|
|
@@ -2261,7 +2340,6 @@ dependencies = [
|
|
|
2261
2340
|
"openai-agents >= 0.4.2",
|
|
2262
2341
|
"bedrock-agentcore >= 1.0.3",
|
|
2263
2342
|
"botocore[crt] >= 1.35.0",
|
|
2264
|
-
"python-dotenv >= 1.0.1",
|
|
2265
2343
|
]
|
|
2266
2344
|
|
|
2267
2345
|
[tool.hatch.build.targets.wheel]
|
|
@@ -2317,7 +2395,6 @@ Use \`agentcore invoke\` to invoke your deployed agent.
|
|
|
2317
2395
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/strands/base/gitignore.template should match snapshot 1`] = `
|
|
2318
2396
|
"# Environment variables
|
|
2319
2397
|
.env
|
|
2320
|
-
.env
|
|
2321
2398
|
|
|
2322
2399
|
# Python
|
|
2323
2400
|
__pycache__/
|
|
@@ -2342,6 +2419,7 @@ wheels/
|
|
|
2342
2419
|
*.egg
|
|
2343
2420
|
|
|
2344
2421
|
# Virtual environments
|
|
2422
|
+
.venv/
|
|
2345
2423
|
venv/
|
|
2346
2424
|
ENV/
|
|
2347
2425
|
env/
|
|
@@ -2403,14 +2481,19 @@ def agent_factory():
|
|
|
2403
2481
|
return get_or_create_agent
|
|
2404
2482
|
get_or_create_agent = agent_factory()
|
|
2405
2483
|
{{else}}
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2484
|
+
_agent = None
|
|
2485
|
+
|
|
2486
|
+
def get_or_create_agent():
|
|
2487
|
+
global _agent
|
|
2488
|
+
if _agent is None:
|
|
2489
|
+
_agent = Agent(
|
|
2490
|
+
model=load_model(),
|
|
2491
|
+
system_prompt="""
|
|
2492
|
+
You are a helpful assistant. Use tools when appropriate.
|
|
2493
|
+
""",
|
|
2494
|
+
tools=tools+[mcp_client]
|
|
2495
|
+
)
|
|
2496
|
+
return _agent
|
|
2414
2497
|
{{/if}}
|
|
2415
2498
|
|
|
2416
2499
|
|
|
@@ -2422,8 +2505,10 @@ async def invoke(payload, context):
|
|
|
2422
2505
|
session_id = getattr(context, 'session_id', 'default-session')
|
|
2423
2506
|
user_id = getattr(context, 'user_id', 'default-user')
|
|
2424
2507
|
agent = get_or_create_agent(session_id, user_id)
|
|
2425
|
-
|
|
2508
|
+
{{else}}
|
|
2509
|
+
agent = get_or_create_agent()
|
|
2426
2510
|
{{/if}}
|
|
2511
|
+
|
|
2427
2512
|
# Execute and format response
|
|
2428
2513
|
stream = agent.stream_async(payload.get("prompt"))
|
|
2429
2514
|
|
|
@@ -2438,6 +2523,11 @@ if __name__ == "__main__":
|
|
|
2438
2523
|
"
|
|
2439
2524
|
`;
|
|
2440
2525
|
|
|
2526
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/strands/base/mcp_client/__init__.py should match snapshot 1`] = `
|
|
2527
|
+
"
|
|
2528
|
+
"
|
|
2529
|
+
`;
|
|
2530
|
+
|
|
2441
2531
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/strands/base/mcp_client/client.py should match snapshot 1`] = `
|
|
2442
2532
|
"from mcp.client.streamable_http import streamablehttp_client
|
|
2443
2533
|
from strands.tools.mcp.mcp_client import MCPClient
|
|
@@ -2453,6 +2543,11 @@ def get_streamable_http_mcp_client() -> MCPClient:
|
|
|
2453
2543
|
return MCPClient(lambda: streamablehttp_client(EXAMPLE_MCP_ENDPOINT))"
|
|
2454
2544
|
`;
|
|
2455
2545
|
|
|
2546
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/strands/base/model/__init__.py should match snapshot 1`] = `
|
|
2547
|
+
"
|
|
2548
|
+
"
|
|
2549
|
+
`;
|
|
2550
|
+
|
|
2456
2551
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/strands/base/model/load.py should match snapshot 1`] = `
|
|
2457
2552
|
"{{#if (eq modelProvider "Bedrock")}}
|
|
2458
2553
|
from strands.models.bedrock import BedrockModel
|
|
@@ -2536,7 +2631,7 @@ def load_model() -> OpenAIModel:
|
|
|
2536
2631
|
"""Get authenticated OpenAI model client."""
|
|
2537
2632
|
return OpenAIModel(
|
|
2538
2633
|
client_args={"api_key": _get_api_key()},
|
|
2539
|
-
model_id="gpt-
|
|
2634
|
+
model_id="gpt-4.1",
|
|
2540
2635
|
)
|
|
2541
2636
|
{{/if}}
|
|
2542
2637
|
{{#if (eq modelProvider "Gemini")}}
|
|
@@ -2574,7 +2669,7 @@ def load_model() -> GeminiModel:
|
|
|
2574
2669
|
"""Get authenticated Gemini model client."""
|
|
2575
2670
|
return GeminiModel(
|
|
2576
2671
|
client_args={"api_key": _get_api_key()},
|
|
2577
|
-
model_id="gemini-2.
|
|
2672
|
+
model_id="gemini-2.5-flash",
|
|
2578
2673
|
)
|
|
2579
2674
|
{{/if}}
|
|
2580
2675
|
"
|
|
@@ -2592,14 +2687,13 @@ description = "AgentCore Runtime Application using Strands SDK"
|
|
|
2592
2687
|
readme = "README.md"
|
|
2593
2688
|
requires-python = ">=3.10"
|
|
2594
2689
|
dependencies = [
|
|
2595
|
-
"anthropic >= 0.30.0",
|
|
2596
|
-
"aws-opentelemetry-distro",
|
|
2690
|
+
{{#if (eq modelProvider "Anthropic")}}"anthropic >= 0.30.0",
|
|
2691
|
+
{{/if}}"aws-opentelemetry-distro",
|
|
2597
2692
|
"bedrock-agentcore >= 1.0.3",
|
|
2598
2693
|
"botocore[crt] >= 1.35.0",
|
|
2599
|
-
"google-genai >= 1.0.0",
|
|
2600
|
-
"openai >= 1.0.0",
|
|
2601
|
-
"
|
|
2602
|
-
"strands-agents >= 1.13.0",
|
|
2694
|
+
{{#if (eq modelProvider "Gemini")}}"google-genai >= 1.0.0",
|
|
2695
|
+
{{/if}}{{#if (eq modelProvider "OpenAI")}}"openai >= 1.0.0",
|
|
2696
|
+
{{/if}}"strands-agents >= 1.13.0",
|
|
2603
2697
|
]
|
|
2604
2698
|
|
|
2605
2699
|
[tool.hatch.build.targets.wheel]
|
|
@@ -2607,6 +2701,8 @@ packages = ["."]
|
|
|
2607
2701
|
"
|
|
2608
2702
|
`;
|
|
2609
2703
|
|
|
2704
|
+
exports[`Assets Directory Snapshots > Python framework assets > python/python/strands/capabilities/memory/__init__.py should match snapshot 1`] = `""`;
|
|
2705
|
+
|
|
2610
2706
|
exports[`Assets Directory Snapshots > Python framework assets > python/python/strands/capabilities/memory/session.py should match snapshot 1`] = `
|
|
2611
2707
|
"import os
|
|
2612
2708
|
from typing import Optional
|
|
@@ -2656,17 +2752,39 @@ exports[`Assets Directory Snapshots > Root-level assets > AGENTS.md should match
|
|
|
2656
2752
|
This directory stores:
|
|
2657
2753
|
|
|
2658
2754
|
- Template assets for agents written in different Languages, SDKs and having different configurations
|
|
2755
|
+
- Container templates (\`container/python/\`) with \`Dockerfile\` and \`.dockerignore\` for Container build agents
|
|
2756
|
+
|
|
2757
|
+
### Directory Layout
|
|
2758
|
+
|
|
2759
|
+
\`\`\`
|
|
2760
|
+
assets/
|
|
2761
|
+
├── python/ # Framework templates (one per SDK)
|
|
2762
|
+
│ ├── strands/
|
|
2763
|
+
│ ├── langchain_langgraph/
|
|
2764
|
+
│ ├── crewai/
|
|
2765
|
+
│ ├── googleadk/
|
|
2766
|
+
│ ├── openaiagents/
|
|
2767
|
+
│ └── autogen/
|
|
2768
|
+
├── container/ # Container build templates
|
|
2769
|
+
│ └── python/
|
|
2770
|
+
│ ├── Dockerfile
|
|
2771
|
+
│ └── dockerignore.template
|
|
2772
|
+
└── agents/ # AGENTS.md vended to user projects
|
|
2773
|
+
\`\`\`
|
|
2774
|
+
|
|
2775
|
+
The rendering logic is rooted in the \`AgentEnvSpec\` and must ALWAYS respect the configuration in the Spec.
|
|
2659
2776
|
|
|
2660
|
-
|
|
2777
|
+
For Container builds, \`BaseRenderer.render()\` automatically copies the \`container/<language>/\` templates (Dockerfile,
|
|
2778
|
+
.dockerignore) into the agent directory when \`buildType === 'Container'\`.
|
|
2661
2779
|
|
|
2662
2780
|
## Guidance for template changes
|
|
2663
2781
|
|
|
2664
2782
|
- Always make sure the templates are as close to working code as possible
|
|
2665
2783
|
- AVOID as much as possible using any conditionals within the templates
|
|
2666
2784
|
|
|
2667
|
-
|
|
2785
|
+
## How to use the assets in this directory
|
|
2668
2786
|
|
|
2669
|
-
- These assets are rendered by the CLI's template renderer in \`
|
|
2787
|
+
- These assets are rendered by the CLI's template renderer in \`src/cli/templates/\`.
|
|
2670
2788
|
"
|
|
2671
2789
|
`;
|
|
2672
2790
|
|
|
@@ -2816,21 +2934,32 @@ file maps to a JSON config file and includes validation constraints as comments.
|
|
|
2816
2934
|
|
|
2817
2935
|
### Common Enum Values
|
|
2818
2936
|
|
|
2819
|
-
- **BuildType**: \`'CodeZip'\`
|
|
2937
|
+
- **BuildType**: \`'CodeZip'\` | \`'Container'\`
|
|
2820
2938
|
- **NetworkMode**: \`'PUBLIC'\`
|
|
2821
2939
|
- **RuntimeVersion**: \`'PYTHON_3_10'\` | \`'PYTHON_3_11'\` | \`'PYTHON_3_12'\` | \`'PYTHON_3_13'\`
|
|
2822
2940
|
- **MemoryStrategyType**: \`'SEMANTIC'\` | \`'SUMMARIZATION'\` | \`'USER_PREFERENCE'\`
|
|
2823
2941
|
|
|
2942
|
+
### Build Types
|
|
2943
|
+
|
|
2944
|
+
- **CodeZip**: Python source is packaged as a zip artifact and deployed directly to AgentCore Runtime.
|
|
2945
|
+
- **Container**: Agent code is built as a Docker container image. Requires a \`Dockerfile\` in the agent's \`codeLocation\`
|
|
2946
|
+
directory. At deploy time, the source is uploaded to S3, built in CodeBuild (ARM64), pushed to a per-agent ECR
|
|
2947
|
+
repository, and the container URI is provided to the AgentCore Runtime. For local development (\`agentcore dev\`), the
|
|
2948
|
+
container is built and run locally with volume-mounted hot-reload.
|
|
2949
|
+
|
|
2824
2950
|
### Supported Frameworks (for template agents)
|
|
2825
2951
|
|
|
2826
2952
|
- **Strands** - Works with Bedrock, Anthropic, OpenAI, Gemini
|
|
2827
2953
|
- **LangChain_LangGraph** - Works with Bedrock, Anthropic, OpenAI, Gemini
|
|
2954
|
+
- **CrewAI** - Works with Bedrock, Anthropic, OpenAI, Gemini
|
|
2828
2955
|
- **GoogleADK** - Gemini only
|
|
2829
2956
|
- **OpenAIAgents** - OpenAI only
|
|
2957
|
+
- **AutoGen** - Works with Bedrock, Anthropic, OpenAI, Gemini
|
|
2830
2958
|
|
|
2831
2959
|
### Specific Context
|
|
2832
2960
|
|
|
2833
|
-
Directory pathing to local projects is required for runtimes.
|
|
2961
|
+
Directory pathing to local projects is required for runtimes. Both CodeZip (Python zip) and Container (Docker image)
|
|
2962
|
+
deployment options are available.
|
|
2834
2963
|
|
|
2835
2964
|
## Deployment
|
|
2836
2965
|
|
|
@@ -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,24 @@
|
|
|
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
|
+
COPY pyproject.toml uv.lock* ./
|
|
12
|
+
RUN uv pip install -r pyproject.toml
|
|
13
|
+
|
|
14
|
+
RUN useradd -m -u 1000 bedrock_agentcore
|
|
15
|
+
USER bedrock_agentcore
|
|
16
|
+
|
|
17
|
+
COPY . .
|
|
18
|
+
|
|
19
|
+
# 8080: AgentCore runtime endpoint
|
|
20
|
+
# 8000: Local dev server (uvicorn)
|
|
21
|
+
# 9000: OpenTelemetry collector
|
|
22
|
+
EXPOSE 8080 8000 9000
|
|
23
|
+
|
|
24
|
+
CMD ["opentelemetry-instrument", "python", "-m", "{{entrypoint}}"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|