Skip to content

Self-Improving Agent Workshop

View the complete sample on GitHub

Related documentation: Strands Agents documentation

Go from a 20-line Strands agent to a fully autonomous, self-improving agent deployed on Amazon Bedrock AgentCore Runtime. Across six progressive steps, the agent learns to create its own tools, rewrite its own system prompt, remember across sessions, work autonomously in the background, and finally deploy itself to production.

From 20 lines of Python to a deployed autonomous agent

Adapted from the AWS New York Summit 2026 builders session AIM308 — “Using Strands to build fully autonomous, self-improving AI agents.” Origin: re:Invent 2025 AIM426.

Tutorial Details

InformationDetails
Strands FeaturesAgent, @tool, load_tools_from_directory, dynamic system prompt, ambient background loop
Agent PatternSingle self-improving agent (extends itself step by step)
Native Toolsshell, file_write
Custom Toolssystem_prompt (self-modification), calculator (example of a self-written tool)
MemoryAmazon Bedrock AgentCore Memory (semantic, per-actor)
ComplexityBeginner → Advanced (progressive)
Model ProviderAmazon Bedrock — Claude Opus 4 (global.anthropic.claude-opus-4-8)
SDK UsedStrands Agents SDK, bedrock-agentcore

The core pattern: Agent → Model → Tools

Every step reuses this one loop. Once you grok Agent · Model · Tools, everything else is a variation.

Strands agent loop — the model decides whether to call a tool; the observation feeds back until a final answer

The 6-step journey

#StepCapability you addNew codeRuntimeVisual
0step-00-helloBaseline agent (one model, one tool)20 linesLocal▶
1step-01-toolsSelf-extending — hot-reload ./tools/*.py+10Local▶
2step-02-system-promptSelf-modifying — rewrites its own prompt+40Local▶
3step-03-memorySelf-learning — AgentCore Memory+30Local▶
4step-04-ambientAutonomous — ambient + scheduler+50Local▶
5step-05-deployDeployed — AgentCore Runtime ARN+15Cloud ☁▶

What you’ll learn

  1. 🛠️ Agents can create their own tools while running — no restart, no redeploy (load_tools_from_directory=True).
  2. ✏️ Agents can rewrite their own system prompt — permanently changing their own behavior, persisted to disk.
  3. 🧠 Agents can learn from every interaction — using Amazon Bedrock AgentCore Memory.
  4. 🌙 Agents can run autonomously in the background — exploring a topic while you’re idle, then injecting findings.
  5. 🚀 Agents can deploy themselves to production — on Amazon Bedrock AgentCore Runtime.

Prerequisites

Run any step locally

Each step is self-contained and builds on the previous one:

Terminal window
cd code/step-00-hello
pip install -r requirements.txt
python agent.py "hello, what can you do?"

Then progress through the steps:

Terminal window
cd ../step-01-tools && pip install -r requirements.txt && python agent.py
cd ../step-02-system-prompt && pip install -r requirements.txt && python agent.py
# ...etc

Steps 3–5: create the memory store first

Terminal window
cd code/step-03-memory
pip install -r requirements.txt
python create_memory.py # prints a BEDROCK_AGENTCORE_MEMORY_ID
export BEDROCK_AGENTCORE_MEMORY_ID=<the-id>
python agent.py

Step 5: deploy to AgentCore Runtime

Terminal window
cd code/step-05-deploy
export BEDROCK_AGENTCORE_MEMORY_ID=<your-memory-id>
./deploy.sh # creates + deploys via @aws/agentcore CLI

Then invoke the deployed agent from anywhere:

Terminal window
export AGENT_ARN=arn:aws:bedrock-agentcore:us-east-1:...:runtime/aim308_research_agent-XYZ
python invoke.py "what do you remember about me?"

Notebook walkthroughs

Prefer interactive? Each step has a click-through Jupyter notebook in notebooks/:

NotebookStep
00_hello_agent.ipynbHello agent
01_self_extending.ipynbSelf-extending tools
02_self_modifying.ipynbSelf-modifying prompt
03_memory.ipynbAgentCore Memory
04_autonomous.ipynbAmbient autonomy
05_deploy.ipynbDeploy to AgentCore

See it run

Each step was recorded live against the real Strands runtime + Claude. The animated SVG recordings and replayable asciinema .cast files live in casts/ (replay locally with asciinema play casts/01-self-extending.cast).

CastStepWhat it shows
00-hello020-line agent; one autonomous shell tool call
01-self-extending1Agent writes tools/password_generator.py mid-run, then uses it
02-self-modifying2Agent rewrites its own prompt → haiku mode; .prompt persists
03-memory3AgentCore Memory recall across sessions
04-ambient4Background ambient thread + finding injection
05-deploy5agentcore create → add agent → deploy → invoke

Project structure

18-self-improving-agents/
├── README.md
├── code/ # Commit-by-commit agent source (what you RUN)
│ ├── step-00-hello/ # 20-line baseline
│ ├── step-01-tools/ # + self-extending tools (hot-reload)
│ ├── step-02-system-prompt/ # + self-modification (.prompt persistence)
│ ├── step-03-memory/ # + AgentCore Memory (semantic recall)
│ ├── step-04-ambient/ # + autonomous background work + scheduler
│ └── step-05-deploy/ # + AgentCore Runtime deployment
├── notebooks/ # Interactive click-through mirror of each step
├── images/ # Animated SVG diagrams (hero + per-step)
└── casts/ # asciinema recordings (.cast + animated .svg)

Additional Resources

Disclaimer

This sample is provided for educational and demonstration purposes only. It is not intended for production use without further development, testing, and hardening. For production deployments, implement appropriate content filtering and safety measures, follow security best practices, conduct thorough testing, and review configurations for your specific requirements.