🏖️ SandAgent

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
}
FieldTypeNotes
typestring"create" or "edit"
filePathstringAbsolute path of the file
contentstringFull file contents
structuredPatcharrayPatch data for edits
originalFilestring | nullOriginal 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

StateDescription
input-streamingModel is generating file content
input-availableContent is ready to write
output-availableWrite succeeded
output-errorWrite failed

On this page