Skip to content

fix: skip vision calls for non-sendable image URLs - #2463

Merged
syzsunshine219 merged 1 commit into
MemTensor:dev-v2.0.36from
Wang-Daoji:fix/skip-invalid-image-url
Oct 8, 2026
Merged

syzsunshine219 merged 1 commit into
MemTensor:dev-v2.0.36from
Wang-Daoji:fix/skip-invalid-image-url

Conversation

@Wang-Daoji

Copy link
Copy Markdown
Collaborator

Relative markdown paths such as images/.jpg were forwarded to the vision API and rejected as invalid base64.

Description

Please include a summary of the change, the problem it solves, the implementation approach, and relevant context. List any dependencies required for this change.

Related Issue (Required): Fixes #issue_number

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

.venv/bin/pytest tests/mem_reader/test_image_parser.py -q
.venv/bin/pytest tests/mem_reader/ -q
  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

Reviewer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed
  • Tests have been provided

Relative markdown paths such as images/<hash>.jpg were forwarded to the vision API and rejected as invalid base64.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Memtensor-AI Memtensor-AI added area:memory 记忆存储、检索、更新、召回逻辑 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Oct 8, 2026
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2463
Task: 5347c502fcc03698
Base: dev-v2.0.36
Head: fix/skip-invalid-image-url

🔍 OpenCodeReview found 2 issue(s) in this PR.


1. tests/mem_reader/test_image_parser.py (L73-L74)

len(result) == 1 alone does not prove the mocked "memory list" entry was consumed. In image_parser.py the "memory list" branch and the no-memory-list fallback (response_json.get("summary", ...)) each return exactly one item, and the mock's summary is non-empty, so a regression that ignores "memory list" entirely would still yield one item and still pass this assertion. Assert something that only the parsed path can produce, e.g. the item's memory value (and/or metadata.memory_type). Since _parse_json_result's degradation path and the empty/malformed-response fallbacks are untested here, a malformed-JSON case would cover them too.

💡 Suggested Change

Before:

    assert len(result) == 1
    llm.generate.assert_called_once()

After:

    assert len(result) == 1
    assert result[0].memory == "A product label is visible."
    llm.generate.assert_called_once()

2. tests/mem_reader/test_image_parser.py (L75-L76)

This hard-coded index chain encodes the exact internal layout of the prompt (first positional arg, message 0, content block 1). It works today, but any legitimate refactor of the message list — inserting a system/instruction block, reordering text before the image, or passing messages as a keyword argument — turns this into an opaque IndexError/KeyError, which reads as a broken test rather than a URL-forwarding regression. Selecting the image block by its type keeps the assertion tied to behavior and survives layout changes.

💡 Suggested Change

Before:

    sent_url = llm.generate.call_args.args[0][0]["content"][1]["image_url"]["url"]
    assert sent_url == url

After:

    sent_parts = llm.generate.call_args.args[0][0]["content"]
    sent_url = next(p["image_url"]["url"] for p in sent_parts if p["type"] == "image_url")
    assert sent_url == url

Generated by cloud-assistant via Open Code Review.

@syzsunshine219
syzsunshine219 merged commit 1827738 into MemTensor:dev-v2.0.36 Oct 8, 2026
18 of 19 checks passed
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

⚠️ Automated Test Results: NO TEST SCOPE

Automated tests were not run because the changed files do not map to an executable test scope.

Details: No executable test scope maps to the changed files. Automated tests were not run; add env.yaml source_mapping + execution for this path family, then rerun. Changed files: (none detected)
Manual review or env.yaml source_mapping/execution coverage is required before merge.

Branch: fix/skip-invalid-image-url

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

Labels

area:memory 记忆存储、检索、更新、召回逻辑 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants