#8042·QwenPaw

Bug: Tool output files are auto-fed back to model as input, causing Internal error when model does not support the file format

Author: wocall88Created Sep 30, 2026Updated Sep 30, 2026

Bug: Tool output files (e.g., generated PDFs) are automatically fed back into the model as input, causing "Internal error" when model doesn't support the format

Environment

  • QwenPaw Hub version: 2.2.1
  • QwenPaw runtime image: 2.2.1 (image ID 4127130c41f4)
  • Channel: WeCom (wecom)
  • Model: Any non-multimodal model (e.g., deepseek-v4.1-flash, text-only LLM)
  • Deployment: Hub mode with Docker provisioner

Summary

When the agent generates a file (e.g., PDF via LibreOffice) using a tool like write_file or execute_shell_command, that generated file is subsequently included in the model's input context as a file or document content block. When the model does not support that file format (PDF), the API returns:

Error code: 400
{
  "error": {
    "message": "InvalidParameter: The current model does not support PDF file input.",
    "type": "invalid_request_error",
    "code": "invalid_parameter_error"
  }
}

This bubbles up to the WeCom user as a generic "Internal error" message, with no useful diagnostic information.

Reproduction Steps

  1. Use any text-only model (e.g., deepseek-v4.1-flash, gpt-3.5-turbo)
  2. Send a document (docx, xlsx, txt) to the agent via WeCom
  3. In the agent's response, instruct it (or let it decide) to:
    • Process the document
    • Generate an output file (PDF via LibreOffice, image via pdftoppm, etc.)
    • Send the output file to the user via send_file_to_user
  4. Agent successfully generates and sends the file to WeCom ✓
  5. However, QwenPaw's runtime also includes that generated file as type=document (or type=file) in the next model call's input
  6. The model rejects the call with HTTP 400 (does not support PDF file input)
  7. Runtime logs the error and returns "Internal error" to the WeCom user

Observed Behavior (from runtime logs)

03:52:51  send_file_to_user: docx  ✓ (sent to WeCom)
03:53:56  send_file_to_user: pdf   ✓ (sent to WeCom)
03:54:43  ERROR: unhandled error session=wecom:...
          Error code: 400 - 'current model does not support PDF file input'
03:54:43  ERROR: channel _stream_with_tracker failed
03:54:44  ERROR: run error run_key=...
03:54:44  User sees: "Internal error"

Root Cause

In the runtime pipeline, when a tool returns a file path (e.g., the result of write_file, execute_shell_command that creates a PDF), the file's contents are read back and attached to the conversation context as a type=document content block. This happens automatically for any file referenced in a tool result, regardless of whether the file was intended for the user or for further processing.

Specifically:

  1. Tool returns success with output: {"file_path": "/path/to/output.pdf"}
  2. Runtime reads the PDF file
  3. Runtime attaches it as a type=document block in the next model input
  4. Model receives the PDF as input → 400 error
  5. User sees only "Internal error"

Suggested Fix

The runtime should distinguish between:

Scenario Behavior
Tool output is a file intended for the model (e.g., analysis result) Attach as type=document (current behavior, OK)
Tool output is a file intended for the user (send_file_to_user) Attach a text reference only (filename, size), NOT file contents

Concretely:

  • When the agent calls send_file_to_user, the file content should NOT be fed back into the model
  • The model should see only metadata (e.g., "已发送文件 /path/to/output.pdf 给用户") or just a tool result confirmation

Workaround (current deployments)

  • Use only multimodal models that support PDF input (e.g., qwen-vl-max, gpt-4o)
  • Or configure agents to NEVER generate binary files in chat flows

Impact

  • Severity: Medium (broken user-facing functionality)
  • Affected: All Hub deployments using text-only models + WeCom channel where agents generate files
  • Frequency: Common (any agent that generates PDFs, images, or Office documents via shell commands)

Related Code Paths

  • qwenpaw/runtime/runtime.py:185 — error handler
  • qwenpaw/app/channels/base.py:1038 — channel error wrapper
  • qwenpaw/app/channels/wecom/channel.py:781-985 — WeCom channel send_file_to_user logic
  • File attachment logic appears to live in the runtime's tool-result-to-context conversion

Additional Notes

This is the same issue users would hit with any "send a file to user" tool, not just WeCom. The fix should be at the runtime level (QwenPaw core), not the channel level.

Thanks for looking into this!