#2577·CopilotKit

Bug/FR: Image Uploads Not Forwarded to AG-UI Agents (PydanticAI)

Author: danialtCreated Oct 4, 2025Updated Sep 28, 2026
Labelsbug

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

  1. Enable image uploads: <CopilotSidebar imageUploadsEnabled={true} />
  2. Connect to a PydanticAI agent via HttpAgent and AG-UI protocol
  3. Upload an image in the chat (drag/drop, paste, or file picker)
  4. Send a message asking about the image (e.g., "What's in this image?")
  5. 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:

  1. Converted from CopilotKit's format to AG-UI protocol format
  2. Included in the HTTP request to the AG-UI endpoint
  3. Delivered to the agent in a format it can process (e.g., PydanticAI's BinaryContent or ImageUrl)
  4. 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

typescript
import { CopilotSidebar } from "@copilotkit/react-ui";

<CopilotSidebar
  imageUploadsEnabled={true}
  inputFileAccept="image/*"
  // ... other props
/>

Backend Setup (PydanticAI)

python
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

typescript
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 ✅

  1. Image upload UI: Images are successfully captured as base64 with format metadata
  2. Image rendering: Uploaded images display correctly in the chat UI
  3. Direct model capability: PydanticAI with Gemini 2.5 Pro can process images when provided as ImageUrl or BinaryContent objects
  4. Image URLs as workaround: Sharing image URLs in chat messages works (agent can download and analyze them)

What's Missing ❌

  1. AG-UI protocol image forwarding: The AG-UI/HttpAgent adapter doesn't convert or forward uploaded images to the backend
  2. 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):

typescript
const imageSrc = `data:image/${image.format};base64,${image.bytes}`;

Images are captured as:

typescript
{
  format: string,  // e.g., "png", "jpeg"
  bytes: string    // base64 encoded image data
}

Backend Expected Format (PydanticAI):

python
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.ts
  • src/lib/runtime/remote-actions.ts
  • src/lib/runtime/copilot-runtime.ts
  • src/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

  1. Is image forwarding through AG-UI protocol planned?
  2. Should the HttpAgent convert CopilotKit's image format to the agent framework's expected format?
  3. 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!