Skip to content

fix(transform): drop tool types DeepSeek cannot accept - #53

Open
davidyaaw wants to merge 1 commit into
yxlao:mainfrom
davidyaaw:fix/drop-unsupported-tool-types
Open

davidyaaw wants to merge 1 commit into
yxlao:mainfrom
davidyaaw:fix/drop-unsupported-tool-types

Conversation

@davidyaaw

Copy link
Copy Markdown

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_tool passes them through unchanged, and DeepSeek rejects the whole request:

tools[i].type: unknown variant `custom`, expected `function`

Fix

  • 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 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_choice are removed when nothing survives; a tool_choice pointing at a dropped tool is removed; a function tool without a name is dropped. pre-commit passes.

Related: #49

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
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