Skip to content

feat(platform): add document_retrieve agent tool#714

Merged
larryro merged 2 commits into
mainfrom
feat/659-document-retrieve-tool
Mar 7, 2026
Merged

feat(platform): add document_retrieve agent tool#714
larryro merged 2 commits into
mainfrom
feat/659-document-retrieve-tool

Conversation

@larryro
Copy link
Copy Markdown
Collaborator

@larryro larryro commented Mar 7, 2026

Summary

  • Add document_retrieve agent tool that retrieves document content from the knowledge base by ID with chunk-based pagination, complementing rag_search by providing sequential, structure-preserving document access
  • Register tool in tool names, tool registry, and Knowledge category in UI tool selector
  • Implement helper with access control, 60s fetch timeout, 50K char safety cap, and differentiated error handling
  • Improve document tools UX: update descriptions to clarify when to use document_retrieve vs file extraction tools, move document_list to Knowledge category
  • Add 24 tests covering happy path, pagination, truncation, access control, error handling, timeout, and schema validation

Refs #659

Test plan

  • Verify document_retrieve returns correct content for a valid document ID
  • Verify chunk-based pagination (chunkStart/chunkEnd) returns expected slices
  • Verify access control rejects unauthorized requests
  • Verify timeout and network error handling
  • Verify tool appears in Knowledge category in the UI tool selector
  • Run existing test suite: all 24 tests pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Introduced document_retrieve tool enabling retrieval of indexed document content with pagination support for handling large documents.
    • Reorganized tool categories to better group document and knowledge base tools.
  • Documentation

    • Enhanced document_list tool descriptions with clearer guidance on appropriate use cases and alternative tools for specific tasks.

larryro added 2 commits March 7, 2026 20:23
Add a new agent tool that retrieves document content from the knowledge
base by ID with chunk-based pagination. Complements rag_search (which
returns relevance-ranked chunks) by providing sequential,
structure-preserving document access.

- Register document_retrieve in tool names and tool registry
- Create tool definition with chunkStart/chunkEnd params (1-indexed)
- Create helper with access control, 60s timeout, 50K char safety cap
- Differentiated error handling (404 graceful, 5xx with context)
- Add to Knowledge category in UI tool selector
- 24 tests covering happy path, pagination, truncation, access control,
  error handling, and schema validation

Refs #659
Move document_list to Knowledge category alongside document_retrieve,
update tool descriptions to clarify when to use document_retrieve vs
file extraction tools, fix totalChars description accuracy, and add
tests for fetch timeout and network error handling.
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@larryro larryro merged commit 5af129c into main Mar 7, 2026
15 of 16 checks passed
@larryro larryro deleted the feat/659-document-retrieve-tool branch March 7, 2026 12:46
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 7, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fe156962-5c5c-478e-a586-6084e8407ce6

📥 Commits

Reviewing files that changed from the base of the PR and between 794304d and 054ce15.

⛔ Files ignored due to path filters (1)
  • services/platform/convex/_generated/api.d.ts is excluded by !**/_generated/**
📒 Files selected for processing (7)
  • services/platform/app/features/custom-agents/components/tool-selector.tsx
  • services/platform/convex/agent_tools/documents/__tests__/document_retrieve_tool.test.ts
  • services/platform/convex/agent_tools/documents/document_list_tool.ts
  • services/platform/convex/agent_tools/documents/document_retrieve_tool.ts
  • services/platform/convex/agent_tools/documents/helpers/retrieve_document.ts
  • services/platform/convex/agent_tools/tool_names.ts
  • services/platform/convex/agent_tools/tool_registry.ts

📝 Walkthrough

Walkthrough

This PR introduces a new document_retrieve agent tool for retrieving indexed document content with pagination support. The implementation includes a tool definition with argument schema validation, a retrieval helper function with access control checks and timeout handling, a comprehensive test suite covering happy paths and error scenarios, and updates to tool categorization mappings, tool registry, and tool naming. Documentation in the document_list tool is updated to clarify the distinction between the new document_retrieve tool and file-based tools.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding a new document_retrieve agent tool to the platform.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/659-document-retrieve-tool

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant