Bug/FR: Image Uploads Not Forwarded to AG-UI Agents (PydanticAI)
Bug Report: Image Uploads Not Forwarded to AG-UI Agents (PydanticAI)
Description
When using imageUploadsEnabled={true} with CopilotKit's AG-UI protocol (specifically with PydanticAI agents via HttpAgent), uploaded images are captured in the UI but not forwarded to the backend agent.
Steps to Reproduce
- Enable image uploads:
<CopilotSidebar imageUploadsEnabled={true} /> - Connect to a PydanticAI agent via
HttpAgentand AG-UI protocol - Upload an image in the chat (drag/drop, paste, or file picker)
- Send a message asking about the image (e.g., "What's in this image?")
- Observe agent's response
Current Behavior
- ✅ Image successfully uploads and appears in the chat UI as a thumbnail
- ✅ Image is stored as base64 with format metadata (
{format: "png", bytes: "..."}) - ✅ Message with text is sent to the backend
- ❌ Image data is NOT included in the request to the AG-UI agent
- ❌ Agent receives only the text message, not the image
- ❌ Agent responds saying it cannot process images
Example agent response:
"I am sorry, I cannot answer that question. I do not have the ability to process images."
Expected Behavior
When a user uploads an image and sends a message, the image data should be:
- Converted from CopilotKit's format to AG-UI protocol format
- Included in the HTTP request to the AG-UI endpoint
- Delivered to the agent in a format it can process (e.g., PydanticAI's
BinaryContentorImageUrl) - The agent should receive and be able to analyze the image content
Environment
- CopilotKit Version: 1.10.5
- Agent Framework: PydanticAI 1.0.10 with AG-UI protocol
- Agent Backend: HttpAgent pointing to PydanticAI AG-UI endpoint
- Model: Google Gemini 2.5 Pro (supports multimodal/vision)
Code Example
Frontend Setup
import { CopilotSidebar } from "@copilotkit/react-ui";
<CopilotSidebar
imageUploadsEnabled={true}
inputFileAccept="image/*"
// ... other props
/>Backend Setup (PydanticAI)
from pydantic_ai import Agent
from pydantic_ai.models.google import GoogleModel
agent = Agent(
model=GoogleModel('gemini-2.5-pro'),
system_prompt="You can analyze images..."
)
app = agent.to_ag_ui()API Route
import { CopilotRuntime } from "@copilotkit/runtime";
import { HttpAgent } from "@ag-ui/client";
const runtime = new CopilotRuntime({
agents: {
"my_agent": new HttpAgent({ url: "http://localhost:8000/" }),
}
});Investigation Findings
What Works ✅
- Image upload UI: Images are successfully captured as base64 with format metadata
- Image rendering: Uploaded images display correctly in the chat UI
- Direct model capability: PydanticAI with Gemini 2.5 Pro can process images when provided as
ImageUrlorBinaryContentobjects - Image URLs as workaround: Sharing image URLs in chat messages works (agent can download and analyze them)
What's Missing ❌
- AG-UI protocol image forwarding: The AG-UI/HttpAgent adapter doesn't convert or forward uploaded images to the backend
- No image data in agent requests: Debug logs show no image data in HTTP requests to the AG-UI endpoint
Code Evidence
Frontend Image Storage (node_modules/@copilotkit/react-ui/src/components/chat/messages/ImageRenderer.tsx):
const imageSrc = `data:image/${image.format};base64,${image.bytes}`;Images are captured as:
{
format: string, // e.g., "png", "jpeg"
bytes: string // base64 encoded image data
}Backend Expected Format (PydanticAI):
from pydantic_ai import Agent, BinaryContent, ImageUrl
# Works when called directly
result = agent.run_sync([
'What company is this logo from?',
ImageUrl(url='https://example.com/image.png'),
])
# Or with binary content
result = agent.run_sync([
'What company is this logo from?',
BinaryContent(data=image_bytes, media_type='image/png'),
])Gap: CopilotKit's AG-UI adapter doesn't convert the frontend image format to PydanticAI's expected format.
Searched Locations
I checked the following files in @copilotkit/runtime for image handling:
src/lib/runtime/agui-action.tssrc/lib/runtime/remote-actions.tssrc/lib/runtime/copilot-runtime.tssrc/service-adapters/openai/utils.ts(only handles OpenAI format)
No image forwarding logic found for AG-UI adapters.
Comparison with Other Adapters
The OpenAI service adapter has image handling logic, but AG-UI adapters do not. This suggests image support is implemented for direct LLM adapters but not for the AG-UI protocol bridge.
Temporary Workaround
Users can share publicly accessible image URLs instead of uploading:
User: "What's in this image? https://example.com/photo.jpg"The agent can then download and analyze the image via URL, but this can be hit and miss with some LLM providers.
Questions
- Is image forwarding through AG-UI protocol planned?
- Should the HttpAgent convert CopilotKit's image format to the agent framework's expected format?
- Is there an existing way to enable this that I'm missing?
Related Issues
- #1756 (Feature Request: File Uploads) - mentions general file upload support
However, I'm not familiar enough with the AG-UI protocol specification to know if this is the correct approach.
Is this a known limitation, or am I missing something in my setup? Any guidance would be appreciated!
Source: CopilotKit/CopilotKit