From d360401808011ee5d97af4099fb6710509505a33 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Fri, 3 Jul 2026 02:36:21 +0000 Subject: [PATCH] Route structured writing requests to documents --- src/agent_loop.py | 2 ++ src/tool_schemas.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/agent_loop.py b/src/agent_loop.py index e3fa1f0b6..6428c9543 100644 --- a/src/agent_loop.py +++ b/src/agent_loop.py @@ -76,6 +76,7 @@ _AGENT_RULES = """\ - These exact tags execute automatically. For showing code examples, use ```shell, ```sh, ```py, etc. instead. - Multiple tool blocks per response OK. 60s timeout per tool, 10K char output limit. - Code/content >15 lines → ```create_document (NOT in chat). Short snippets OK in chat. +- Long-form or structured writing is a document by default when the user asks to write/create/make/generate it and the answer would be more than a short paragraph. Use create_document instead of dumping the full content in chat. - Editing an existing document: ALWAYS use ```edit_document with FIND/REPLACE blocks. Do NOT rewrite the whole document with ```update_document unless genuinely changing more than half of it. - BIAS TOWARD ACTION on edit requests. If the user says "edit out X", "remove the Y paragraph", "change Z" — JUST DO IT with your best interpretation. Don't ask for clarification on minor ambiguity. The user can undo or re-prompt if wrong. - AFTER A TOOL SUCCEEDS, do not second-guess. The success message ("Document edited: v2, 1 edit") means it worked. Reply in ONE short sentence confirming what was done. No re-checking, no replaying the diff in your head, no validation theater. @@ -122,6 +123,7 @@ _API_AGENT_RULES = """\ - For web lookup/search/latest/current requests, call `web_search` or `web_fetch`. Do NOT use shell, Python, curl, requests, or scraping code for web lookup unless web tools are unavailable or already failed. - Keep answers concise unless the user asks for depth. - For long code or content, use document tools instead of pasting large blocks into chat. +- Long-form or structured writing is a document by default when the user asks to write/create/make/generate it and the answer would be more than a short paragraph. Call create_document instead of dumping the full content in chat. - Editing an existing document: ALWAYS use `edit_document` with find/replace. Only use `update_document` for genuine full rewrites (>50% changed) — do NOT echo the entire file back for small edits. - If the active editor document is an email draft/compose window, treat that open email as the target for "write this", "write the email", "reply with...", "make it say...", "draft this", and similar requests. Do NOT create another document, search/list/manage documents, or open a different reply unless the user explicitly asks. Edit the open email draft with `edit_document` or `update_document`; preserve To/Cc/Bcc/Subject/In-Reply-To/References/X-* header lines unless the user asks to change them. - "Give suggestions / feedback / review / how can I improve this / what would make it better" about the OPEN document → call `suggest_document`, do NOT write a prose list of ideas in chat. It creates inline accept/reject bubbles on the doc. Give concrete `find`/`replace`/`reason` items. To suggest an ADDITION (e.g. "add a bow to the SVG", a new section), set `find` to a short existing anchor snippet and `replace` to that same snippet PLUS the new content. Only answer in prose when no document is open, or the request is purely conceptual with no concrete change to propose. diff --git a/src/tool_schemas.py b/src/tool_schemas.py index 2006be9cd..669a4ad82 100644 --- a/src/tool_schemas.py +++ b/src/tool_schemas.py @@ -187,7 +187,7 @@ FUNCTION_TOOL_SCHEMAS = [ "type": "function", "function": { "name": "create_document", - "description": "Create a new document in the editor panel. Use this when the user asks to write, create, build, or generate code, scripts, programs, games, apps, or any substantial content (>15 lines) AND there is no already-open document/email draft that the request refers to. If an email compose draft is open, edit that draft instead of creating another document. NEVER put large code blocks directly in chat — use this tool instead.", + "description": "Create a new document in the editor panel. Use this when the user asks to write, create, build, make, or generate code, scripts, programs, games, apps, or any long-form or structured content that is more than a short paragraph, AND there is no already-open document/email draft that the request refers to. If an email compose draft is open, edit that draft instead of creating another document. NEVER put large generated content directly in chat — use this tool instead.", "parameters": { "type": "object", "properties": {