Skip to content

fix(backend): replace sunset Assistants file-chat with Chat Completions - #12284

Closed
Git-on-my-level wants to merge 4 commits into
BasedHardware:mainfrom
Git-on-my-level:fix/sca-362-file-chat-completions
Closed

Git-on-my-level wants to merge 4 commits into
BasedHardware:mainfrom
Git-on-my-level:fix/sca-362-file-chat-completions

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

Summary

OpenAI retired the Assistants API on 2026-08-26. Production Cloud Run backend /v2/messages file-chat has been 100% down on the non-vision path since 20:02Z: every POST /v1/threads is 404, wrapped as RuntimeError('failed to create OpenAI thread').

This PR replaces that retired surface with the already-healthy direct Chat Completions lane (SCA-361 RCA):

  • Images stay on gpt-5.6-luna as base64 image_url (live-verified).
  • PDFs use Chat Completions file parts {"type":"file","file":{"file_id":…}} on gpt-4.1 (documented file-input contract; luna is not pinned for an untested file-part capability).
  • Upload: images purpose=vision; PDFs purpose=user_data; other docs rejected at attach as UnsupportedChatFileError.
  • Assistants thread/assistant create/persist/delete is gone. Legacy openai_thread_id / openai_assistant_id remain readable on old session docs.
  • File-chat 4xx is classified at the graph boundary (unsupported_attachment / provider_rejected vs stream_failure) with status_code + sanitized param only.
  • search_files_tool rides the same replacement and still returns a soft error string.

Closes #3361
Closes SCA-362

RCA (SCA-361)

Last-24h chat_response failures were the Assistants file-chat lane. Historical ~2% were Assistants 400s (message-create / run-create). The hard break is the sunset: 8/8 thread creates 404 after 2026-08-26 20:02Z. Files API and chat/completions 200 on the same key. Agentic search_files_tool 404s were swallowed as journey success.

Test plan

  • Sunset: PDF chat via fake completions client; zero Assistants calls; no thread/assistant ids persisted
  • Stale/deleted file_id → typed unsupported_attachment error frame + journey failure
  • Completion stream error after first token → error frame + journey failure
  • Upload: non-PDF doc → 400 UnsupportedChatFileError; PDF → purpose=user_data
  • search_files_tool provider failure returns soft error string without raising
  • Do not merge until review; merge later is merge-commit only (never squash)

Verification

Focused backend unit tests for the file-chat / graph / upload / tool / inventory surfaces passed locally (25 passed on the new Completions suite plus the updated neighbors).

Failure-Class: FC-pinned-vendor-request-contract-retired

Review in cubic

Git-on-my-level and others added 4 commits August 28, 2026 00:53
OpenAI retired Assistants on 2026-08-26, so every /v1/threads create 404s
and non-vision file chat is down. Stream PDFs as Chat Completions file
parts on gpt-4.1 (documented file-input contract) and keep images on the
verified gpt-5.6-luna vision lane.

Failure-Class: FC-pinned-vendor-request-contract-retired
Co-authored-by: Cursor <[email protected]>
Co-authored-by: multica-agent <[email protected]>
Unpacking a token-budget dict into create() is untyped and fails pyright.

Failure-Class: FC-pinned-vendor-request-contract-retired
Co-authored-by: Cursor <[email protected]>
Co-authored-by: multica-agent <[email protected]>
CI ran each unit file in its own process; incomplete BYOK/LLM stubs and a
duration-guard race on desktop transcribe failed the backend suite.

Co-authored-by: Cursor <[email protected]>
Co-authored-by: multica-agent <[email protected]>
Upstream 7c900a9 moved the Soniox client into utils.stt.soniox but left
SafeSonioxSocket / process_audio_soniox imported in streaming.py without a
re-export marker; receiver.py and test_soniox_streaming.py import them through
utils.stt.streaming, so strict pyright fails main and every PR merge ref.

Carry the one-line marker so this backend CI lane can go green; matches the
existing SafeDeepgramSocket compat re-export convention on the previous line.

Co-authored-by: multica-agent <[email protected]>
@Git-on-my-level
Git-on-my-level force-pushed the fix/sca-362-file-chat-completions branch from 4f6d9f1 to ebd3618 Compare August 27, 2026 18:02
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Backend unit suite unblocked — the failure was not in this PR's diff. Upstream main has been failing its own Backend Unit Tests since the Soniox module refactor (7c900a9383) left SafeSonioxSocket / process_audio_soniox imported in backend/utils/stt/streaming.py without a re-export marker; strict pyright flags both as unused even though receiver.py and test_soniox_streaming.py import them through utils.stt.streaming. Since this lane evaluates the merge ref, every open PR inherited the break.

  • Rebased onto current origin/main (932e2f5f06) and marked the Soniox imports as intentional re-exports (# pyright: ignore[reportUnusedImport], matching the existing SafeDeepgramSocket compat line). Net-zero line count (1707 → 1707) so the line-count ratchet stays clean.
  • Verification: enforced backend/scripts/typecheck.sh 0 errors (pinned pyright 1.1.403; was 2 errors); repo-runner unit suites for test_soniox_streaming.py (11 passed), the five file-chat suites (all passed) post-rebase; full pre-push gate passed.
  • Note for maintainers: main itself is still red on this lane (latest main run at 2026-08-27T16:49Z fails with the same 2 errors) — the marker fix or equivalent should land on main separately to unblock other PRs.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Superseded by #12337

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Git-on-my-level 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

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.

Change file upload purpose to user_data according to official recommendation

1 participant