From eba94a0de03f13683d5f70b98b26e0b3da0b4ff9 Mon Sep 17 00:00:00 2001 From: Lukas Parsons Date: Tue, 7 Jul 2026 11:45:05 -0400 Subject: [PATCH] fix: add 'read' to manage_documents tool schema + DOCUMENT PANEL disambiguation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit manage_documents: Added read/view/open/get to the action enum (was only list/delete/tidy). The handler already supported these actions but the function-calling schema blocked the model from using them. Added document_id (for read), offset (pagination), and limit (chars to read) params with descriptions for the read action. create_document, edit_document: Added 'DOCUMENT PANEL (not disk)' prefix to prevent models from using these for filesystem operations. Explicitly references write_file/edit_file as the disk alternative. These were the root cause of agent-mode document confusion — the model had filesystem tools but no way to read library documents. --- src/tool_schemas.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/tool_schemas.py b/src/tool_schemas.py index 2006be9c..a0dd392d 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": "DOCUMENT PANEL (not disk) — 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. For files on disk use write_file.", "parameters": { "type": "object", "properties": { @@ -203,7 +203,7 @@ FUNCTION_TOOL_SCHEMAS = [ "type": "function", "function": { "name": "edit_document", - "description": "Edit a document OPEN IN THE EDITOR PANEL (created via create_document) — NOT a file on disk. For files on disk (home folder, project files, anything with a path like ~/x.txt or /path/to/file) use edit_file instead. Targeted find-and-replace with multiple FIND/REPLACE pairs per call; use for any edit smaller than a full rewrite. Do NOT send the whole file back via update_document for small edits.", + "description": "DOCUMENT PANEL (not disk) — Edit a document OPEN IN THE EDITOR PANEL (created via create_document) — NOT a file on disk. For files on disk (home folder, project files, anything with a path like ~/x.txt or /path/to/file) use edit_file instead. Targeted find-and-replace with multiple FIND/REPLACE pairs per call; use for any edit smaller than a full rewrite. Do NOT send the whole file back via update_document for small edits.", "parameters": { "type": "object", "properties": { @@ -752,15 +752,16 @@ FUNCTION_TOOL_SCHEMAS = [ "type": "function", "function": { "name": "manage_documents", - "description": "Manage documents: list all documents (with optional search/language filter), delete documents, or run tidy cleanup.", + "description": "DOCUMENT PANEL (not disk) — List, read, delete, or tidy library documents. Use action=list to find documents, then action=read with document_id to view one (supports offset/limit for pagination). The document opens in the editor panel — click its title link or use action=read. Do NOT use read_file for library documents; use this tool instead.", "parameters": { "type": "object", "properties": { - "action": {"type": "string", "enum": ["list", "delete", "tidy"]}, - "document_id": {"type": "string", "description": "Document ID (for delete)"}, + "action": {"type": "string", "enum": ["list", "read", "view", "open", "get", "delete", "tidy"]}, + "document_id": {"type": "string", "description": "Document ID (for read, delete)"}, "search": {"type": "string", "description": "Search query (for list)"}, "language": {"type": "string", "description": "Filter by language (for list)"}, - "limit": {"type": "integer", "description": "Max results (for list, default 50)"} + "limit": {"type": "integer", "description": "Max results (for list, default 50) or max chars to read (for read, default 8000)"}, + "offset": {"type": "integer", "description": "Char offset for paginated reading (for read, default 0)"} }, "required": ["action"] }