Conversation
When a GPT-named model is selected, Cursor sends OpenAI-only free-form tools
(`{"type": "custom", ...}`). DeepSeek rejects the whole request with
`tools[i].type: unknown variant custom, expected function`.
- keep only `type: "function"` tools that have a function name; drop the
rest and log a warning with their names
- remove `tools` entirely when nothing survives
- remove `tool_choice` when it points at a dropped tool or is not a
recognized function choice
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
When a GPT-named model is selected in Cursor (for example, to route it through the non-DeepSeek fallback rewrite), Cursor sends OpenAI-only free-form tools:
{"type": "custom", "name": "apply_patch", "description": "..."}normalize_toolpasses them through unchanged, and DeepSeek rejects the whole request:Fix
type: "function"tools that have a function name. Drop the rest and log a warning with their names.toolsentirely when nothing survives.tool_choicewhen it forces a tool that was dropped, or when it isn't a recognized function choice. Otherwise DeepSeek would reject that too.Function tools are not changed.
Tests
Four new cases in
tests/test_transform.py: a custom tool is dropped with a warning;tools/tool_choiceare removed when nothing survives; atool_choicepointing at a dropped tool is removed; a function tool without a name is dropped.pre-commitpasses.Related: #49