Skip to content

Fix/agent creation files#7346

Merged
Subash-Mohan merged 5 commits intomainfrom
fix/agent-creation-files
Jan 12, 2026
Merged

Fix/agent creation files#7346
Subash-Mohan merged 5 commits intomainfrom
fix/agent-creation-files

Conversation

@Subash-Mohan
Copy link
Copy Markdown
Contributor

@Subash-Mohan Subash-Mohan commented Jan 11, 2026

Description

This pull request addresses below:

  1. Disable the Create/Save button while files are still uploading (UPLOADING status)
  2. Show a message when files are processing: "Onyx is still processing your uploaded files, the agent can be used but it will not have access to all the files.
  3. Notify the assistant owner when all files are processed if the assistant is created before user file processing is completed.

ticket -> https://linear.app/onyx-app/issue/ENG-3124/user-uploaded-large-files-block-agent-creation

How Has This Been Tested?

Tested by creating the assistant before the files were processed and verified whether the notification was received.
Screenshot 2026-01-11 at 12 37 54 PM

Additional Options

  • [Optional] Override Linear Check

Summary by cubic

Improve agent creation flow by blocking Create/Save while files upload, showing a clear processing message, and notifying owners when all files finish indexing. Addresses Linear ENG-3124 so large uploads don’t stall creation and owners know when agents have full file access.

  • New Features

    • Send ASSISTANT_FILES_READY notification to the assistant owner when all files for that agent are completed, with a link to the agent.
  • Bug Fixes

    • Disable Create/Save while any selected file is uploading.
    • Show a message when files are processing: “Onyx is still processing your uploaded files. You can create the agent now, but it will not have access to all files until processing completes.”

Written for commit 211cd5b. Summary will update on new commits.

@Subash-Mohan Subash-Mohan requested a review from a team as a code owner January 11, 2026 07:22
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="backend/onyx/db/notification.py">

<violation number="1" location="backend/onyx/db/notification.py:20">
P1: The check-then-insert pattern creates a race condition window where concurrent calls can create duplicate notifications. Consider using SQLAlchemy's atomic insert().on_conflict_do_update() to handle existing notifications atomically.

(Based on your team's feedback about avoiding TOCTOU race conditions with atomic operations.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 11, 2026

Greptile Overview

Greptile Summary

This PR implements three key improvements to the agent creation flow when files are being uploaded:

Changes Made

  1. Backend Notification System - Added ASSISTANT_FILES_READY notification type that alerts users when all uploaded files have finished processing for their agent
  2. Frontend Button Disabling - Disabled the Create/Save button while files are in UPLOADING status to prevent premature agent creation
  3. User Feedback Message - Added an informational message when files are still processing, explaining that the agent can be used but won't have access to all files yet

Critical Issues Found

1. Duplicate Notification Bug ⚠️ (MUST FIX)

The notification logic in user_file_indexing_adapter.py will create multiple notifications when multiple files for the same assistant complete in the same batch. The deduplication check doesn't work because autocommit=False prevents the transaction from seeing previously created notifications in the same batch. Fix: Track notified assistants within the batch to prevent duplicates.

2. Missing File Status Handling ⚠️ (SHOULD FIX)

In AgentEditorPage.tsx, if a file ID exists in user_file_ids but not in allRecentFiles, the status check returns undefined and the button won't be disabled. This edge case could allow form submission with files in an unknown state. Fix: Treat undefined status as "uploading" to err on the side of caution.

3. Message Clarity (NICE TO HAVE)

The processing message could be clearer about whether users can proceed with agent creation and what to expect regarding file availability and notifications.

Architecture Notes

  • UPLOADING is a frontend-only status for optimistic UI updates; the backend only uses PROCESSING, COMPLETED, FAILED, CANCELED, and DELETING
  • The notification uses the existing notification infrastructure with additional_data.link to provide a clickable link to the agent
  • The notification deduplication logic checks for existing notifications with the same user_id, notif_type, and additional_data

Confidence Score: 2/5

  • This PR has critical bugs that will cause duplicate notifications and potential edge case issues with file status handling
  • While the overall approach is sound and addresses the requirements, there are two critical logic errors: (1) duplicate notifications when multiple files complete simultaneously, and (2) undefined file status handling that could allow form submission in invalid states. The duplicate notification bug is particularly problematic as it will annoy users and could happen frequently if files are batched together for processing. These issues must be fixed before merging.
  • Pay close attention to backend/onyx/indexing/adapters/user_file_indexing_adapter.py (duplicate notification logic) and web/src/refresh-pages/AgentEditorPage.tsx (undefined file status handling)

Important Files Changed

File Analysis

Filename Score Overview
backend/onyx/indexing/adapters/user_file_indexing_adapter.py 2/5 Added notification logic for assistant file completion; critical bug with duplicate notifications when multiple files complete in same batch
backend/onyx/db/notification.py 3/5 Added autocommit parameter for transaction control; deduplication may not work correctly with autocommit=False
web/src/refresh-pages/AgentEditorPage.tsx 3/5 Added file status checks to disable Create/Save button and show processing message; potential edge case where undefined file status could allow submission

Sequence Diagram

sequenceDiagram
    participant User
    participant AgentEditorPage
    participant Backend
    participant IndexingAdapter
    participant NotificationService
    participant Database

    User->>AgentEditorPage: Upload files & create/edit agent
    AgentEditorPage->>AgentEditorPage: Check file status (UPLOADING)
    alt Files still uploading
        AgentEditorPage-->>User: Disable Create/Save button
    end
    
    AgentEditorPage->>Backend: Submit agent with user_file_ids
    Backend->>Database: Create/update agent with file associations
    Backend-->>User: Agent created
    
    Note over Backend,IndexingAdapter: File processing happens async
    
    IndexingAdapter->>IndexingAdapter: Process uploaded files
    IndexingAdapter->>Database: Update file status to PROCESSING
    IndexingAdapter->>IndexingAdapter: Index file content
    IndexingAdapter->>Database: Update file status to COMPLETED
    
    IndexingAdapter->>IndexingAdapter: Check if all assistant files completed
    alt All files completed
        IndexingAdapter->>NotificationService: Create ASSISTANT_FILES_READY notification
        NotificationService->>Database: Check for duplicate notification
        NotificationService->>Database: Save notification (autocommit=false)
        IndexingAdapter->>Database: Commit transaction
    end
    
    Database-->>User: Notification sent
    User->>AgentEditorPage: Click notification link
    AgentEditorPage->>Backend: Navigate to /assistants/{id}
    Backend-->>User: Show agent with all files ready
Loading

Copy link
Copy Markdown
Contributor

@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.

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Contributor

@yuhongsun96 yuhongsun96 left a comment

Choose a reason for hiding this comment

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

lgtm

@Subash-Mohan Subash-Mohan added this pull request to the merge queue Jan 12, 2026
Merged via the queue into main with commit e320ef9 Jan 12, 2026
72 of 74 checks passed
@Subash-Mohan Subash-Mohan deleted the fix/agent-creation-files branch January 12, 2026 07:05
jessicasingh7 pushed a commit that referenced this pull request Jan 12, 2026
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.

2 participants