diff --git a/src/assets/templates/a2a-python-strands/main.py b/src/assets/templates/a2a-python-strands/main.py index 649f96411..c3182b7a8 100644 --- a/src/assets/templates/a2a-python-strands/main.py +++ b/src/assets/templates/a2a-python-strands/main.py @@ -82,19 +82,16 @@ def list_files(path: str) -> str: {{/each}}{{/if}} """ -# serve_a2a serves one agent instance, so it is bound to a fixed session and -# actor; get_memory_session_manager returns None (in-process history only) until -# the deployed MEMORY_ID env var is set by the CDK. -agent = Agent( - name="{{ name }}", - model=load_model(), - session_manager=get_memory_session_manager("default-session", "default-user"), - system_prompt=SYSTEM_PROMPT, - tools=tools, -) +def create_agent(context_id: str) -> Agent: + return Agent( + name="{{ name }}", + model=load_model(), + session_manager=get_memory_session_manager(context_id, "default-user"), + system_prompt=SYSTEM_PROMPT, + tools=tools, + ) # serve_a2a binds 0.0.0.0:9000 in the container (the AgentCore A2A service -# contract) and publishes the agent card at /.well-known/agent-card.json. The -# card is derived by introspecting the executor's agent. +# contract) and publishes the agent card at /.well-known/agent-card.json. if __name__ == "__main__": - serve_a2a(StrandsA2AExecutor(agent)) + serve_a2a(StrandsA2AExecutor(agent_factory=create_agent)) diff --git a/src/assets/templates/a2a-python-strands/pyproject.toml b/src/assets/templates/a2a-python-strands/pyproject.toml index fe05495bd..e12be9fe5 100644 --- a/src/assets/templates/a2a-python-strands/pyproject.toml +++ b/src/assets/templates/a2a-python-strands/pyproject.toml @@ -9,11 +9,11 @@ description = "AgentCore A2A Agent using Strands SDK" readme = "README.md" requires-python = ">=3.10" dependencies = [ - "a2a-sdk[all] ~= 0.3.0", + "a2a-sdk[all] ~= 0.3.26", "aws-opentelemetry-distro ~= 0.18.0", - "bedrock-agentcore[a2a,strands-agents] >= 1.18.1, < 2.0.0", - "botocore[crt] ~= 1.43.0", - "strands-agents >= 1.15.0, < 2.0.0", + "bedrock-agentcore[a2a,strands-agents] ~= 1.24.0", + "botocore[crt] ~= 1.43.107", + "strands-agents ~= 1.57.2", ] [tool.hatch.build.targets.wheel] diff --git a/src/core/project/templates/pythonSecurity.test.ts b/src/core/project/templates/pythonSecurity.test.ts index c5ff66225..29e079412 100644 --- a/src/core/project/templates/pythonSecurity.test.ts +++ b/src/core/project/templates/pythonSecurity.test.ts @@ -8,7 +8,16 @@ const renderer = new HandlebarsTemplateRenderer(); test.each([ ["agent-python-minimal", ["bedrock-agentcore >= 1.18.1, < 2.0.0"]], ["agent-python-strands", ["bedrock-agentcore[strands-agents] >= 1.18.1, < 2.0.0"]], - ["a2a-python-strands", ["bedrock-agentcore[a2a,strands-agents] >= 1.18.1, < 2.0.0"]], + [ + "a2a-python-strands", + [ + "a2a-sdk[all] ~= 0.3.26", + "aws-opentelemetry-distro ~= 0.18.0", + "bedrock-agentcore[a2a,strands-agents] ~= 1.24.0", + "botocore[crt] ~= 1.43.107", + "strands-agents ~= 1.57.2", + ], + ], ["agui-python-strands", ["bedrock-agentcore[strands-agents] >= 1.18.1, < 2.0.0"]], [ "export-harness-python",