Estimate the uploaded image of /v1/images/edits requests #4054
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 352 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.351
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4054"
general
weight: 0.35
ahg-g
What type of PR is this?
/kind feature
What this PR does / why we need it:
The images-edits parser discarded the uploaded
imagefile part, so the request's image-to-image conditioning input carried zero estimated tokens: an edit with a 4K input image weighed the same as one with a thumbnail, and only the prompt text reached the in-flight token load.The parser now captures the image part as
UploadedMedia— byte size, leading bytes for header sniffing, content type, and a content hash — without retaining the body, which is forwarded byte-for-byte. The estimate backend decodes the image's dimensions from the retained head (image.DecodeConfig; PNG/JPEG/GIF already registered for the chat path) and appends the same image multimodal feature chatimage_urlparts produce:wh/factorplaceholder tokens behind the conditioning text, falling back to the default resolution for undecodable headers. Requests without an image part (/v1/images/generationsshares the typed body) estimate the text alone, exactly as before.Note on overlap with #3964: this PR introduces
UploadedMedia,parseMultipartForm,readUploadedMedia, andappendMMAssetHashverbatim from the transcriptions PR, because it is based onmainrather than stacked. Whichever PR merges first, the other's overlapping hunks become no-ops on rebase.Which issue(s) this PR fixes:
Fixes #4053
Release note _(write
NONEif no user-facing change)_:``
release-note
`The token-producer estimates the input cost of /v1/images/edits requests from the uploaded image: pixel dimensions decoded from the image header produce placeholder tokens (wh/1024 by default, configurable through the existing estimate.image config), falling back to the default resolution for undecodable headers. The uploaded body is not retained and is forwarded unchanged; /v1/images/generations requests are unaffected.
Test plan:
) is ignored, and a request without an image part leaves the captured media at its zero valueplaceholder tokens as an image feature behind the conditioning text, counted in the request's tokens with the content hashmake presubmit
passes (fmt, lint, security, govulncheck, boilerplate, telemetry, latest-tags).verify-review-playbookfails identically on cleanmain(unroutedpkg/common/grpc/files, pre-existing);go test ./pkg/epp/...` is green.