Skip to content

agent: Add image generation appfunction#25

Open
calebareeveso wants to merge 2 commits into
android:mainfrom
calebareeveso:agent-image-gen
Open

agent: Add image generation appfunction#25
calebareeveso wants to merge 2 commits into
android:mainfrom
calebareeveso:agent-image-gen

Conversation

@calebareeveso

Copy link
Copy Markdown
Contributor

What I have done and why

This PR adds an image generation AppFunction to the Agent demo app so the agent can generate images based on user requests.

Key Changes

  • Image Generation Function (generateImage): Added a new built in AppFunction that calls the Gemini API (gemini-3.1-flash-image-preview ) to generate images from user prompts.
  • Secure Image Sharing (FileProvider): Configured FileProvider ( ${applicationId}.fileprovider ) to save generated images safely to local disk and share them using secure content:// URIs.
  • General Media Attachments (MessageAttachment ): Updated Room database ( AppDatabase v3) and MessageEntity to store structured media attachments with exact MIME types.
  • Chat UI Card Rendering: Updated AgentDemoScreen so generated images render as distinct image cards below the message text bubble instead of relying on raw JSON output or Markdown string injection.
  • Unit Tests: Added unit tests for database attachment serialization (MessageAttachmentConverterTest) and orchestrator attachment extraction (AgentOrchestratorTest )

Change-Id: Ie5a3a97c4dc2eefe349f0df22313f2bc12fcfe01

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces image generation capabilities to the AI assistant. It adds a new generateImage built-in AppFunction that integrates with the Gemini API, configures a FileProvider to cache and serve generated images, updates the database schema to support message attachments, and enhances the UI to display these attachments. Feedback on the changes highlights two critical issues: first, the aspectRatio parameter in the image generation function is currently ignored in the API payload; second, passing the generated content:// URIs to other apps without explicitly granting read permissions will result in a SecurityException.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Change-Id: Ie3fbb88ae72223cc9b1fb29ca226fdc045200104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant