An agent loop is a cycle of reasoning, tool execution, and context management. Unlike a single question-and-response interaction, it lets an agent take multiple steps toward an outcome, using tools to retrieve information or interact with external systems. section 8.4.3
A framework can manage the loop while the agent’s system prompt sets its role and decision policy. Tools extend the agent’s capabilities through functions or external resources. Document each tool’s purpose, inputs, and return data so the agent can use it effectively. section 8.4.3
Home climate control
A home digital twin agent considers indoor conditions, solar production, and weather forecasts to decide whether to run HVAC using excess solar energy. Its policy calculates excess power, checks temperature thresholds, and avoids cycling the AC if its state changed less than 15 minutes ago. section 8.4.3
Listing 8.11 Agent with Strands SDK for home climate control
import datetime
from strands import Agent
current_time_str = datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
system_prompt = f""" #1
### ROLE
Climate Control Agent. Current Time: {current_time_str}.
### CONSTANTS
- **Target Temp:** 21°C–24°C
- **AC Load:** 1500W
- **Baseload:** 1000W (08:00–16:00); 200W (otherwise).
### CONTROL POLICY
1. **Fetch Data:** Get current solar ($P_{{solar}}$), forecast,
and indoor temp ($T_{{room}}$ (last 24 hours).
2. **Calculate Excess:** $P_{{excess}} = P_{{solar}} - \\text{{Baseload}}$.
3. **Evaluate State:**
- **COOLING NEEDED** if $T_{{room}} > 24°C$.
- **OPPORTUNISTIC COOLING** if $P_{{excess}} > 1500W$ AND $T_{{room}} >
21°C$ (Priority: Solar).
- **IDLE** otherwise.
4. **Safety:** Apply hysteresis (don't cycle AC if state changed
<15 mins ago).
5. **Priorities:** Always prioritize minimizing grid consumption
over comfort.
### OUTPUT INSTRUCTION
Output a concise reasoning step (e.g., "Excess solar 1600W > AC Load;
engaging cooling."), then call `set_aircon_state` if a change is needed.
"""
agent = Agent( #2
name="ClimateAgent",
system_prompt=system_prompt,
tools=[
get_realtime_solar_data,
get_weather_forecast,
get_space_climate_history,
set_aircon_state,
],
)
The agent listing shows how a system prompt specifies data gathering, excess-power calculations, decision thresholds, and a safety rule. section 8.4.3
