RAG diff embedding skipped on large PRs: 32 KiB byte cap exceeds 8192-token model limit #26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
On PR #25 the gateway logged:
The pipeline swallowed the error and continued without RAG context. The review subsequently posted with
findings=0after the severity floor dropped 9 candidate findings — quality silently degraded with only aWARN.Root cause
crates/ar-review/src/context_builder.rs:112-113hardcodes the diff-embedding cap as bytes:OpenAI's
text-embedding-3-smallrejects any input over 8192 tokens. The 32 KiB byte cap is a rough match for English prose, but Rust diffs (dense in identifiers, punctuation, leading whitespace) routinely exceed 8192 tokens well below 32 KiB. PR #25 is the proof.The
EmbedConfiginfrastructure introduced by #20 (PR #21) exists for exactly this knob —AR_EMBED_INPUT_CAP_BYTESwithDEFAULT_EMBED_INPUT_CAP_BYTES = 6 KiB, seecrates/ar-index/src/embed.rs:45. But the diff-embedding path incontext_builder.rswas never wired through it. So operators raising/loweringAR_EMBED_INPUT_CAP_BYTESchange symbol embedding caps without touching the diff query cap.Proposed fix
EMBED_QUERY_CAPincontext_builder.rswithEmbedConfig::from_env().input_cap_bytes(or pass anEmbedConfigthrough the call site, matching howembed_symbols_with_configalready works).num_ctx=2048already need to drop to ~6 KiB; OpenAI users with the 8192-token model should land closer to 16 KiB. TheEmbedConfigdefault of 6 KiB is fine as the conservative floor.skip RAG and continuepath is fine as a fallback but a halve-and-retry would recover most cases without operator tuning.Acceptance
wiremock'd 8192-token boundary, or by replaying PR #25 with the new default).AR_EMBED_INPUT_CAP_BYTESoverrides the diff-embedding cap, not just the symbol-embedding cap.WARN ar_review::context_builder: diff embedding failedentries for PR diffs the size of #25.References
jwilger/auto_review, PR #25crates/ar-review/src/context_builder.rs:99-120EmbedConfig+AR_EMBED_*)