Skip to content

feat(rag): Add management UI for user-contributed knowledge entries #69

Closed

Description

@larryro

Background

The rag_write_tool was temporarily removed because knowledge entries written through conversations were directly sent to the external RAG service without being recorded in Convex database. This made it impossible to manage (view, edit, delete) these entries through the existing document management UI.

Problem

When the rag_write_tool was active:

  • Users could add new knowledge or corrections via chat conversations
  • These entries were directly POST'd to the RAG service (/api/v1/documents)
  • Document IDs were generated with pattern: {type}-{timestamp}-{randomString}
  • No record was kept in Convex, so entries couldn't be managed later
  • This could lead to confusion and uncontrollable knowledge accumulation

Knowledge Conflict Problem

A critical issue with the previous implementation: new knowledge could conflict with existing knowledge without resolution.

Example Scenario

  1. Knowledge base contains: "Return policy is 7 days"
  2. User says via chat: "Update return policy to 3 days"
  3. rag_write_tool adds a new document with "Return policy is 3 days"
  4. Both documents now exist in the RAG service
  5. Future queries may retrieve either or both, causing inconsistent responses

Why the "Correction" Mechanism Failed

The tool attempted to handle this by creating correction documents:

CORRECTION - RETURN POLICY
Previous (INCORRECT) information: 7-day return policy
CORRECT information: 3-day return policy
Note: The correct information above should be used instead of older information.

Problems:

  • Old document still exists and can be retrieved
  • LLM must interpret the "correction note" - no guarantee it will
  • Correction may not rank higher than original in similarity search
  • Multiple corrections on same topic accumulate over time

Proposed Solution

If we want to re-enable this feature, we need to address both the management and conflict issues:

1. Database Schema

  • Create a knowledge_entries table in Convex
  • Fields: organizationId, topic, content, type, ragDocumentId, createdAt, createdBy
  • Index by topic for conflict detection

2. Conflict Resolution Strategy (Choose One)

  • Option A: Delete + Replace - When adding knowledge on an existing topic, delete the old entry first
  • Option B: Versioning - Track versions by topic, RAG service only surfaces latest version
  • Option C: Approval Workflow - Chat-submitted knowledge goes to admin queue for review before indexing
  • Option D: Manual Only - Only allow knowledge modifications via admin UI, not via chat (current state)

3. Modify rag_write_tool

  • After writing to RAG service, create record in knowledge_entries table
  • Store ragDocumentId for future deletion capability
  • Implement chosen conflict resolution strategy

4. Management UI

  • Add section in Knowledge management area (alongside Documents)
  • List all user-contributed knowledge entries grouped by topic
  • Show version history if versioning is implemented
  • Allow viewing, editing, and deletion

5. Backend APIs

  • getKnowledgeEntries: List entries with pagination
  • deleteKnowledgeEntry: Delete from both Convex and RAG service
  • getKnowledgeByTopic: For conflict detection

Related Files

  • Removed: services/platform/convex/agent_tools/rag/rag_write_tool.ts
  • Registry: services/platform/convex/agent_tools/tool_registry.ts
  • Chat agent: services/platform/convex/lib/create_chat_agent.ts
  • Existing document management: services/platform/app/(app)/dashboard/[id]/(knowledge)/documents/

Open Questions

  1. Which conflict resolution strategy should we adopt?
  2. Should entries be organization-scoped or support cross-org knowledge?
  3. Should there be rate limiting to prevent abuse?
  4. How to handle semantic duplicates (same meaning, different wording)?

This issue is for discussion and tracking. Implementation can proceed once the approach is agreed upon.

Activity

  1. added
    priority: medium
    needs discussion
    on Jan 2, 2026
  2. larryro commented on Jan 2, 2026

    @larryro
    ContributorAuthor

    Related Commit

    The rag_write_tool has been removed in commit 0d441c6:

    Changes:

    • Deleted services/platform/convex/agent_tools/rag/rag_write_tool.ts
    • Removed from tool registry (tool_registry.ts)
    • Removed from chat agent default tools (create_chat_agent.ts)
    • Removed from UI tool display mapping (chat-interface.tsx)
    • Removed translation entry (en.json)

    The feature is now disabled until a proper management solution (as discussed in this issue) is implemented.

  3. larryro commented on Jan 12, 2026

    @larryro
    ContributorAuthor

    Discussion: Alternative Approach

    One consideration: Do we really need the rag_write_tool feature?

    Alternative: Use Existing Documents Page

    Instead of implementing the full solution (new table + conflict resolution + management UI), users could simply:

    • Extract and refine knowledge into documents manually
    • Upload them via the existing Documents page in the knowledge management area

    Pros of This Approach

    • Zero development cost - leverages existing functionality
    • User-controlled - users have full control over what gets added
    • No conflict issues - users manage conflicts manually (delete old before uploading new)
    • Simpler and more predictable - avoids complexity of automatic knowledge injection

    Cons

    • Less seamless UX - requires manual effort from users
    • Users need to proactively organize and refine knowledge

    Potential Middle Ground

    If conversational knowledge capture is still desired, consider a lighter approach: have the AI suggest that users upload information to the Documents page, rather than auto-writing to the RAG service.


    This is just a thought for discussion, not a final decision. Open to other perspectives.

  4. added
    feat
    and removed on Feb 1, 2026
  5. added
    service: rag
    priority: low
    and removed
    priority: medium
    on Feb 17, 2026
  6. yannickmonney commented on Apr 7, 2026

    @yannickmonney
    Contributor

    This requires both RAG service changes (CRUD endpoints for knowledge entries) and platform UI (management interface). The knowledge entries need to be tracked in Convex for the management UI while being synced to the RAG service for search.

  7. yannickmonney commented on May 31, 2026

    @yannickmonney
    Contributor

    Triaged — keeping open as a design/feature item. Confirmed the rag_write_tool was removed and isn't in the tool registry. Re-enabling conversational knowledge writes needs a conflict-resolution strategy and a management UI — and there's a zero-dev alternative on the table (just use the Documents page) that has support. Decision pending; assigned to me. Related: #662, #77.

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

Metadata

Metadata

Assignees

Labels

featneeds discussionpriority: lowservice: platformservice: rag

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions