Skip to content

Once I get an error I can't move on #4781

Closed as not planned
Closed as not planned

Description

@sai-sy

Description

I asked the model to get some images and perform some actions, it didn't properly get some images so I got this error:

image formats: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].```

That's fine I replaced the files in the directory with correct working image. But I can't move past the error:

```The image data you provided does not represent a valid image. Please check your input and try again with one of the supported
image formats: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].

finish task 3 in l9.md and send it to the server
sai (08:01 AM)

The image data you provided does not represent a valid image. Please check your input and try again with one of the supported
image formats: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].

okay don't use any image
sai (08:01 AM)

The image data you provided does not represent a valid image. Please check your input and try again with one of the supported
image formats: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Nov 26, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if your specific case involves different circumstances.

  2. self-assigned this
    on Nov 26, 2025
  3. rekram1-node commented on Nov 26, 2025

    @rekram1-node
    Collaborator

    Yeah ill fix this

  4. luisrudge commented on Jan 7, 2026

    @luisrudge

    having the same issue when OC tries to read a big image

    Image Image
  5. vaisov commented on Jan 26, 2026

    @vaisov

    It happens to me even without any image provided, no idea where it gets this from.

    Image
  6. rosspeoples commented on Feb 20, 2026

    @rosspeoples

    I've hit this twice so far. Both times it was debugging an issue, not even touching images, then just gets stuck:

    Image

    Now I have to try and figure what it was doing and convince it to continue in a new thread.

  7. kozak-codes commented on Mar 28, 2026

    @kozak-codes

    Any update on this? @BASIC-BIT ?

    My current fix is to open a new opencode thread and tell it to remove the b64 image from the history of that current thread. Willing to push a fix, but I frequently run into this problem when using the chrome MCP.

  8. kozak-codes commented on Mar 28, 2026

    @kozak-codes

    Additional context + reproduction steps

    This is a persistent session-poisoning bug. Once an invalid or oversized image gets stored in the message history, every subsequent request in that session fails with the same error — even if you tell the model to ignore images entirely. The bad image data is already baked into the context sent to the API on every turn.

    Root cause: OpenCode stores image attachments (base64-encoded) inside the part records in its local SQLite database (~/.local/share/opencode/opencode.db). When the API rejects an image, the offending data remains in the DB and gets replayed on every new message in that session.

    Two distinct error variants I've hit:

    1. image exceeds 5 MB maximum: X bytes > 5242880 bytes — full-page screenshots captured via the read tool on binary image files
    2. At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels — tall/long screenshots (e.g. full-page captures) where height exceeds 2000px
      Steps to reproduce:
    3. In a session, ask the model to take a screenshot or read an image file (e.g. via the read tool on a .png)
    4. If the image is either >5MB or has a dimension >2000px, the API returns a 400 error
    5. Send any follow-up message in the same session — the error repeats identically, regardless of content
    6. Telling the model to "ignore images" or "don't use images" has no effect — the bad attachment is already in the stored history

    Workaround (manual DB surgery):

    python3 << 'EOF'
    import sqlite3, json, base64, struct
    conn = sqlite3.connect('~/.local/share/opencode/opencode.db')
    cursor = conn.cursor()
    # Replace SESSION_ID with your session ID
    cursor.execute("SELECT id, data FROM part WHERE session_id = 'SESSION_ID'")
    rows = cursor.fetchall()
    def get_png_dimensions(b64_data):
        try:
            if ',' in b64_data:
                b64_data = b64_data.split(',', 1)[1]
            raw = base64.b64decode(b64_data[:100])
            if raw[:4] == b'\x89PNG':
                w = struct.unpack('>I', raw[16:20])[0]
                h = struct.unpack('>I', raw[20:24])[0]
                return w, h
        except:
            pass
        return None, None
    fixed = 0
    for part_id, data_str in rows:
        data = json.loads(data_str)
        state = data.get('state', {})
        attachments = state.get('attachments', [])
        bad = False
        for att in attachments:
            if att.get('mime', '').startswith('image/'):
                url = att.get('url', '')
                b64_size = len(url)
                w, h = get_png_dimensions(url)
                if b64_size > 5_000_000 or (w and (w > 2000 or h > 2000)):
                    bad = True
                    break
        if bad:
            data['state']['attachments'] = []
            cursor.execute("UPDATE part SET data = ? WHERE id = ?", (json.dumps(data), part_id))
            fixed += 1
    conn.commit()
    print(f"Stripped {fixed} bad image(s)")
    conn.close()
    EOF
    

    Expected behavior: The session should either (a) not store image attachments that exceed API limits in the first place, or (b) gracefully strip/skip bad attachments from history on retry rather than hard-failing every subsequent turn.

  9. added a commit that references this issue on Mar 28, 2026
    cd69363
  10. kozak-codes commented on Mar 28, 2026

    @kozak-codes

    @rekram1-node Did you end up fixing this? If not, see my related PR.

  11. zeke commented on Apr 10, 2026

    @zeke
    Contributor

    This bug has several duplicate/related issues open:

    The root cause is the same across all of them: oversized or invalid image data gets persisted in session history as base64 data URLs. Every subsequent API call replays the bad image, the provider rejects it, and the session is permanently stuck. Compaction can't help because it also replays the images (or has nothing to compact if it's early in the session).

    There are two open PRs:

    #19555 is the simplest path to stop sessions from bricking. Image resizing could be a follow-up.

    We have several people on our team hitting this regularly. It kills active sessions mid-task with no recovery path other than manual SQLite surgery or starting over. Would be great to get a maintainer review on #19555.

  12. removed
    bugSomething isn't working
    on May 3, 2026
  13. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  14. infomiho commented on Aug 3, 2026

    @infomiho

    I just hit this issue.

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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