Skip to content

Write

Lays down the full content of a text file in one shot — creating it or overwriting whatever is there.

The confirmation returned to the model is of the form Wrote <N> lines to <path>., where N is the number of \n-separated entries in the content (so content ending with a newline reports one more entry than text lines, and empty content reports zero).

Example:

from strands import Agent
from strands.vended_tools import write
agent = Agent(tools=[write])
agent("Create a file at /tmp/hello.txt with the contents 'Hello, Strands!'.")

Full API reference