fix(rag): wire diff embed through EmbedConfig (closes #26) #27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/rag-diff-embed-cap"
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?
Summary
crates/ar-review/src/context_builder.rs: replace hardcoded 32 KiB diff-embed cap withEmbedConfig::from_env().input_cap_bytessoAR_EMBED_INPUT_CAP_BYTESgoverns every embed call. Default drops to 6 KiB (DEFAULT_EMBED_INPUT_CAP_BYTES), within the 8192-token ceiling oftext-embedding-3-smalleven on dense source. Symbol-embed pass now reuses the sameEmbedConfiginstead of re-reading env.crates/ar-review/src/diff.rs: addcap_for_embedhelper — strict byte-bounded truncation, no trailing marker (embeddings encode semantic content, the[truncated]tag only inflated token usage and added 2 bytes of overhead).Why
Closes #26. PR #25's review hit
HTTP 400: maximum input length is 8192 tokenson the diff-embedding call, the pipeline silently dropped RAG context, and the review came back with 0 findings after the severity floor dropped 9 candidates. Quality degraded with only aWARN. TheEmbedConfiginfrastructure introduced for #20 already governs per-symbol embed caps but never reached the diff-embed call site.Test plan
cargo nextest run --workspace --no-tests=pass(998/998 pass)cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warnings(no issues)cargo deny check licenses bans sources(ok)diff_embedding_input_is_capped_to_embed_config_defaultdrives a 256 KiB diff through the path and asserts the embedder saw <= 6 KiB.cap_for_embed's strict-bound, short-input, and UTF-8 boundary semantics.AR_EMBED_INPUT_CAP_BYTES=16384for richer diff context (still well under 8192 tokens for English-heavy diffs).References
EmbedConfig)jwilger/auto_review, PR #25This PR addresses issue #26 by replacing the hardcoded 32 KiB cap for diff embedding with a configurable cap using
EmbedConfig. This change prevents HTTP 400 errors due to exceeding token limits and ensures consistent embedding input sizes. The PR appears safe to merge, with comprehensive tests verifying the new behavior.Walkthrough
EmbedConfig::from_env().input_cap_bytesto ensure embedding input size is governed by environment configuration.embed_and_query_symbolsto acceptEmbedConfig, ensuring consistent configuration use.cap_for_embedfunction for strict byte-bound truncation without a trailing marker, optimizing token usage.Pre-merge checks