Skip to content

fix(harness): classify Qwen invalid PDF file payload rejection - #26

Merged
ygyang11 merged 1 commit into
mainfrom
fix/qwen-file-payload-rejection
Sep 18, 2026
Merged

ygyang11 merged 1 commit into
mainfrom
fix/qwen-file-payload-rejection

Conversation

@ygyang11

Copy link
Copy Markdown
Owner

Problem

A Qwen-compatible endpoint (Aliyun MaaS compat-mode) rejects a request whose type: "file" part carries bytes that are not a valid PDF:

data: {"error":{"code":"invalid_parameter_error","param":null,"message":"Input file must be a valid PDF","type":"invalid_request_error"},"id":"chatcmpl-..."}

MEDIA_REJECTION_PHRASES has no phrase matching that message, so openai_provider raises a generic LLMError instead of LLMUnsupportedContentError. The agent-level self-heal (agent/base.py, which strips the offending tool-run attachments and retries once) therefore never fires and the whole run fails.

Evidence

Probed against the live endpoint with the exact wire shape the provider emits (_render_user_content file block):

  • invalid PDF bytes in file_data → HTTP 400 at create(), for streaming and non-streaming alike; the streaming 400 body is the raw SSE line quoted above;
  • the same request carrying a structurally valid minimal PDF → 200 OK.

So the endpoint supports file parts; only the payload was invalid, which is exactly the case the self-heal path exists for.

Change

  • src/agent_harness/utils/media.py: add "must be a valid pdf" to MEDIA_REJECTION_PHRASES (placed in the existing file-payload cluster).
  • tests/unit/test_harness/test_utils/test_media.py: one provider sample for the message above.

Matching stays narrow on purpose: "must be a valid pdf" covers the observed prefix variants without catching unrelated 400s. The matcher is a plain substring test on the lowercased error string, so wrappers such as data: {...} (streaming 400 bodies) or Error code: 400 - {...} need no separate sample.

Checks

  • ruff check src tests — passed
  • mypy src — passed
  • pytest — 2770 passed, 3 skipped

@ygyang11
ygyang11 merged commit d0f1076 into main Sep 18, 2026
5 checks passed
@ygyang11
ygyang11 deleted the fix/qwen-file-payload-rejection branch September 18, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant