Skip to content

Claude/fix tool calling deepseek#1554

Open
farzanshibu wants to merge 6 commits intoPortkey-AI:2.0.0from
farzanshibu:claude/fix-tool-calling-deepseek
Open

Claude/fix tool calling deepseek#1554
farzanshibu wants to merge 6 commits intoPortkey-AI:2.0.0from
farzanshibu:claude/fix-tool-calling-deepseek

Conversation

@farzanshibu
Copy link
Copy Markdown

@farzanshibu farzanshibu commented Mar 5, 2026

This pull request introduces several important updates across the codebase, primarily focusing on improving type safety, adding support for DeepSeek tool calls, and correcting import paths. The most significant changes include enhancements to the DeepSeek provider to support tool calls, adjustments to type handling in Bedrock and DeepSeek response transforms, and standardization of import paths for the RealTimeLLMEventParser. Additionally, there are minor improvements to ensure robustness in logging logic. #1555

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

Claude AI and others added 3 commits March 4, 2026 19:05
Co-authored-by: farzanshibu <69754165+farzanshibu@users.noreply.github.com>
…ion types

- add ToolCall interface for DeepSeek function/tool payloads
- type DeepSeek response and stream chunks to use ToolCall instead of any[]
- keep only tools/tool_choice parameters (drop legacy functions/function_call)
- add comprehensive chat completion tests:
  - legacy function fields are not forwarded
  - strict OpenAI finish_reason mapping for insufficient_system_resource
  - non-strict finish_reason passthrough
  - stream finish_reason mapping in strict mode
Copilot AI review requested due to automatic review settings March 5, 2026 21:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates provider transforms and request configs to improve type-safety and add DeepSeek tool-calling support, while also standardizing the realtime event parser import path and hardening logging.

Changes:

  • Add tools / tool_choice support and tool-call passthrough to the DeepSeek chat completion provider (plus extensive unit tests).
  • Adjust finish-reason / stop-reason typing and transforms across providers (notably Bedrock ↔ Anthropic stop reasons).
  • Standardize RealTimeLLMEventParser import path casing and minor robustness tweaks in winky logging.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/services/winky/index.ts Hardens handling of missing ai_model when calculating redaction, pricing, and metrics labels.
src/providers/utils.ts Changes Anthropic stop-reason transform return type.
src/providers/deepseek/types.ts Introduces DeepSeek tool-call typing.
src/providers/deepseek/chatComplete.ts Adds tool-call support in request config and response/stream transforms.
src/providers/deepseek/tests/chatComplete.test.ts Adds DeepSeek provider coverage (params, tool calls, finish reasons, streaming).
src/providers/bedrock/messages.ts Adapts Bedrock Messages transforms to new stop-reason typing (currently via casts).
src/handlers/websocketUtils.ts Updates realtime parser import path.
src/handlers/realtimeHandlerNode.ts Updates realtime parser import path.
src/handlers/realtimeHandler.ts Updates realtime parser import path.
package-lock.json Updates lockfile (adds optional snappy native deps and modifies dev/optional flags).
Comments suppressed due to low confidence (1)

src/providers/utils.ts:99

  • transformToAnthropicStopReason now declares a | null return type, but the implementation never returns null (it always falls back to end_turn). This type change forces downstream as any/as string assertions and reduces type-safety. Either (a) revert the return type to ANTHROPIC_STOP_REASON or (b) actually return null in the cases where callers expect it and update call sites accordingly.
export const transformToAnthropicStopReason = (
  finishReason?: PROVIDER_FINISH_REASON
): ANTHROPIC_STOP_REASON | null => {
  if (!finishReason) return ANTHROPIC_STOP_REASON.end_turn;
  const transformedFinishReason = AnthropicFinishReasonMap.get(finishReason);
  if (!transformedFinishReason) {
    return ANTHROPIC_STOP_REASON.end_turn;
  }
  return transformedFinishReason;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@roh26it
Copy link
Copy Markdown
Collaborator

roh26it commented Mar 6, 2026

@farzanshibu - thanks for the PR! Can you address Copilot's comments?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@farzanshibu
Copy link
Copy Markdown
Author

@roh26it Please check

@narengogi narengogi changed the base branch from 2.0.0 to main March 24, 2026 12:56
@narengogi narengogi changed the base branch from main to 2.0.0 March 24, 2026 12:56
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.

4 participants