LearnNewsExamplesServices
Frontmatter
id12748
titleInteractive/batch priority lane for local chat-model requests (mirror the embedding queue)
stateClosed
labels
enhancementaiarchitectureperformancemodel-experience
assigneesneo-opus-grace
createdAtJun 8, 2026, 10:46 AM
updatedAtJun 21, 2026, 2:16 AM
githubUrlhttps://github.com/neomjs/neo/issues/12748
authorneo-opus-grace
commentsCount1
parentIssue12740
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 14, 2026, 12:33 AM

Interactive/batch priority lane for local chat-model requests (mirror the embedding queue)

Closed v13.1.0/archive-v13-1-0-chunk-1 enhancementaiarchitectureperformancemodel-experience
neo-opus-grace
neo-opus-grace commented on Jun 8, 2026, 10:46 AM

Context

V-B-A of @tobiu's concern (from the €50-incident follow-up): once we move summarization + mini-summaries + ask synthesis to the local gemma4 endpoint (#12742 + the #12740 epic), a heavy long-running maintenance request could block small interactive requests at the shared, serialized local endpoint.

The V-B-A confirms the worry and locates the gap precisely:

  • The "small-request priority" logic that exists is the embedding interactive/batch queue (ai/services/memory-core/TextEmbeddingService.mjs:127-202): runs local posts one-at-a-time "preferring interactive work" and explicitly "prevents add_memory from waiting behind a serialized batch."
  • The chat path has no equivalent. buildChatModel / SessionService summaries / MemoryService.buildMiniSummary / SearchService ask synthesis call the model with no interactive/batch lane.
  • The heavy-maintenance lease (MaintenanceBackpressureService) is task-level (coordinates the 7 heavy tasks; non-heavy work bypasses it at line 417) — it does not manage endpoint chat-request priority.

Today the block is masked because chat still hits remote Gemini (high concurrency). The local-models move removes that mask.

The Problem

A 30-60m heavy session-summary (or backfill) on the serialized local chat endpoint will queue ahead of a latency-sensitive interactive request (ask_knowledge_base synthesis; the mini-summary fired right after add_memory) → the interactive request waits until the heavy batch finishes / the MCP client times out. Exactly the failure the embedding queue was built to prevent — but for chat.

The Architectural Reality

  • Pattern to mirror: TextEmbeddingService.mjs:127-202#enqueueOpenAiCompatiblePost(inputData, options, priority) with priority: 'interactive'|'batch', FIFO-within-lane, interactive preferred.
  • Chat call sites needing it: SessionService.mjs buildChatModel (:38) + summarizeSessions/summarizePendingSessions; MemoryService.buildMiniSummary (:713); SearchService ask synthesis (:54).
  • Endpoint reality: local OpenAI-compatible / Ollama servers serialize requests (TextEmbeddingService's own note).

The Fix

A shared chat-request interactive/batch lane on the local-endpoint path: interactive work (ask synthesis, post-add_memory mini-summary) preempts/queue-jumps batch work (heavy session-summary, backfill) on the serialized local endpoint. Mirror the embedding queue's semantics; classify heavy maintenance summaries as batch, user/agent-facing requests as interactive.

Decision Record impact

aligned-with ADR 0019 (reads provider config at use site; no mutation).

Acceptance Criteria

  • A heavy batch summarization in flight does NOT block an interactive chat request (ask synthesis / post-add_memory mini-summary) on the local endpoint — interactive jumps the queue.
  • Heavy maintenance summaries classified batch; interactive ask/mini-summary classified interactive.
  • A test demonstrates interactive-preemption under a serialized local endpoint (no live remote API).

Out of Scope

  • Embeddings (already covered — TextEmbeddingService). Provider default → local (#12742). Backfill loop pacing (#12746 — that's the loop's rate, distinct from cross-request priority). KB-ask provider routing (#12741).

Related

  • #12740 (epic). #12742 (the local-default move that makes this a prerequisite). #12746 (backfill loop-safety, sibling). €50 Gemini cost incident V-B-A follow-up, 2026-06-08.

Live latest-open sweep: per the 08:10Z cluster sweep + the 08:30Z merge-audit; no chat-priority-lane dup (distinct from the embedding queue + #12746's loop pacing).

Origin Session ID: 1cf2ad9f-28af-4242-9069-fd14c04e1b62 Retrieval Hint: query_raw_memories("chat request interactive batch priority lane local endpoint heavy summary block")

Authored by Claude Opus 4.8 (Claude Code), @neo-opus-grace.