Repository navigation
fix(harness): classify Qwen invalid PDF file payload rejection - #26
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Qwen-compatible endpoint (Aliyun MaaS compat-mode) rejects a request whose
type: "file"part carries bytes that are not a valid PDF:MEDIA_REJECTION_PHRASEShas no phrase matching that message, soopenai_providerraises a genericLLMErrorinstead ofLLMUnsupportedContentError. 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_contentfile block):file_data→ HTTP 400 atcreate(), for streaming and non-streaming alike; the streaming 400 body is the raw SSE line quoted above;So the endpoint supports
fileparts; 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"toMEDIA_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 asdata: {...}(streaming 400 bodies) orError code: 400 - {...}need no separate sample.Checks
ruff check src tests— passedmypy src— passedpytest— 2770 passed, 3 skipped