bedrock agentcore runtime getting started

 Amazon Bedrock AgentCore Runtime is the serverless infrastructure layer that hosts custom agent code, pay for what you use while AgentCore Harness is a fully managed orchestration layer running on top of that runtime that builds the agent loop for you through simple configuration. Harness created runs and you will be billed for how long it is running.

To get started with AgentCore runtime, we need to install it

npm install -g @aws/agentcore

agentcore --version

Next, we will run the following in the root directory of the project (it must be in the root directory) :- 

agentcore create --project-name MyTsAgent --no-agent

cd MyTsAgent

agentcore add agent --name TsAgent --type create --build CodeZip --language Python --framework Strands --model-provider Bedrock --memory none

And to deploy it 

agentcore deploy


And we can see it in the console too




To test it out 

agentcore invoke "Tell me a joke"

Or you can invoke it wth code :-



import boto3
import json

client = boto3.client('bedrock-agentcore', region_name='us-east-1')
payload = json.dumps({"prompt": "Explain machine learning in simple terms"})

response = client.invoke_agent_runtime(
    agentRuntimeArn='arn:aws:bedrock-agentcore:us-east-1:xxxxxxxxxxxx:runtime/MyTsAgent_TsAgent-icgqf0HXPh',
    runtimeSessionId='<Enter your SessionId>', # Must be 33+ char. Every new SessionId will create a new MicroVM
    payload=payload,
    qualifier="<Replace with your Endpoint>" # This is Optional. When the field is not provided, Runtime will use DEFAULT endpoint
)
response_body = response['response'].read()
response_data = json.loads(response_body)
print("Agent Response:", response_data)


So which model are you using for this? The answer lies in your load.py. 

from strands.models.bedrock import BedrockModel


def load_model() -> BedrockModel:
    """Get Bedrock model client using IAM credentials."""
    return BedrockModel(model_id="global.anthropic.claude-sonnet-4-5-20250929-v1:0")


Once you deployed it 

And the clean it up 

agentcore remove all

And then we have to do another deployment to remove it.



To get the status :-

agentcore status



Comments

Popular posts from this blog

Windows SSH: Permissions for 'private-key' are too open

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20