Summary
Add a new document_list agent tool that allows the AI agent (and workflow LLM nodes) to query and filter documents from the knowledge base. Currently, the agent has no way to list, filter, or browse documents — it can only search by semantic relevance via rag_search.
Motivation
Many advanced workflows require the agent to identify specific documents before processing them:
- "Find the last 10 contracts uploaded this month"
- "List all documents in folder X"
- "Show me all PDF files tagged with team Y"
Without this tool, the agent cannot perform document-level operations like comparison, batch analysis, or systematic review.
Proposed Tool Design
Tool name: document_list
Registration: Add to agent_tools/tool_names.ts and agent_tools/tool_registry.ts
Input Schema
{
folderPath?: string; // Filter by folder path (e.g., "/contracts/2024")
extension?: string; // Filter by file extension (e.g., "pdf", "docx")
dateFrom?: string; // ISO date string, filter by creation date
dateTo?: string; // ISO date string, filter by creation date
query?: string; // Optional name/title search
sortBy?: "createdAt" | "name"; // Sort order (default: "createdAt")
sortOrder?: "asc" | "desc"; // Sort direction (default: "desc")
limit?: number; // Max results (default: 20, max: 50)
}
Output
{
documents: Array<{
id: string;
name: string;
folderPath: string;
extension: string;
createdAt: string; // ISO timestamp
sizeBytes: number;
teamTags: string[];
}>;
totalCount: number;
hasMore: boolean;
}
Implementation Notes
- Query the Convex
documents table directly (no RAG service call needed)
- Scope by
organizationId from tool context
- Filter by
teamTags using userTeamIds from tool context for access control
- Leverage existing indexes on
organizationId + extension
- Follow patterns from existing tools like
customer_read_tool.ts and product_read_tool.ts
Key Files
services/platform/convex/agent_tools/documents/document_list_tool.ts (new)
services/platform/convex/agent_tools/tool_names.ts (register name)
services/platform/convex/agent_tools/tool_registry.ts (register tool)
services/platform/convex/documents/ (existing queries to reference)
Acceptance Criteria
Summary
Add a new
document_listagent tool that allows the AI agent (and workflow LLM nodes) to query and filter documents from the knowledge base. Currently, the agent has no way to list, filter, or browse documents — it can only search by semantic relevance viarag_search.Motivation
Many advanced workflows require the agent to identify specific documents before processing them:
Without this tool, the agent cannot perform document-level operations like comparison, batch analysis, or systematic review.
Proposed Tool Design
Tool name:
document_listRegistration: Add to
agent_tools/tool_names.tsandagent_tools/tool_registry.tsInput Schema
Output
Implementation Notes
documentstable directly (no RAG service call needed)organizationIdfrom tool contextteamTagsusinguserTeamIdsfrom tool context for access controlorganizationId + extensioncustomer_read_tool.tsandproduct_read_tool.tsKey Files
services/platform/convex/agent_tools/documents/document_list_tool.ts(new)services/platform/convex/agent_tools/tool_names.ts(register name)services/platform/convex/agent_tools/tool_registry.ts(register tool)services/platform/convex/documents/(existing queries to reference)Acceptance Criteria
document_listtool registered in tool registry