Skip to content

【DO NOT MERGE】fix(providers): stop sending media to SiliconFlow DeepSeek V4 - #7247

Closed
rayrayraykk wants to merge 1 commit into
agentscope-ai:mainfrom
rayrayraykk:investigate/windows-thinking-memory-v2
Closed

【DO NOT MERGE】fix(providers): stop sending media to SiliconFlow DeepSeek V4#7247
rayrayraykk wants to merge 1 commit into
agentscope-ai:mainfrom
rayrayraykk:investigate/windows-thinking-memory-v2

Conversation

@rayrayraykk

Copy link
Copy Markdown
Member

Summary

SiliconFlow discovers models dynamically with namespaced IDs such as deepseek-ai/DeepSeek-V4-Flash. The packaged text-only annotations only covered the separate deepseek provider and unnamespaced IDs, so the SiliconFlow models remained supports_multimodal=None.

Unknown capability intentionally fails open. As a result, every new model call cloned, formatted, JSON-encoded, and uploaded every historical screenshot in the session even though SiliconFlow's DeepSeek V4 Pro/Flash models are text-only. The current response does not need to contain an image: old tool-result images in the live session are enough to make a new request large before/while the UI shows Thinking.

This PR:

  • marks deepseek-ai/DeepSeek-V4-Flash and deepseek-ai/DeepSeek-V4-Pro as text-only for both siliconflow-cn and siliconflow-intl;
  • applies documentation annotations to dynamically discovered models, including during the discovery transaction, rather than only to configured models on a later restart;
  • preserves probed and user-configured capability values.

SiliconFlow's model catalog lists tool calling for these two models but does not list visual input; its visual models carry a separate visual-input capability: https://www.siliconflow.cn/models

User-visible failure chain

  1. One session accumulates screenshot DataBlocks across long agent/tool loops.
  2. SiliconFlow DeepSeek V4 remains capability-unknown because the dynamic namespaced ID does not match the existing baseline.
  3. Unknown fails open, so the OpenAI-compatible formatter retains all historical images.
  4. Each subsequent turn rebuilds and uploads the growing full-media request. Temporary formatter/JSON/HTTP allocations raise the process high-water RSS; CPython does not promptly return all arenas to the OS.
  5. A slow provider keeps the large request and streaming call alive longer. The UI can show only an unfinished Thinking block while the backend is under memory pressure.

This is independent of the two streaming fixes already merged today:

Both are valid, but neither prevents historical screenshots from entering a text-only SiliconFlow request. This PR does not drop tool chunks or change the SSE/frontend protocol.

Reproduction

The benchmark used the real QwenPaw OpenAI formatter, AgentScope OpenAIChatModel, and the OpenAI Python SDK against a local OpenAI-compatible streaming server. The server read the request without retaining it and returned reasoning deltas. Each simulated screenshot was a 1 MiB image in a historical ToolResultBlock; the same process made 15 calls while history grew from 4 to 60 images.

macOS, Python 3.12; values are backend RSS measured from the initialized model/session:

15-turn growing session Capability state Request body at 60 images RSS after turn 1 RSS after turn 15 Retained delta after GC Total elapsed
Before unknown → fail-open media 80.0 MiB 194.6 MiB 751.9 MiB +583.1 MiB 6.42 s
After documented text-only 24.5 KiB 177.5 MiB 180.0 MiB +10.7 MiB 4.14 s

A separate single-call boundary test with 130 historical images at 1.95 MiB each produced a 338.1 MiB request and +463.4 MiB client peak RSS before the fix. With media stripping, request size stays approximately constant (about 53 KiB for 130 history entries).

The mock is intentionally shaped like the reported workload: one session, historical screenshots/tool results, a new response that emits only reasoning, and an OpenAI-compatible DeepSeek endpoint. It does not rely on impossible concurrent unfinished tasks or cumulative provider deltas.

Scope of the 12 GiB observation

I reproduced the monotonic per-turn RSS growth mechanism and the text-only control removes it. I did not reproduce exactly 12 GiB on macOS, and no Windows heap dump is available, so this PR does not claim this is the only allocation source in that specific process. Reaching 12 GiB depends on the number/size of retained media blocks, repeated turns, allocator behavior, and in-flight provider latency. The reported Windows session had many screenshots and long agent loops, which is the workload this fix bounds.

ReMe auto-memory is not the source of these image bytes in 0.4.1.5: it removes Base64 data before session JSONL persistence, and its history prompt uses text content only.

Tests

  • Added discovery coverage for both SiliconFlow regions and both V4 model IDs.
  • Verified discovered models immediately receive supports_image=False, supports_video=False, supports_multimodal=False, and probe_source=documentation.
  • 163 passed, 1 skipped for SiliconFlow, capability catalog, and ProviderManager tests after rebasing onto current main.
  • 749 passed, 1 skipped across provider and formatter/message-normalization regression suites before the final rebase.
  • Pre-commit passed: JSON validation, mypy, black, flake8, pylint, and repository checks.

Copilot AI lite review requested due to automatic review settings August 24, 2026 09:19
@github-project-automation github-project-automation Bot moved this to Todo in QwenPaw Aug 24, 2026
@github-actions

Copy link
Copy Markdown

Welcome to QwenPaw! 🐾

Hi @rayrayraykk, this is your 260th Pull Request.

🎁 Milestone Celebration

🏆🏆🎖️🏅 Congratulations! This is your 260th contribution. Thank you for your continued support! You're an important member of the QwenPaw community! 🐾

📋 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes excessive request growth and memory pressure when using SiliconFlow’s dynamically discovered DeepSeek V4 models by ensuring the packaged “text-only” capability annotations apply to namespaced model IDs (e.g. deepseek-ai/DeepSeek-V4-*) immediately during the discovery transaction. This prevents historical screenshot/media blocks from being included in subsequent text-only requests when capability was previously None (fail-open).

Changes:

  • Add SiliconFlow (siliconflow-cn and siliconflow-intl) capability-baseline entries marking deepseek-ai/DeepSeek-V4-Flash and deepseek-ai/DeepSeek-V4-Pro as non-visual (text-only).
  • Apply documentation-based annotations to discovered models (and do so during discovery snapshot persistence), while preserving probed and already-configured capability values.
  • Add regression tests covering both SiliconFlow regions and both DeepSeek V4 namespaced IDs to ensure discovered models are immediately annotated as text-only.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/unit/providers/test_siliconflow_provider.py Adds discovery regression tests asserting DeepSeek V4 discovered models are annotated as text-only with probe_source=documentation.
src/qwenpaw/providers/provider_manager_discovery.py Applies capability annotations to the discovery snapshot before it is merged/persisted, so discovered models are corrected immediately.
src/qwenpaw/providers/provider_annotations.py Extends annotation application to include discovered_models in addition to configured models.
src/qwenpaw/providers/data/model_capabilities.json Updates catalog version/date and adds text-only capability expectations for the SiliconFlow DeepSeek V4 Flash/Pro model IDs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rayrayraykk rayrayraykk changed the title fix(providers): stop sending media to SiliconFlow DeepSeek V4 【DO NOT MERGE】fix(providers): stop sending media to SiliconFlow DeepSeek V4 Aug 24, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in QwenPaw Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants