Skip to content

fix(gemini): convert PDF to text in functionResponse parts to prevent API errors#2035

Closed
echoVic wants to merge 4 commits intoQwenLM:mainfrom
echoVic:fix/pdf-function-response
Closed

fix(gemini): convert PDF to text in functionResponse parts to prevent API errors#2035
echoVic wants to merge 4 commits intoQwenLM:mainfrom
echoVic:fix/pdf-function-response

Conversation

@echoVic
Copy link
Copy Markdown
Contributor

@echoVic echoVic commented Mar 2, 2026

Fixes #2020

Converts PDF content to text description in functionResponse parts to prevent Gemini API 400 errors.

Changes

  • Convert PDF file references to text descriptions in function responses
  • Prevents API errors when PDFs are passed as function results

Testing

  • Verified that PDF files are properly converted to text descriptions

echoVic added 4 commits March 1, 2026 11:19
QwenLM#2025)

- Trim skill name in validateToolParams to handle cases where model adds extra whitespace
- Update params.skill with trimmed value for consistent usage throughout the tool
- Add test cases for leading/trailing whitespace and Chinese skill names

Fixes QwenLM#2025
… API errors (QwenLM#2020)

- Add PDF (application/pdf) to unsupported media types in convertUnsupportedMediaToText
- This prevents 'Invalid value: file' API errors when reading PDF files
- PDF content in tool responses is now converted to explanatory text
- Add test cases for PDF inlineData and fileData conversion

Fixes QwenLM#2020
…l names (QwenLM#2012)

- Add 'bash' and 'sh' to ToolNamesMigration as aliases for run_shell_command
- Migrate legacy tool names in CoreToolScheduler before registry lookup
- This fixes 'Tool "bash" not found in registry' errors when models use common aliases
- Add test case for tool name migration

Fixes QwenLM#2012
@tanzhenxin
Copy link
Copy Markdown
Collaborator

@echoVic Thanks for your contribution! This issue has been resolved and merged in #1982 already, close it for now.

@tanzhenxin tanzhenxin closed this Mar 4, 2026
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.

[Bug] Failed to read PDF file and then became unavailable w/ red error message "API Error: 400"

2 participants