Skip to main content

Overview

Kortix agents can see and analyze images, enabling visual understanding for tasks like UI recreation, diagram analysis, screenshot interpretation, and visual content extraction. The vision capability loads images into the conversation context and makes them accessible to the AI model. Images are automatically compressed, converted to supported formats (SVG→PNG), and uploaded to cloud storage for efficient processing.

Core Function

Load Image

Loads an image into conversation context for AI analysis. Supports both local files and URLs.

Image Context Management

Hard Limit: Maximum 3 images can be loaded in context at any time. Each image consumes 1000+ tokens.
From the source code (sb_vision_tool.py:46-86):

Automatic Context Management

From sb_vision_tool.py:464-472:
When the 3-image limit is reached, older images are automatically cleared to make room.

Supported Formats

  • JPEG/JPG: Standard photo format
  • PNG: Lossless format with transparency
  • GIF: Animated images (animations preserved)
  • WEBP: Modern efficient format
  • SVG: Vector graphics (automatically converted to PNG)
Image Files Only: This tool is ONLY for actual image files. For PDFs and documents, use read_file instead.

Real-World Examples

Example 1: UI Recreation from Screenshot

Example 2: Diagram Analysis

Example 3: Data Extraction from Chart

Example 4: Multiple Image Comparison

Implementation Details

Image Compression

From sb_vision_tool.py:171-279:
Compression settings:
  • Max dimensions: 1920x1080
  • JPEG quality: 85
  • PNG compression: Level 6
  • Max original size: 10 MB
  • Max compressed size: 5 MB

SVG Conversion

From sb_vision_tool.py:98-169:
SVG files are converted using:
  1. Primary: Chromium browser rendering (highest quality)
  2. Fallback: svglib + reportlab (if browser fails)

Cloud Storage Upload

From sb_vision_tool.py:429-463:
Images are stored in Supabase with:
  • Unique timestamped filenames
  • Public access for LLM
  • Original filename preserved in metadata

Format Validation

From sb_vision_tool.py:420-427:
Only formats supported by Claude are allowed.

Image Context Format

Images are added to conversation context in OpenAI format:

Download from URL

From sb_vision_tool.py:286-321:

When to Keep vs Clear Images

Keep Images Loaded When:

  • User wants to recreate/rebuild what’s in the image
  • Writing code based on image content (UI, diagrams, wireframes)
  • Editing or iterating on image content
  • Task requires active visual reference
  • In middle of multi-step task involving the image

Clear Images When:

  • Task is complete and images no longer needed
  • User moves to different topic unrelated to images
  • You only needed to extract information/text (already done)
  • Reached 3-image limit and need to load new images

Best Practices

1. Only Load Actual Images

2. Manage the 3-Image Limit

3. Keep Images During Active Work

4. Optimize for Token Usage

Limitations

  • Max images in context: 3 simultaneous images
  • Max file size: 10 MB original, 5 MB compressed
  • Max dimensions: Resized to 1920x1080 if larger
  • Token cost: ~1000+ tokens per image
  • Supported formats: JPEG, PNG, GIF, WEBP (SVG converted)
  • PDF not supported: Use read_file for PDFs

Configuration

Vision capabilities require:
Without GEMINI_API_KEY, SVG conversion falls back to svglib (lower quality).

Image Files Remain in Sandbox

Clearing images from context only removes them from the conversation. The actual image files remain in the sandbox at their original paths and can be reloaded anytime.