feat(platform): require explicit user request for file generate operations#855
Conversation
…tions Add guard instructions to all file tool descriptions (DOCX, Excel, PDF, PPTX, text) to prevent the agent from proactively generating files unless the user explicitly asks for that format.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughThis PR updates the tool descriptions for five file export tools (DOCX, Excel, PDF, PPTX, and text) to add explicit instructions that the "generate" operation should only be invoked when users explicitly request file creation or export. The changes are purely descriptive and do not modify any runtime logic, argument schemas, control flow, or execution behavior. Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@services/platform/convex/agent_tools/files/pdf_tool.ts`:
- Line 41: The agent system prompt in file agent.ts still instructs the agent to
"Generate with reasonable defaults" and "Choose appropriate formats
automatically", which conflicts with the new guard in pdf_tool.ts that requires
explicit user requests to call the "generate" operation; update the agent system
prompt (the string or constant that composes the file agent instructions, e.g.,
the SYSTEM_PROMPT or buildAgentPrompt function in the file agent module) to
remove any phrasing that allows automatic PDF creation and instead explicitly
require that the agent call the PDF tool's "generate" operation only when the
user explicitly asks to create or export a PDF; ensure the prompt language
mirrors the guard in pdf_tool.ts so the agent will not choose formats or invoke
generate proactively.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 17b12e11-e4e0-404d-afbe-d61f7c6eed46
📒 Files selected for processing (5)
services/platform/convex/agent_tools/files/docx_tool.tsservices/platform/convex/agent_tools/files/excel_tool.tsservices/platform/convex/agent_tools/files/pdf_tool.tsservices/platform/convex/agent_tools/files/pptx_tool.tsservices/platform/convex/agent_tools/files/text_tool.ts
| tool: createTool({ | ||
| description: `PDF tool for generating, downloading, and parsing PDF documents. | ||
|
|
||
| IMPORTANT: Only call the "generate" operation when the user explicitly requests creating or exporting a PDF file. Do NOT proactively generate PDFs unless the user specifically asks for this format. |
There was a problem hiding this comment.
Conflicting agent instructions can still trigger proactive PDF generation.
Line 41 adds the right guard, but it conflicts with services/platform/convex/agents/file/agent.ts (“Generate with reasonable defaults” / “Choose appropriate formats automatically”). With both present, behavior is ambiguous and the PR objective (“require explicit user request”) is not reliably enforced. Please align the file-agent system prompt with this new rule so “generate” is only used on explicit user request.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@services/platform/convex/agent_tools/files/pdf_tool.ts` at line 41, The agent
system prompt in file agent.ts still instructs the agent to "Generate with
reasonable defaults" and "Choose appropriate formats automatically", which
conflicts with the new guard in pdf_tool.ts that requires explicit user requests
to call the "generate" operation; update the agent system prompt (the string or
constant that composes the file agent instructions, e.g., the SYSTEM_PROMPT or
buildAgentPrompt function in the file agent module) to remove any phrasing that
allows automatic PDF creation and instead explicitly require that the agent call
the PDF tool's "generate" operation only when the user explicitly asks to create
or export a PDF; ensure the prompt language mirrors the guard in pdf_tool.ts so
the agent will not choose formats or invoke generate proactively.
Prevent ambiguous form submissions by ensuring single_select, multi_select, and yes_no fields have unique resolved values (value ?? label). Adds Zod refinement on the schema and a runtime check in the mutation.
Summary
Test plan
Summary by CodeRabbit