Skip to content

fix: enable image paste in Agent sessions#14173

Open
brettschneider wants to merge 2 commits intoCherryHQ:mainfrom
brettschneider:fix/agent-image-paste
Open

fix: enable image paste in Agent sessions#14173
brettschneider wants to merge 2 commits intoCherryHQ:mainfrom
brettschneider:fix/agent-image-paste

Conversation

@brettschneider
Copy link
Copy Markdown

Summary

This PR fixes the image paste functionality in Agent sessions. Previously, images were not being sent to the model - only file paths were included as text.

Changes Made

  1. API Schema (agents/index.ts): Added optional images field to CreateSessionMessageRequest swagger docs
  2. Frontend Inputbar (AgentSessionInputbar.tsx):
    • Read image files as base64 using FileManager
    • Separate images from other file types
    • Create image blocks for UI display
    • Pass images in the dispatch
  3. Message Thunk (messageThunk.ts):
    • Added images to AgentSessionContext type
    • Include images in API request body
  4. Type Definitions (agent.ts): Added images field to CreateSessionMessageRequestSchema
  5. Backend Service (SessionMessageService.ts): Pass images to claudeCodeService.invoke instead of hardcoded undefined

How It Works

  • Images are detected by checking file type (starts with image/) or file extension
  • Image files are read as base64 data using FileManager.readBase64File()
  • Non-image files still have their paths appended to the message text
  • Images are sent to the API via the new images field in the request body
  • The backend processes images through the existing resizeImageIfNeeded logic

Testing

  • Tested with screenshots (PNG)
  • Tested with JPEG images
  • Tested mixed images + text files
  • Type checking passes
  • Lint checking passes

Related Issue

Fixes #14171

The apiModelAdapter function was not preserving user-defined model capabilities
when adapting API models for use in Agent mode. This caused vision capabilities
(and other user-defined capabilities) to be lost when using models in Agent
sessions, even though they worked correctly in Assistant mode.

The fix looks up the model in the Redux store and copies the capabilities
property if found, ensuring that user-defined settings are preserved.

This addresses the issue where Ollama models with manually enabled vision
showed \"model does not support images\" in Agent mode despite working in
Assistant mode.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Add images field to CreateSessionMessageRequest API schema
- Read image files as base64 in AgentSessionInputbar
- Pass images through message thunk to API
- Update SessionMessageService to pass images to ClaudeCodeService

Fixes CherryHQ#14171
@brettschneider brettschneider force-pushed the fix/agent-image-paste branch from 9e8cedb to 1764cbe Compare April 11, 2026 02:27
@EurFelux
Copy link
Copy Markdown
Collaborator

Hi, thanks for your work! However, this PR is essentially a feature, not a fix. We are currently undergoing a large-scale architectural change from main to v2, and no new features are being accepted on the main branch—only critical fixes. Moreover, since the architecture is still in flux, I also do not recommend that you develop this feature on the v2 branch at this time.

@EurFelux EurFelux added the Blocked: v2 The PR is blocked until v2 released label Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blocked: v2 The PR is blocked until v2 released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Image paste does not work in Agent sessions

2 participants