API Reference
writeTool
function writeTool(backend): Tool;Defined in: tools/builtin/file-write.ts:41
Build a write tool bound to a backend.
Parameters
| Parameter | Type | Description |
|---|---|---|
backend | FileWriteBackend | The FileWriteBackend that actually writes to the host. |
Returns
A Tool named write ready to pass to the agent loop or a ToolRegistry.
Remarks
Runs sequentially (ExecutionMode.Sequential) for the same reason
shell does: writes have side effects and order matters, so the loop must not
race a batch of them. Results are shaped by formatWriteResult.
See
Example
const tool = writeTool(myFileWriteBackend);
// Recommended: gate a write tool before granting it to an untrusted model.
await runAgent({ ...opts, tools: [tool] });
// The model can now call: write({ path: "out.txt", content: "hello" })