Skip to content

embedder-openai: embed() sends every input in one request; providers with a per-request cap reject a reindex #36995

Description

@os-bob

maintainer · os-bob · session_012dn2AecKpLaYkUtNRiqtby

Filing gate: ① product defect. Source: topic #36990.
Grading: area:ai · Bug · Impeded · rare (deployments that configure a provider with a per-request input cap) · evidence: read (the cap per provider is measured in this card's step 1).

维护者速读

  • 问题:向量化时把所有文本塞进一个请求。有的服务商每次请求最多只收几条,大一点的重建会整批失败。
  • 修法:按每家服务商的上限自动分批,顺序不变。
  • 不做:「单条文本太长」的处理。它要和切分一起做,放在「知识检索平台化」专题。
  • 需要你做的:无。

What

  1. Measure first: for each provider in the known-model table that the PR touches, send one request above its documented per-request input count and record what happens (error or truncation). Name the providers and results in the PR.
  2. packages/plugins/embedder-openai/src/index.ts embed(): split texts into batches of the model's per-request cap (known-model table; an OpenAIEmbedderOptions override; unknown model → a conservative default with one warning), send them in sequence, return vectors in input order.
  3. No change to the IEmbedder contract.

Acceptance

  • Inputs above the cap are split and order is preserved; a failing batch fails the call with the batch index; measured provider caps recorded in the PR.
  • Container run per AGENTS.md; changeset.

Blocked-by: none
Parent: #36990. Reader: the plugins lane.
Dedupe: embedder-openai 159 · embedder batch 117 (none open on this mechanism).

Activity

  1. added theissue type on Nov 24, 2026
  2. added
    area:ai
    on Nov 24, 2026
  3. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    Triage: state pm:queue. Grade, area and type stay as the maintainer filed them. The card's Blocked-by: is none. No seat holds area:ai below p1 under the maintainer's routing, so it waits in the queue for the topic's dispatch.

  4. added
    pm:queue
    on Nov 24, 2026
  5. added
    priority:p2
    pm:queue
    and removed
    pm:queue
    on Nov 24, 2026
  6. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL
    Claim: PM loop round 1
    Session: session_01QSeKYpRrYuqSLCvbSk9zrL
    Account: os-justin
    Branch: claude/issue-36995-embedder-batches
    Worktree: objectstack-issue-36995
    Domain: domain:server (the fix lands in packages/plugins/embedder-openai; the card carries no domain:* label yet — triage's to write)
    Seat: repo:objectstack#4
    Area: a4-K
    File surface: packages/plugins/embedder-openai/**, .changeset/* (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: default (dispatch-gates --tier: "no path-derived mandate … floor sonnet · default opus · ceiling fable"), effort: high
    Clause-②: yes
    Metadata-protocol: none
    Responsibility: objectstack's own embedder-openai plugin sends every input in one /embeddings request (packages/plugins/embedder-openai/src/index.ts embed()) | no platform path batches today | any deployment pointing the embedder at a provider with a per-request input cap, on any reindex larger than that cap
    Thread-read: 7134654574
    Premise: holds — embed() on origin/main f77d078 builds one body { model, input: texts } and sends one request.
    Serial constraints cleared: none — no open PR touches packages/plugins/embedder-openai/** (PR #36823 and PR #36850 file lists read now; open-PR search for the path: none besides the Version Packages PR).
    Pre-claim lane: packages/plugins/embedder-openai/src/index.ts — embedder-openai is in the domain:server row; inside this zone's lease roots.
    Pre-claim deps: card Blocked-by: none; no "after #N".
    Prior rulings read: check-prior-rulings.mjs --card 36995 --paths packages/plugins/embedder-openai — 8 hit lines in 2 files (CHANGELOG, tsconfig.test.json), all about the type-check debt family onboarding, none on batching; docs/adr/** grep for embedder batching: none. Epic #37000 rules bind: no IEmbedder contract change (card item 3).

  7. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 24, 2026
  8. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL
    os-dev-report

    {
      "issue": 36995,
      "status": "done",
      "branch": "claude/issue-36995-embedder-batches",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/37037",
      "head_sha": "f88cfb00425c15c3c67645c379f92046553ff1bd",
      "session": "session_01QSeKYpRrYuqSLCvbSk9zrL",
      "premise_still_valid": true,
      "summary": "Premise held on origin/main a73edb3c (no change to the package since the claim's f77d078d reading): embed() built one body { model, input: texts } and sent one resilientFetch. OpenAIEmbedder.embed() now splits texts into batches of at most maxBatchSize inputs, sends them one after another, and returns the vectors in input order. maxBatchSize comes from the new optional OpenAIEmbedderOptions.maxBatchSize (a positive integer, otherwise the constructor throws), else from a documented-caps table beside KNOWN_DIMENSIONS (OpenAI 2048; DashScope v3 10, v1/v2 25; Zhipu embedding-3 64; SiliconFlow bge-m3/bge-large-zh/en-v1.5 32), else a default of 10 with one console.warn per instance at construction. The class has no logger, and none is reachable from it. A failing batch fails the call with the provider's status and text unchanged plus the suffix [batch index N of M (0-based), inputs A..B], and no later batch is sent. No IEmbedder or packages/spec change. Nothing new is sent: the request body keys are unchanged.",
      "tests": "head f88cfb00. pnpm --filter @objectstack/embedder-openai test: Test Files 1 passed (1), Tests 21 passed (21) (14 existing + 7 new, in a new top-level describe 'OpenAIEmbedder batching (per-request input cap)' in the existing harness src/__tests__/openai-embedder.test.ts). The new cases: order preserved with sizes [10,10,5]; exact cap is 1 request; cap+1 is [10,1]; a failing 2nd batch rejects with the provider text and 'batch index 1 of 3 (0-based), inputs 10..19', with fetch called exactly 2 times; an override of 3 gives [3,3,1]; 0/-1/1.5/NaN are refused; an unknown model is batched [10,2,10,2] with warn called exactly once, and a known model or an override stays silent. typecheck: exit 0 (check:test-typecheck OK, 0 errors). build: exit 0 (check-dts-emitted 2/2). os-verify-lock VERDICT command-exit 0. Ablation, one-time: the tests import ../index (source), so there is no dist leg. Via scripts/ablation-replace.mjs, 'texts.slice(start, start + this.maxBatchSize)' was mutated to 'texts.slice(start)' (anchor x1 -> x0, blob 6e8c6095 -> 5eab5b01). Result: Tests 5 failed | 16 passed (21), the 5 splitting cases red and exact-cap green as expected. Restored: blob == HEAD 6e8c6095, git diff HEAD empty.",
      "gates": "Local subset at f88cfb00: dispatch-gates --commands --repo objectstack-ai/objectstack derived 65 commands. First pass: 62 exit 0, 3 exit 3 (prerequisite, not a verdict). Of the three: check-plugin-teardown-shape --self-test could not reach fixture 621a4876 in the shallow clone, so I fetched that one commit (refs/os-issue-36995/teardown-fixture) and re-ran it: exit 0, 48 cases. pnpm check:lean-entry-closure needed objectql dist, so I built @objectstack/objectql... under the lock and re-ran it: exit 0. pnpm check:dual-build-cjs-loads: self-test 94 cases pass, but the scan needs every package's dist (96+ absent), so it is NOT MEASURED locally, a declared narrowing; CI Lint & Repo Gates runs it. --ran with exit codes recorded: '65 derived, 64 run, 1 NOT-MEASURED, 0 UNRUN'. overlap-check: VERDICT clean (twice: before the push, before pr_create). check-nul-bytes: OK. CI check-runs on PR #37037: not read; reported at hand-off time, in_progress at best.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "3 — all through the fleet-write relay as objectstack-fleet[bot]: POST /repos/objectstack-ai/objectstack/pulls (pr_create, draft, PR #37037); POST /repos/objectstack-ai/objectstack/issues/37037/assignees (pr_create assignees leg, os-justin); POST /repos/objectstack-ai/objectstack/issues/36995/comments (this os-dev-report). Plus 2 git pushes (not REST).",
      "files_changed": [
        ".changeset/36995-embedder-openai-batches.md",
        "packages/plugins/embedder-openai/README.md",
        "packages/plugins/embedder-openai/src/__tests__/openai-embedder.test.ts",
        "packages/plugins/embedder-openai/src/index.ts"
      ],
      "line_budget": "228 changed lines (+217 / -11, 4 files) vs the 3000 human-merge threshold: under. Within the file surface (packages/plugins/embedder-openai/** plus one .changeset).",
      "deviations": [
        "Card step 1 (one live over-cap request per provider) was NOT done: this container holds no provider API keys, and none were requested. Every cap is documented, not measured live, with its source URL and quote in the PR (OpenAI, DashScope, Zhipu, SiliconFlow). Doubao, MiniMax, Ollama, Zhipu embedding-2 and BGE base/small document no item cap, so they take the default of 10.",
        "check:dual-build-cjs-loads NOT MEASURED locally (needs a whole-workspace build); a declared narrowing, so CI's run is its reading.",
        "test:repo not run locally (CI-owned; the diff touches none of its tests). AGENTS.md Multi-agent §10's full suite before the PR is narrowed by the os-dev local-verification scope to the targeted package run plus the derived gates.",
        "Harness attribution conflict: the session reminder asked for a commit trailer naming the model ('Co-Authored-By: Claude Opus …') and a PR-body footer with an emoji line. AGENTS.md (which the reminder defers to) forbids a model identifier in the trailer pair and fixes the footer form, so the commit carries the model-free pair 'Claude-Session' + 'Co-authored-by: Claude' and the PR body carries the AGENTS.md session-URL footer.",
        "One-warning choice: emitted once per embedder instance at construction, not per call, through console.warn, because the class has no logger and none is reachable from it."
      ],
      "open_questions": [
        {
          "question": "Card step 1 asks for a live over-cap request per provider; none was possible here (no keys). Is the documented-caps record enough to accept, or is a live measurement still owed?",
          "options": [
            "A — accept the documented caps (source + quote per provider in the PR); a deployment with a different cap sets maxBatchSize",
            "B — a seat holding provider keys runs one over-cap request per provider and appends the observed error text to the PR"
          ],
          "recommendation": "A, because every cap in the table is quoted from the provider's own API reference (two as an explicit schema maxItems), the default of 10 is at or below every documented cap, and B needs credentials this lane may not request."
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted in the PR's Acceptance notes, not filed — OpenAI also caps a request at 300,000 tokens summed across inputs (API reference); item-count batching does not bound that. Read from the docs only, not reproduced; it sits with the input-size/chunking work the card leaves to the epic · dedupe words: embedder token budget, embeddings 300000 tokens, embedder chunking",
        "carrier: none · noted in the PR's Acceptance notes, not filed — the only description found of MiniMax's own embeddings endpoint (a third-party snippet) shows a texts + type body, not input; if so, the minimax preset may not work at all. Unverified, no key, read-only inference · dedupe words: embedder minimax, embo-01 texts, minimax preset"
      ]
    }
  9. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

    Ruled · 2026-11-24T16:15Z · provider caps — option A (documented caps accepted)

    The maintainer's words, in seat repo:objectstack#4's session, 2026-11-24, verbatim: 「A」 — the answer to the seat's presentation of the open question zone a4-K raised on PR #37037 (dev report 7137247072), analysed at fable tier on the four axes, recommendation A.

    • A (ruled): the acceptance line "measured provider caps recorded in the PR" is replaced by: each provider's documented cap is cited in the PR with its source (quote and link); a live measurement is added later where a key exists. The PR's table (OpenAI 2048; DashScope v3 10, v1/v2 25; Zhipu embedding-3 64; SiliconFlow bge family 32; an unknown provider defaults to 10 with a one-time warning) and the maxBatchSize override stand as the shipped behaviour. The PR keeps "documented, not measured live" in its body.
    • Why it holds: a documented cap that is too high fails loudly (the call fails with the batch index and the input range, no later batch is sent, a short vector count also fails), and the deployment sets maxBatchSize; one that is too low only costs more requests. Nothing is dropped silently on the rebuild path.
    • Not taken: B (a key-holding seat measures each provider before merge) — no lane may request provider keys, and it would hold epic 专题:知识检索平台化(应用写一份知识源配置就有可用的检索:开源、托管、企业版都能用) #37000's phase-1 outcome for a confirmation the override already covers.

    Noted, not changed by this ruling: on the event-sync path a failure is logged and the record is not indexed (today's behaviour, not this PR's); that belongs to #37000's phase 4.

  10. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL

    Delivered (2026-11-24T17:02Z): PR #37037 merged as 5ff858b and closed this card. Area: a4-K.

    • OpenAIEmbedder.embed() now sends inputs in sequential batches of the model's per-request cap (documented-caps table, maxBatchSize override, unknown model defaults to 10 with one warning), returns vectors in input order, and fails the call with the batch index and input range; no IEmbedder change.
    • Acceptance as ruled (7137388978, option A): documented caps cited per provider; live measurement left for where a key exists.
    • Nothing remains on this card. The OpenAI per-request token total sits with epic 专题:知识检索平台化(应用写一份知识源配置就有可用的检索:开源、托管、企业版都能用) #37000's splitter work. pm:dispatched removed in this stroke.
  11. removed
    pm:dispatched
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:aipriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions