Skip to content

Handle None in tool/function arguments. #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

kanaka
Copy link

@kanaka kanaka commented Jun 11, 2025

The normal OpenAI API returns an empty string when there are no function arguments. The GitHub Copilot wrapper around the OpenAI API seems to return None instead of an empty string when there are no arguments.

Treat None as an empty string. If we still have an empty string at the point that we parse the JSON for the arguments, then use "{}" instead so that we get the expected empty map.

This patch is for supporting the full function of this PR: jmdaly/llm-github-copilot#18 But either can be merged in any order, the two together enable tool calling of anthropic models via github copilot plugin (openai tool calling via github copilot's API works without this patch).

@kanaka
Copy link
Author

kanaka commented Jun 20, 2025

Hi @simonw. The llm-github-copilot plugin PR just got merged (jmdaly/llm-github-copilot#18). Any chance you might be able to do a quick review and merge of this so that tool calling with Github Copilot + Claude models will work? This change should be fully backwards compatible.

The normal OpenAI API returns an empty string when there are no function
arguments. The GitHub Copilot wrapper around the OpenAI API seems to
return None instead of an empty string when there are no arguments.

Treat None as an empty string. If we still have an empty string at the
point that we parse the JSON for the arguments, then use "{}" instead so
that we get the expected empty map.
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