Write Tool UI
Handle file write tool calls from the agent in your UI
When the agent uses the Write tool, it produces a DynamicToolUIPart that your UI can render.
Output Shape
{
"type": "create",
"filePath": "/sandagent/output/report.md",
"content": "# Title\n\nFull file contents...",
"structuredPatch": [],
"originalFile": null
}| Field | Type | Notes |
|---|---|---|
type | string | "create" or "edit" |
filePath | string | Absolute path of the file |
content | string | Full file contents |
structuredPatch | array | Patch data for edits |
originalFile | string | null | Original file contents for edits |
DynamicToolUIPart
interface DynamicToolUIPart {
toolName: "Write";
state: "input-streaming" | "input-available" | "output-available" | "output-error";
input: {
file_path: string;
content: string;
};
output?: {
type: "create" | "edit";
filePath: string;
content: string;
structuredPatch: any[];
originalFile: string | null;
};
errorText?: string;
}State Behavior
| State | Description |
|---|---|
input-streaming | Model is generating file content |
input-available | Content is ready to write |
output-available | Write succeeded |
output-error | Write failed |