fix(copilot): reject unresolved image references - #7297
Open
j15z wants to merge 1 commit into
Open
Conversation
Require every declared image reference to resolve and load before calling Gemini, while preserving text-only generation when inputs are omitted.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
10 tasks
Contributor
Greptile SummaryThis PR makes image-reference handling fail closed so declared references cannot be silently omitted before provider invocation.
Confidence Score: 5/5The PR appears safe to merge because declared image references now fail before provider invocation unless every reference resolves, passes the model-safety boundary, and is readable. The generated contract, runtime guard, workspace-scoped resolution, safety check, and focused tests consistently preserve prompt-only generation while preventing partial or silently dropped image-reference requests.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/copilot/tools/server/image/generate-image.ts | Replaces best-effort reference loading with all-or-nothing validation and defers provider initialization until every declared image is loaded. |
| apps/sim/lib/copilot/tools/server/image/generate-image.test.ts | Adds focused coverage for valid text-to-image behavior and the principal reference-loading success and failure paths. |
| apps/sim/lib/copilot/generated/tool-catalog-v1.ts | Declares that a supplied generate-image inputs object must contain at least one file. |
| apps/sim/lib/copilot/generated/tool-schemas-v1.ts | Mirrors the non-empty reference-file contract in the generated runtime schema. |
Sequence Diagram
sequenceDiagram
participant C as Copilot
participant T as generate_image
participant W as Workspace files
participant G as Gemini
C->>T: prompt + optional inputs.files
alt inputs supplied without files
T-->>C: Reject before provider call
else direct uploads/... path
T-->>C: Require save_upload and files/... path
else references declared
loop Every reference
T->>W: Resolve, safety-check, and read
alt Any reference fails
W-->>T: Resolution/read error
T-->>C: Reject entire request
else Reference loads
W-->>T: Image bytes and MIME type
end
end
T->>G: All references + prompt
G-->>T: Generated image
T-->>C: Saved workspace image
else inputs omitted
T->>G: Prompt only
G-->>T: Generated image
T-->>C: Saved workspace image
end
Reviews (1): Last reviewed commit: "fix(copilot): reject unresolved image re..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
generate_imagedeclares reference files, Sim now either loads every reference or fails before calling Gemini. A missing or unreadable image can no longer be silently dropped and turn an intended image edit into an unrelated text-only generation. Text-to-image remains unchanged wheninputsis omitted.This supersedes #5615. The existing production
save_uploadflow already promotes uploads to canonical workspace files, so this replacement preserves that boundary instead of makinguploads/...a second first-class media path.Related contract and agent-guidance change: https://github.com/simstudioai/mothership/pull/465
Type of Change
Changes
inputs.filesarray.uploads/...references with guidance to usesave_uploadand the returnedfiles/...path.generate_image.inputs.filescontract.Testing
cd apps/sim && bun run test lib/copilot/tools/server/image/generate-image.test.ts lib/copilot/tools/server/media/model-boundaries.test.ts— 14 tests passed.bunx biome checkpassed for all four changed Sim files.bun run check:api-validationpassed.git diff --checkpassed.The repository-wide typecheck is currently blocked by unrelated existing dependency drift, including missing
@sim/deployment-configand browser-protocol packages. Filtering its diagnostics produced no errors for the changed image-generation or generated-contract files.Post-Deploy Monitoring & Validation
GenerateImageToollogs forFailed to load reference image,inputs.files must contain at least one, andsave_uploadguidance.referenceImageCount >= 1, while text-to-image calls continue succeeding with noinputsobject.Checklist
Screenshots / Videos
Not applicable; this is a server-side runtime and generated-contract change.