WriteFileSchema is the OpenAI tool definition for write_file. The description steers the model away from bash heredocs (shell-quoting failure mode) for small-to-medium writes, and toward heredoc appends for large files (streamed tool-call args truncate server-side), mirroring the system prompt's rul
()
| 37 | // tool-call args truncate server-side), mirroring the system prompt's rule so |
| 38 | // the two instruction channels can't contradict each other. |
| 39 | func WriteFileSchema() map[string]any { |
| 40 | return map[string]any{ |
| 41 | "type": "function", |
| 42 | "function": map[string]any{ |
| 43 | "name": WriteFileName, |
| 44 | "description": "Write content bytes to a file at path. Creates parent directories. Overwrites existing files. Use this instead of bash heredocs for small-to-medium multi line content or content with single quotes, dollar signs, or backticks - no shell quoting issues. Content beyond a few hundred lines gets truncated by the server mid-stream: build large files with bash heredoc appends (cat > path <<'EOF' first, then cat >> path <<'EOF' per part) from the first call.", |
| 45 | "parameters": map[string]any{ |
| 46 | "type": "object", |
| 47 | "properties": map[string]any{ |
| 48 | "path": map[string]any{ |
| 49 | "type": "string", |
| 50 | "description": "Absolute or relative file path. Relative paths resolve against the working directory.", |
| 51 | }, |
| 52 | "content": map[string]any{ |
| 53 | "type": "string", |
| 54 | "description": "Exact bytes to write to the file.", |
| 55 | }, |
| 56 | }, |
| 57 | "required": []string{"path", "content"}, |
| 58 | }, |
| 59 | }, |
| 60 | } |
| 61 | } |