Strands AgentCore Tools: Self-Deploying Agents ☁️
Agentic tools that enable AI agents to autonomously deploy, manage, and monitor themselves on AWS Bedrock AgentCore.
9 Python functions that wrap AWS Bedrock AgentCore boto3 APIs for deployment, invocation, monitoring, and lifecycle management.
Installation
What This Is
Tools for: - ✅ Deploy agents to AgentCore from code - ✅ Invoke deployed agents programmatically - ✅ Monitor CloudWatch logs and metrics - ✅ Manage memory, sessions, and OAuth - ✅ Integrate with Strands agents for autonomous deployment
Quick Start
1. Create Your Agent
# agent.py
import threading
from bedrock_agentcore import BedrockAgentCoreApp
from strands import Agent
app = BedrockAgentCoreApp()
@app.entrypoint
async def invoke(payload, context):
"""Async entrypoint with streaming support"""
agent = Agent()
prompt = payload.get("prompt", "")
mode = payload.get("mode", "streaming")
if mode == "fire_and_forget":
task_id = app.add_async_task("agent_processing", payload)
thread = threading.Thread(
target=run_agent_background,
args=(agent, prompt, task_id),
daemon=True
)
thread.start()
yield {"status": "started", "content": [{"text": "Running in background"}]}
elif mode == "sync":
result = agent(prompt)
yield {"status": "success", "content": [{"text": str(result)}]}
else: # streaming
for event in agent.stream_async(prompt):
yield event
def run_agent_background(agent, prompt, task_id):
"""Background worker"""
try:
for event in agent.stream_async(prompt):
print(event)
app.complete_async_task(task_id)
except Exception as e:
app.logger.error(f"Background task failed: {e}")
app.complete_async_task(task_id)
app.run()
2. Deploy It
from strands_agentcore_tools import configure, launch, invoke
# Configure
configure(action="configure", entrypoint="agent.py", agent_name="my-agent")
# Launch
launch(action="launch", agent_name="my-agent")
# Invoke
invoke(
agent_arn="arn:aws:bedrock-agentcore:...",
payload='{"prompt": "Hello!", "mode": "streaming"}'
)
Available Tools
| Tool | Purpose |
|---|---|
configure |
Configure agent for deployment |
launch |
Deploy to AgentCore |
invoke |
Call deployed agent |
agents |
List/manage agents |
status |
Check agent status |
logs |
View CloudWatch logs |
memory |
Manage agent memory |
identity |
Configure OAuth |
session |
Manage sessions |
Architecture
flowchart TB
subgraph Local["💻 Local Development"]
Code[agent.py]
Tools[AgentCore Tools]
end
subgraph AWS["☁️ AWS"]
CB[CodeBuild]
ECR[ECR]
AC[AgentCore Runtime]
CW[CloudWatch]
end
Code --> Tools
Tools -->|configure| CB
CB -->|build| ECR
ECR -->|deploy| AC
AC -->|logs| CW
style AC fill:#f9f,stroke:#333,stroke-width:4px
Agent with Memory
# agent.py - Agent with STM + LTM
from bedrock_agentcore import BedrockAgentCoreApp
from strands import Agent
from bedrock_agentcore.memory.integrations.strands.config import (
AgentCoreMemoryConfig, RetrievalConfig
)
from bedrock_agentcore.memory.integrations.strands.session_manager import (
AgentCoreMemorySessionManager
)
app = BedrockAgentCoreApp()
MEMORY_ID = os.getenv("BEDROCK_AGENTCORE_MEMORY_ID")
@app.entrypoint
async def invoke(payload, context):
session_id = context.session_id
actor_id = context.headers.get("X-Amzn-Bedrock-AgentCore-Runtime-Custom-Actor-Id", "user")
# Configure memory with semantic search
memory_config = AgentCoreMemoryConfig(
memory_id=MEMORY_ID,
session_id=session_id,
actor_id=actor_id,
retrieval_config={
f"/users/{actor_id}/facts": RetrievalConfig(top_k=3, relevance_score=0.5)
}
)
agent = Agent(
session_manager=AgentCoreMemorySessionManager(memory_config)
)
async for event in agent.stream_async(payload.get("prompt", "")):
yield event
CLI Usage
# Configure
strands-agentcore configure --entrypoint agent.py --agent-name my-agent
# Launch
strands-agentcore launch --agent-name my-agent
# Check status
strands-agentcore status --agent-name my-agent
# View logs
strands-agentcore logs --agent-name my-agent --tail
# Invoke
strands-agentcore invoke --agent-arn arn:... --prompt "Hello!"
Zero DevOps deployment—agents deploy themselves. ☁️