Skip to content

Feature: Store images as path references instead of base64 in session history #16358

@elegansn2

Description

@elegansn2

Problem

When users send images via Discord/Telegram, OpenClaw:

  1. Saves the image file to ~/.openclaw/media/inbound/
  2. Also embeds the full base64 data in the session .jsonl file ← Problem

This causes:

  • A 972KB PNG becomes 1.15MB in session history (base64 overhead)
  • Session files grow rapidly (3.3MB+ with just a few images)
  • Context window fills up quickly since the base64 is loaded into LLM context
  • Images cannot be pruned by contextPruning since they're part of user messages

Current Behavior

// In session .jsonl
{
  "type": "message",
  "message": {
    "role": "user",
    "content": [
      {"type": "text", "text": "..."},
      {"type": "image", "data": "iVBORw0KGgo...(1MB base64)...", "mimeType": "image/png"}
    ]
  }
}

Proposed Solution

Store images as path references:

{
  "type": "image",
  "path": "/Users/.../.openclaw/media/inbound/xxx.png",
  "mimeType": "image/png"
}

When loading context:

  • If image is recent (within TTL): read from disk and include
  • If image is old: replace with placeholder like [Image: screenshot.png - pruned]

Additional Enhancement

After image analysis, optionally replace base64 with text summary:

{"type": "image_summary", "text": "[Screenshot showing terminal with sessions.json file size of 5.6MB]"}

Environment

  • OpenClaw 2026.2.12
  • macOS
  • Discord channel

Impact

This would significantly reduce:

  • Session file sizes
  • Context consumption
  • API costs (fewer tokens for images that don't need re-analysis)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions