Skip to content

fix(gateway): ignore MEDIA examples without local files#16436

Open
qwertysc wants to merge 1 commit into
NousResearch:mainfrom
qwertysc:fix/media-extract-existing-files
Open

fix(gateway): ignore MEDIA examples without local files#16436
qwertysc wants to merge 1 commit into
NousResearch:mainfrom
qwertysc:fix/media-extract-existing-files

Conversation

@qwertysc

Copy link
Copy Markdown

Summary

  • Ignore MEDIA: tags inside fenced code blocks and inline code.
  • Only extract MEDIA: paths for native delivery when the expanded local file exists.
  • Preserve skipped MEDIA: examples in text instead of removing them or attempting delivery.

Root cause

BasePlatformAdapter.extract_media() treated any MEDIA:<path> token as a real attachment directive. Code snippets, grep output, and test examples containing MEDIA:/tmp/missing.png were therefore sent through native media delivery and produced noisy File not found warnings.

What changed

  • Builds code spans for fenced and inline code and skips matches inside them.
  • Validates candidate paths with os.path.isfile() before adding them to the media list.
  • Removes only accepted delivery tags from the outgoing text; skipped examples remain visible.
  • Updates gateway media extraction tests to use real temp files for positive cases and adds coverage for missing files / code examples.

Tests

  • python -m pytest tests/gateway/test_media_extraction.py tests/gateway/test_platform_base.py -q -o 'addopts='

Verification

  • Verified that existing local media files are still extracted and removed from text.
  • Verified that missing paths, fenced-code examples, and inline-code examples are not extracted and are preserved.

Fixes #16434

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

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway should not treat MEDIA examples or missing files as attachments

2 participants