Skip to content

Add optional token-budget embedding batches - #76

Merged
mariusvniekerk merged 4 commits into
mainfrom
feat/vector-token-budget
Aug 27, 2026
Merged

Add optional token-budget embedding batches#76
mariusvniekerk merged 4 commits into
mainfrom
feat/vector-token-budget

Conversation

@mariusvniekerk

@mariusvniekerk mariusvniekerk commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Embedding providers can cap the combined input tokens in a request independently of input count. EncodeBatched and Fill now use functional options; WithBatchTokenBudget derives the effective batch width from a caller-supplied total budget and conservative per-input bound, and applies it to direct encoding and shared fill batches.

This replaces the public BatchOptions and FillOptions structs before the new API ships. Omitting the token budget preserves count-only batching. Callers remain responsible for model limits and token estimates; kit/vector does not tokenize or alter input text.

Count-only batching can exceed a provider's aggregate token limit even when
each input fits the model. Shared callers need one way to lower request width
from a conservative per-input upper bound.

Keep the budget opt-in so existing callers retain their current request shape.
Callers still own model limits and token estimates; the vector package only
enforces the declared bound.
@roborev-ci

roborev-ci Bot commented Aug 27, 2026

Copy link
Copy Markdown

roborev: Combined Review (56dc87d)

Verdict: Medium-severity issue found in cross-document Fill batching.

Medium

  • vector/flow.go:269 — Cross-document Fill batching calls EncodeBatched with empty BatchOptions, silently ignoring WithBatchTokenBudget when FillOptions.Batch.BatchSize > 0. This can send batches exceeding the configured token budget. Apply the effective token-limited batch size when splitting fill references and propagate invalid-budget errors before encoding.

Reviewers: 2 done | Synthesis: codex, 5s | Total: 1m16s

Providers can cap the combined input tokens separately from the number of
inputs. Callers need API documentation that identifies when the option applies
and how a conservative per-input bound affects request capacity.

Generated with OpenAI Codex
Co-authored-by: OpenAI Codex <noreply@openai.com>
@roborev-ci

roborev-ci Bot commented Aug 27, 2026

Copy link
Copy Markdown

roborev: Combined Review (6ebe861)

Verdict: One medium-severity batching issue found.

Medium

  • vector/flow.go:191-193,269Fill cross-document batching ignores WithBatchTokenBudget, splitting only by BatchSize and calling EncodeBatched with empty options. Requests may exceed the configured token limit. Apply the effective token-capped batch size when splitting fill references and add an integration test for cross-document fills.

Reviewers: 2 done | Synthesis: codex, 5s | Total: 2m5s

Callers should configure batching on the operation instead of constructing
temporary option structs. A single functional-option path also makes the token
budget available to both direct encoding and document fills.

Shared fill batches must use the effective token-bound width when they split
work. Otherwise they can still exceed the provider limit even though direct
EncodeBatched calls enforce it.

Generated with OpenAI Codex
Co-authored-by: OpenAI Codex <noreply@openai.com>
@roborev-ci

roborev-ci Bot commented Aug 27, 2026

Copy link
Copy Markdown

roborev: Combined Review (4532ff0)

Verdict

One medium-severity configuration-handling issue was identified; no security vulnerabilities were found.

Medium

  • vector/flow.go:639-668 — Invalid token-budget configuration is treated as a per-document encoding error when no positive WithBatchSize is set. If WithFillEncodeError returns true, pending documents may be stamp-saved as skipped without vectors instead of the configuration being rejected. Validate token-budget options before document processing and bypass the per-document skip handler for configuration errors.

Reviewers: 2 done | Synthesis: codex, 5s | Total: 3m27s

Per-document fills discovered an invalid token budget inside EncodeBatched.
The document error handler could then treat that configuration failure as bad
content and stamp-skip a pending document without vectors.

Validate the batch configuration at the Fill boundary so configuration errors
cannot enter document-level recovery.

Generated with OpenAI Codex
Co-authored-by: OpenAI Codex <noreply@openai.com>
@roborev-ci

roborev-ci Bot commented Aug 27, 2026

Copy link
Copy Markdown

roborev: Combined Review (cfd24a0)

No issues found.


Reviewers: 2 done | Synthesis: codex | Total: 4m51s

@mariusvniekerk
mariusvniekerk merged commit e6c9ee3 into main Aug 27, 2026
10 checks passed
@mariusvniekerk
mariusvniekerk deleted the feat/vector-token-budget branch August 27, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant