Skip to content

fix(message_processing): return resolved path for file:// URL audio blocks#4021

Merged
qbc2016 merged 1 commit intoagentscope-ai:mainfrom
karls0r:fix/audio-file-url-resolution
May 6, 2026
Merged

fix(message_processing): return resolved path for file:// URL audio blocks#4021
qbc2016 merged 1 commit intoagentscope-ai:mainfrom
karls0r:fix/audio-file-url-resolution

Conversation

@karls0r
Copy link
Copy Markdown
Contributor

@karls0r karls0r commented May 3, 2026

Summary

Fixes audio (and any media) blocks delivered with {"type": "url", "url": "file://..."} source: the local path was extracted correctly via url2pathname() but then unconditionally overwritten by download_file_from_url(), which is HTTP-only and returns None for file:// URLs. As a result _process_single_file_block returned None for file:// audio blocks, _process_audio_block was never invoked, and the agent saw the raw audio block instead of a transcribed text.

Setup that reproduces it

  • QwenPaw v1.1.5 / current main
  • Telegram channel
  • audio_mode = "auto"
  • A working OpenAI-compat Whisper provider (any /v1/audio/transcriptions endpoint)

Send a voice message; the workspace media file lands in ~/.qwenpaw/workspaces/<agent>/media/<id>.oga. The constructed audio block has source = {"type": "url", "url": "file:///.../<id>.oga"}. Without this fix, the LLM receives that audio block raw instead of the transcribed [Voice message]: ....

Relation to #1896

Orthogonal. PR #1896 normalises data{"type": "url", "url": "file://..."} for blocks that arrive without a source dict. After that normalisation lands, _process_single_file_block still drops the resulting file:// URL on the floor — that's what this PR fixes. Both can land independently; the audio pipeline only works end-to-end with both.

Change

src/qwenpaw/agents/utils/message_processing.py — for the parsed.scheme == "file" branch, return the resolved local path immediately instead of falling through to download_file_from_url(). Six added lines, no removals, no behaviour change for HTTP URLs.

Tests

Happy to add unit coverage for _process_single_file_block (currently uncovered) if that helps the review — let me know if you'd prefer the PR to grow.

Issue

Confirmed in #1516 (comment).

🤖 Authored with Claude Code (Ren, Anthropic Claude Opus 4.7) — final review and submission by @karls0r.

…locks

In `_process_single_file_block`, when a media block's source has
`{"type": "url", "url": "file://..."}`, the local path was correctly
extracted via `urllib.request.url2pathname()` but then immediately
overwritten by an unconditional call to `download_file_from_url(url, ...)`,
which is HTTP-only and returns `None` for `file://` URLs.

Net effect: `_process_single_file_block` returned `None` for
`file://` audio blocks, `_process_audio_block` was never reached, and
the agent received the raw audio block instead of a transcribed text.

Symptom: Telegram voice messages with `audio_mode="auto"` and a
configured Whisper provider stayed unparsed at the LLM, even though
the transcription provider was reachable and the workspace media
file existed locally.

This is orthogonal to PR agentscope-ai#1896 (which normalises `data` -> `source`
for blocks that lack a `source` dict). Once agentscope-ai#1896 hands a proper
`{"type": "url", "url": "file://..."}` source to this function, the
present bug still swallows it; both fixes are needed independently.

Fix: short-circuit the file:// branch with `return local_path`
immediately after `url2pathname()` succeeds, so the HTTP downloader
is never called for local-file URLs.

Co-Authored-By: Ren (Claude) <noreply@anthropic.com>
@github-project-automation github-project-automation Bot moved this to Todo in QwenPaw May 3, 2026
@github-actions github-actions Bot added the first-time-contributor PR created by a first time contributor label May 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

Welcome to QwenPaw! 🐾

Hi @karls0r, thank you for your first Pull Request! 🎉

📋 About PR Template

To help maintainers review your PR faster, please make sure to include:

  • Description - What this PR does and why
  • Type of Change - Bug fix / Feature / Breaking change / Documentation / Refactoring
  • Component(s) Affected - Core / Console / Channels / Skills / CLI / Documentation / Tests / CI/CD / Scripts
  • Checklist:
    • Run and pass pre-commit run --all-files
    • Run and pass relevant tests (pytest or as applicable)
    • Update documentation if needed
  • Testing - How to test these changes
  • Local Verification Evidence:
    pre-commit run --all-files
    # paste summary result
    
    pytest
    # paste summary result

Complete PR information helps speed up the review process. You can edit the PR description to add these details.

🙌 Join Developer Community

Thanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page:
https://qwenpaw.agentscope.io/docs/community

We truly appreciate your enthusiasm—and look forward to your future contributions! 😊

We'll review your PR soon.


Tip

⭐ If you find QwenPaw useful, please give us a Star!

Star QwenPaw

Staying ahead

Star QwenPaw on GitHub and be instantly notified of new releases.

Your star helps more developers discover this project! 🐾

@xieyxclack
Copy link
Copy Markdown
Member

@qbc2016 Please help review this pr

Copy link
Copy Markdown
Member

@qbc2016 qbc2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@qbc2016 qbc2016 merged commit 534d8ba into agentscope-ai:main May 6, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in QwenPaw May 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Welcome to QwenPaw! 🎉

Thank you @karls0r for your first contribution! Your PR has been merged. 🚀

We'd love to give you a shout-out in our release notes! If you're comfortable sharing, please reply to this comment with your social media handles using the format below:

discord: your_discord_handle
x: your_x_handle
xiaohongshu: your_xiaohongshu_id

Note: Only share what you're comfortable with — all fields are optional.

Thanks again for helping make QwenPaw better!

cofly-io pushed a commit to cofly-io/xClaw that referenced this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time-contributor PR created by a first time contributor Under Review

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants