Read model-id from SSM and pass to BedrockModel in main.py

This commit is contained in:
daniel
2026-05-15 06:58:54 -05:00
parent 62862f00f0
commit f31d732cb9

View File

@@ -4,7 +4,9 @@ agent-claw Runtime 1 — main assistant agent.
Entrypoint for AgentCore CodeZip deployment. Entrypoint for AgentCore CodeZip deployment.
""" """
import os import os
import boto3
from strands import Agent, tool from strands import Agent, tool
from strands.models import BedrockModel
from bedrock_agentcore.runtime import BedrockAgentCoreApp from bedrock_agentcore.runtime import BedrockAgentCoreApp
from channels.telegram import TelegramAdapter from channels.telegram import TelegramAdapter
@@ -15,6 +17,10 @@ from tools import messaging
app = BedrockAgentCoreApp() app = BedrockAgentCoreApp()
# Read model ID from SSM once at module load (cached for warm invocations)
_ssm = boto3.client("ssm", region_name=os.environ.get("AWS_REGION_NAME", "us-east-1"))
_model_id = _ssm.get_parameter(Name="/agent-claw/model-id")["Parameter"]["Value"]
# ── Tool definitions ────────────────────────────────────────────────────── # ── Tool definitions ──────────────────────────────────────────────────────
@@ -77,6 +83,7 @@ def main(payload: dict, context) -> dict:
# Create and run Strands agent # Create and run Strands agent
agent = Agent( agent = Agent(
model=BedrockModel(model_id=_model_id),
system_prompt=system_prompt, system_prompt=system_prompt,
tools=[send_message, web_search, web_fetch, read_workspace_file, write_workspace_file], tools=[send_message, web_search, web_fetch, read_workspace_file, write_workspace_file],
) )