Once Upon Agentic AI Using AWS Strands Series.
⚔️ Chapter 2: Built-in Tools
Quest Objective
Tools are the primary mechanism for extending agent capabilities, enabling them to perform actions beyond text generation. Tools allow agents to interact with external systems, access data, and manipulate their environment. In this chapter, you’ll master your first built-in tool by adding the current_time tool to your agent.
Make sure you are at the root of Chapter 2 in your terminal:
cd sample-once-upon-agentic-ai/2_built_in_toolsOpen and modify the agent_with_built_in_tools.py file.
Your Arsenal: Built-in Tools
Strands comes equipped with several built-in tools ready for immediate use. Here are some common examples:
current_time: Returns the current date and timecalculator: Performs mathematical calculationsfile_read/file_write: Reads from and writes to filespython_repl: Executes Python codehttp_request: Fetches content from web URLsbrowser: Automates web browsing interactions
View the complete list in the documentation →
Step 1: Equip Your Agent with current_time
# TODO: Import the current_time built-in toolImport the current_time tool from the strands_tools library. See the documentation for an example of how to import a tool.
from strands import Agent
# TODO: Import the current_time built-in tool
from strands_tools import current_time
agent = Agent(
tools=[
from strands_tools import current_time: This reaches into the Strands toolkit and grabs a pre-built tool that knows how to read the system clock.
Step 2: Activate the Tool
# TODO: Add the current_time tool to your agentPass the current_time tool to your agent's tools parameter. This enables your agent to invoke the tool when answering time-related questions. The documentation shows how to configure tools.
# TODO: Add the current_time tool to your agent
current_time
]
)
result = agent("What time is it?")
print(result)
tools=[current_time]: By passing this tool into theAgentwhen it is initialized, you give the agent the ability to use it. The agent automatically reads the tool's description and decides on its own when to call it based on your question.
Step 3: Test Your Quest
Once you’ve completed both TODOs, run your script:
python agent_with_built_in_tools.pyYour agent will:
- Receive the question “What time is it?”
- Determine that it needs to use the
current_timetool - Call the tool to retrieve the current date and time
- Return the result
This demonstrates that your agent can autonomously select and use tools to answer questions.
🌟 Bonus Quest: The Multi-Tool Challenge (optional)
Ready to go deeper? Try the bonus example in 2_built_in_tools/bonus_quest.py:
Build a Fibonacci Agent: Equip an agent with python_repl and file_write tools that can:
- Generate Python code for the Fibonacci sequence
- Execute the code to compute results
- Write the output to a file
⚠️ Windows users: The python_repl tool relies on Unix-only modules (fcntl, pty, termios) and does not run on native Windows — importing it raises ModuleNotFoundError. To try this optional bonus quest on Windows, run it inside WSL (Windows Subsystem for Linux). (file_write works everywhere; only python_repl is affected.)
⚠️ Important: Enable Debug Logs for Interactive Tools
Get Elijah Chimera’s stories in your inbox
Join Medium for free to get updates from this writer.
Before attempting the bonus quest, enable DEBUG logging to see tool consent prompts. The python_repl and file_write tools require your permission before executing. Check the logging documentation for setup instructions.
import logging
from strands import Agent
#TODO: import python_repl, file_write
from strands_tools import python_repl, file_write
#TODO: Enable Strands debug log level
# Configure the root strands logger to DEBUG and set up the stream handler
logging.getLogger("strands").setLevel(logging.DEBUG)
logging.basicConfig(
format="%(levelname)s | %(name)s | %(message)s",
handlers=[logging.StreamHandler()]
)
# Your magical creation here
arcane_scribe = Agent(
#tools= #TODO: add the tools
tools=[python_repl, file_write],
system_prompt="""You are Kiro the Grey Hat, a wizard who specializes in the ancient art of code magic.
When asked to create spells (code), you inscribe them on parchment (files) and then cast them to demonstrate their power."""
)
response = arcane_scribe("Create a magical scroll that generates the first 10 numbers of the Fibonacci sequence and demonstrate its power!")
print(response)
import loggingBrings in Python's standard tool for recording and displaying background system messages.
from strands import AgentImports the core
Agentblueprint from the Strands SDK so you can create a new AI assistant.
from strands_tools import python_repl, file_writeReaches into the Strands toolkit and pulls out two specific abilities for your agent.
python_replallows the agent to execute Python code, andfile_writeallows it to create and save files on your computer.
logging.getLogger("strands").setLevel(logging.DEBUG)Targets the specific background channel used by the Strands SDK and sets it toDEBUGmode. This forces the agent to show you its detailed, under-the-hood operations. This is crucial for this quest because the tools you are using require the agent to pause and ask for your permission (consent) in the terminal before it modifies your computer.
logging.basicConfig( format="...", handlers=[...] )Sets the rules for how those background messages look on your screen. It formats the text to show the severity level, the system name, and the message, and streams it directly to your terminal.
arcane_scribe = Agent(...)Creates your brand-new AI assistant and assigns it to the variable named
arcane_scribe.
tools=[python_repl, file_write],Equips your newly created agent with the two tools you imported earlier. The agent will automatically read the descriptions of these tools and figure out when to use them.
system_prompt="""You are Kiro..."""Gives the AI its personality and rules. By telling it to act like a wizard who inscribes spells on parchment and casts them, you are tricking the AI into combining its two tools: it knows it must first use
file_writeto write the code, and then usepython_replto run it.
response = arcane_scribe("Create a magical scroll...")This is your actual prompt to the AI. You are asking it to generate the Fibonacci sequence. The agent takes this request, uses its tools to write and run the code, and saves the final outcome into the
responsevariable.
print(response)Takes the final answer the agent generated and displays it on your screen.
What you’ll see:
DEBUG | strands.tools | Tool 'file_write' requires consent. Do you want to allow this action? (y/n):Type y and press Enter to allow the tool to execute.
Tool Consent & Safety
Consent Prompts: By default, certain tools (file_write, python_repl) require your permission before executing. This ensures you maintain control over system-altering actions.
Bypass for Testing (use with caution):
export BYPASS_TOOL_CONSENT=true1. Waking Up & Gearing Up
DEBUG | strands.models.bedrock | ... initializing
DEBUG | strands.tools.loader | tool_name=<python_repl> ...
DEBUG | strands.tools.loader | tool_name=<file_write> ...Here, the system is waking up the AI model (Claude Sonnet) and successfully loading the two tools you gave it:
python_replandfile_write.2. The First Action: Inscribing the Scroll (Writing the File)
DEBUG | strands.models.bedrock | request=<{'modelId'... 'Create a magical scroll...
Tool #1: file_writeThe system packages up your prompt (“Create a magical scroll…”) along with Kiro’s personality and sends it to the AI. The AI reads this and realizes its first step must be to write the code. It builds a Python script called
fibonacci_scroll.py and triggers the file_write tool.
Do you want to proceed with the file write? [y/*] yBecause you enabled debug logging and these tools require consent, the system pauses the agent and asks for your permission to save the file to your hard drive. You typed
yto allow it.3. The Second Action: Casting the Spell (Running the Code)
{'text': 'The scroll has been inscribed! Now let me cast it! 🪄'}
Tool #2: python_replThe system tells the AI, “Okay, the file was saved successfully.” The AI responds in character and immediately reaches for its second tool (
python_repl) to execute the code it just wrote.
Do you want to proceed with Python code execution? [y/*] y
=============================================
🌀 CASTING THE FIBONACCI SPELL... 🌀Once again, the system stops and asks for your permission to run the code. You type
y, and the Python code runs successfully, printing out the Fibonacci sequence exactly as the AI programmed it to do.4. The Final Summary
DEBUG | strands.models.bedrock | got response from model
The spell has been cast with great success! ⚡🧙♂️Finally, the system takes all the output generated by the Python script and feeds it back to the AI one last time. The AI looks at the successful sequence, formats it beautifully into a Markdown table, and delivers its final in-character response to you, closing out the quest!
🎉 Quest Complete!
Congratulations! You’ve equipped your agent with the current_time built-in tool, and it can now decide on its own when to use it.
What you’ve learned:
- ✅ How to import a built-in tool and add it to your agent
- ✅ How an agent autonomously decides when to use a tool
- ✅ Tool consent and safety (covered with the bonus quest’s
python_replandfile_write)
Next Adventure: Journey to Chapter 3 where you’ll create custom tools for your specific use cases!
“The right tool at the right moment makes all the difference.” 🛠️✨







