Skip to content

agent-cloud /sync drops non-NULL columns when the first row of a batch has NULLs #10602

Closed

Description

@skanderkaroui

The agent VM's /sync endpoint derives the column list for a whole batch from the first row only, while the desktop sender deliberately omits NULL columns per row. When those disagree, rows are written missing columns that the sender did populate — and the desktop still advances its sync cursor, so they are never resent.

Sender — desktop/macos/Desktop/Sources/AgentSyncService.swift:523-525:

case .null:
  // skip nulls — let the VM use its defaults
  break

Each row's key set therefore varies by which columns happened to be NULL.

Server — desktop/macos/agent-cloud/agent.mjs:1592:

const cols = Object.keys(rows[0]);

That schema is then applied to all 100 rows of the batch via INSERT OR REPLACE.

Concrete failure: a screenshots batch whose first row was captured but not yet OCR'd/embedded omits ocrText and embedding, so cols excludes them. The other 99 rows — which do have OCR text and embeddings — are inserted without those columns. Because it is INSERT OR REPLACE (delete + insert), any values already on the VM are wiped as well. semantic_search (WHERE embedding IS NOT NULL) then silently returns nothing for those screenshots and screenshots_fts has no text to match. /sync returns {"applied": 100}, the desktop advances its cursor, and the rows are never resent.

The converse also holds: if row 0 has a column that later rows omit, those later rows get an explicit null written over real prior data.

Both sides verified by reading the current code; present on main and on the branch for #10256.

Found while working backwards from PostHog agent metrics. Not fixing it in the same change as the unrelated agent-proxy/backend fixes since it changes wire behaviour on the sync path and deserves its own review.

Activity

  1. moved this from Someday to In progress in omi TODO / bountieson Jul 25, 2026
  2. added 2 commits that reference this issue on Jul 25, 2026
    4d1f0a7
    d3e7015
  3. moved this from In progress to In review in omi TODO / bountieson Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions