A declaration, not a function. It is the simplest of the four write tools, and the only one that cannot lose anything.
Declaring it
tools: {
create_folder: api.tools.createFolder,
write_document: api.tools.writeDocument,
}tools = {
"create_folder": api.tools.create_folder,
"write_document": api.tools.write_document,
}What the model sends
pathstringrequiredThe folder, relative to the workspace. For example Projects/Launch.
Every parent is created on the way, and a folder that is already there is left exactly as it is — so the call is safe to repeat. The answer is the folder's path.
// What the run reports back
{ path: "Projects/Launch" }# What the run reports back
{"path": "Projects/Launch"}It is rarely the one you need
Declare this one when the structure itself is the point — a tree prepared before anything is filled, an empty folder an interface will show. For writing a file, the write tool is enough, and one tool fewer is fewer tokens on every turn.
The path rules are the workspace's
Relative, forward slashes, and it cannot leave the workspace. An absolute path or one that climbs out is refused — see LocalFiles for the whole set.
The server cannot reach a disk. When the agent calls this, the run asks the machine that holds the key to perform it, the package does the work there, and the answer goes back into the run. So it only works while your process is listening — and nothing of the file ever travels to be written.
Refusals the run reports
- A missing path, or one that is not a string.
- An absolute path, or one outside the workspace.
- The workspace root itself.
- A path where a file already sits — the filesystem refuses, and the message says so.