Skip to content

fix(providers): filter streaming image results to prevent duplicates - #790

Merged
haiphucnguyen merged 2 commits into
askimo-ai:mainfrom
toktokbr:feature/prevent-gemini-generate-duplicate-images
Oct 31, 2026
Merged

haiphucnguyen merged 2 commits into
askimo-ai:mainfrom
toktokbr:feature/prevent-gemini-generate-duplicate-images

Conversation

@toktokbr

Copy link
Copy Markdown
Contributor

Summary

This mitigates an issue where the upstream Gemini provider returns duplicate image objects during streaming sessions.

Related Issue(s)

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactor (no functional change)
  • 🧪 Tests
  • 🔧 Chore / tooling / CI

What Changed & Why

In the recent Gemini models, it generates the double images, one is draft and one is final. We keep the final image only. If gemini only generate one image, we do not filter it out

How to Test

./gradlew test

Screenshots / Recordings (if applicable)

Checklist

  • I have read the CONTRIBUTING guide
  • My branch is up to date with main
  • I ran ./gradlew spotlessApply and ./gradlew detekt locally
  • I ran ./gradlew test and all tests pass
  • I added/updated tests for my changes (if applicable)
  • I added/updated documentation (if applicable)
  • My commits are signed off (DCO) — git commit -s
  • This PR is focused on a single feature/fix

Additional Notes

- Process the finalized image list instead of raw generated images to ensure uniqueness in the streamed response.
- Wrap the streaming callback for image data in a try-catch block to prevent exceptions in consumer code from interrupting the main execution flow.

@haiphucnguyen haiphucnguyen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you @toktokbr for this PR. Perhaps we should check this logic apply for Gemini only?

@toktokbr

Copy link
Copy Markdown
Contributor Author

Thank you @toktokbr for this PR. Perhaps we should check this logic apply for Gemini only?

@haiphucnguyen Updated per feedback. Thanks!

@haiphucnguyen haiphucnguyen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you @toktokbr !

@haiphucnguyen
haiphucnguyen merged commit df8d55e into askimo-ai:main Oct 31, 2026
12 checks passed
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.

2 participants