Skip to content

fix(gateway): stop bare local paths from being uploaded in post-stream media delivery#20843

Open
liuhao1024 wants to merge 3 commits into
NousResearch:mainfrom
liuhao1024:fix/post-stream-media-bare-paths
Open

fix(gateway): stop bare local paths from being uploaded in post-stream media delivery#20843
liuhao1024 wants to merge 3 commits into
NousResearch:mainfrom
liuhao1024:fix/post-stream-media-bare-paths

Conversation

@liuhao1024

@liuhao1024 liuhao1024 commented May 6, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Remove the extract_local_files() call from GatewayRunner._deliver_media_from_response() so that only explicit MEDIA: directives trigger file uploads after streaming completes.

Root Cause

_deliver_media_from_response() mixed two behaviors:

  1. Explicit: Extract MEDIA: directives from the response → upload intended files
  2. Implicit: Extract bare local file paths from cleaned response text → upload unintended files

The implicit path (extract_local_files(cleaned)) caused the gateway to upload files whose paths happened to appear in tool output or assistant text, even when the final visible reply contained no attachment directive.

This is especially dangerous in streaming mode because:

  • The user-visible text has already been streamed/sanitized
  • The post-stream helper reparses the full response
  • Hidden/internal/tool-derived path strings get promoted into real uploads

Related Issue

N/A

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • See commit messages for detailed changes

How to Test

  1. Run pytest tests/ -q — all tests should pass
  2. Verify the specific scenario described above is resolved

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.4.1

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture and workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A

liuhao1024 and others added 3 commits April 24, 2026 22:14
…INSTALL_TIMEOUT

Increase the default npm install timeout for WhatsApp bridge from 60s
to 300s (5 minutes) to accommodate slower systems like Unraid NAS.
Make it configurable via WHATSAPP_NPM_INSTALL_TIMEOUT environment variable
for users who need even longer timeouts.

Closes NousResearch#14980
- Add 'path', 'old_string', 'new_string', and 'patch' to required list
- Update description to clarify mode-specific parameter requirements
- This addresses issue where LLMs would omit these parameters because
  they were not marked as required in the schema, even though they
  are required depending on the mode

Fixes NousResearch#15524
…m media delivery

Remove extract_local_files() call from _deliver_media_from_response()
so that only explicit MEDIA: directives trigger file uploads after
streaming. Bare local paths mentioned in tool output or response text
are no longer promoted into attachments.

Fixes NousResearch#20834
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 P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants