openclaw - 💡(How to fix) Fix [Feature]: Expose inbound image attachments as local file paths for agent tool use [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#52243Fetched 2026-04-08 01:13:47
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

Root Cause

  • #49111 (ACP runtime image handling — closed, different root cause)
  • #16595 (mediaLocalRoots for outbound message tool — related concept)
  • #42641 (image tool accessing Telegram media files)

Fix Action

Fix / Workaround

Current Workaround

RAW_BUFFERClick to expand / collapse

Feature Description

When a user sends an image to an agent via a messaging channel (Signal, Telegram, WebChat, etc.), the agent can receive and understand the image content through the vision model. However, the agent has no way to access the image as a local file for downstream operations such as:

  • Uploading to GitHub Issues (via gh CLI)
  • Forwarding to another service or API
  • Saving to a workspace directory for later reference
  • Attaching to an outbound message on a different channel

Currently, inbound images are processed inline by the model pipeline, but no local file path or workspace-accessible copy is exposed to the agent's tool environment.

Use Case

As a DevLead agent managing GitHub issues, I receive bug report screenshots from my user via Signal/WebChat. I can analyze the image and describe it, but I cannot attach it to the GitHub issue I create — defeating the purpose of visual bug reports.

Proposed Solution

When an inbound message contains image attachments:

  1. Save each image to a well-known directory (e.g. ~/<agent-workspace>/attachments/ or a configurable mediaLocalRoots path)
  2. Expose the local file path(s) to the agent session, either:
    • As a system-injected context variable (e.g. {{attachments.[0].path}})
    • Via a dedicated tool (e.g. attachment_list returning [{name, path, mimeType, size}])
    • As metadata in the message object accessible through session tools
  3. Clean up expired attachments based on a configurable TTL

Current Workaround

The user must manually upload the image to a server path and tell the agent where it is — which negates the benefit of integrated messaging.

Related Issues

  • #49111 (ACP runtime image handling — closed, different root cause)
  • #16595 (mediaLocalRoots for outbound message tool — related concept)
  • #42641 (image tool accessing Telegram media files)

Environment

  • OpenClaw Gateway on Linux (x64)
  • Channel: WebChat / Signal
  • Agent runtime: native (non-ACP)

extent analysis

Fix Plan

To address the issue, we will implement the proposed solution by modifying the agent's message processing pipeline. Here are the concrete steps:

  • Save image attachments: Create a new directory ~/<agent-workspace>/attachments/ to store incoming image attachments. Use a unique filename for each image, e.g., image_<timestamp>_<message_id>.<extension>.
  • Expose local file path: Inject a system variable {{attachments.[0].path}} into the agent session, containing the local file path of the saved image attachment.
  • Clean up expired attachments: Implement a TTL (time-to-live) mechanism to delete attachments older than a configurable threshold (e.g., 30 days).

Example Code

import os
import datetime

# Define the attachments directory
attachments_dir = os.path.join(os.path.expanduser('~'), '<agent-workspace>', 'attachments')

# Create the directory if it doesn't exist
if not os.path.exists(attachments_dir):
    os.makedirs(attachments_dir)

# Function to save image attachment
def save_image_attachment(message):
    # Get the image data and filename
    image_data = message['image_data']
    filename = f"image_{datetime.datetime.now().strftime('%Y%m%d%H%M%S')}_{message['id']}.jpg"
    filepath = os.path.join(attachments_dir, filename)

    # Save the image to the attachments directory
    with open(filepath, 'wb') as f:
        f.write(image_data)

    # Inject the file path into the agent session
    message['attachments'] = [{'path': filepath, 'name': filename, 'mimeType': 'image/jpeg', 'size': len(image_data)}]

    return message

# Function to clean up expired attachments
def clean_up_attachments(ttl_days=30):
    # Get the current timestamp
    now = datetime.datetime.now()

    # Iterate through the attachments directory
    for filename in os.listdir(attachments_dir):
        filepath = os.path.join(attachments_dir, filename)
        # Get the file timestamp
        file_timestamp = datetime.datetime.fromtimestamp(os.path.getctime(filepath))

        # Check if the file is older than the TTL
        if (now - file_timestamp).days > ttl_days:
            # Delete the file
            os.remove(filepath)

# Call the clean up function periodically (e.g., daily)
clean_up_attachments()

Verification

To verify that the fix worked, test the following scenarios:

  • Send an image attachment to the agent via WebChat or Signal.
  • Check that the image is saved to the ~/<agent-workspace>/attachments/ directory.
  • Verify that the agent session has access to the local file path of the saved image attachment via the {{attachments.[0].path}} variable.
  • Test the clean up mechanism by sending an image attachment and waiting for the TTL to expire. The attachment should be

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Feature]: Expose inbound image attachments as local file paths for agent tool use [1 participants]