Skip to content

  • 项目
  • 群组
  • 代码片段
  • 帮助
  • 当前项目
    • 正在载入...
  • 登录 / 注册
B
bit-pm
  • 项目
    • 项目
    • 详情
    • 活动
    • 周期分析
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 图表
    • 比较
    • 统计图
  • 议题 0
    • 议题 0
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 0
    • 合并请求 0
  • CI / CD
    • CI / CD
    • 流水线
    • 作业
    • 日程
    • 统计图
  • Wiki
    • Wiki
  • 代码片段
    • 代码片段
  • 成员
    • 成员
  • 折叠边栏
  • 活动
  • 图像
  • 聊天
  • 创建新问题
  • 作业
  • 提交
  • 问题看板
  • 燕伟桐
  • bit-pm
  • Repository

切换分支/标签
  • bit-pm
  • src
  • __tests__
  • ai_messages_utils.test.ts
查找文件
BlameHistoryPermalink
  • wwwillchen-bot's avatar
    fix: sanitize tool-call inputs to prevent LiteLLM invalid dict error (#2890) · d8774673
    由 wwwillchen-bot 提交于 3月 05, 2026
    should fix #2879.
    
    ## Summary
    - Add defensive sanitization ensuring tool-call `input` fields are
    always valid objects (at minimum `{}`) before messages reach the
    Anthropic API
    - Prevents LiteLLM from sending empty strings as `tool_use.input` when
    converting OpenAI→Anthropic format, which causes `400
    invalid_request_error: Input should be a valid dictionary`
    - Adds sanitization in two locations: `cleanMessageForOpenAI` (stored
    messages) and `maybeCaptureRetryReplayEvent` (stream replay events)
    
    ## Context
    This is a known LiteLLM bug pattern (issues
    [#5063](https://github.com/BerriAI/litellm/issues/5063),
    [#15322](https://github.com/BerriAI/litellm/issues/15322),
    [#19061](https://github.com/BerriAI/litellm/issues/19061)). When
    `function.arguments` is empty or malformed, LiteLLM's `json.loads()`
    fails and falls back to passing the raw string as `input`, which
    Anthropic rejects.
    
    ## Test plan
    - [x] Added 3 new unit tests for `cleanMessageForOpenAI` covering empty
    string, null, and valid inputs
    - [x] All 847 existing tests pass
    - [x] Lint, format, and type checks pass
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    <!-- devin-review-badge-begin -->
    
    ---
    
    <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2890"
    target="_blank">
      <picture>
    <source media="(prefers-color-scheme: dark)"
    srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
    <img
    src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
    alt="Open with Devin">
      </picture>
    </a>
    <!-- devin-review-badge-end -->
    
    ---------
    Co-authored-by: 's avatarWill Chen <willchen90@gmail.com>
    Co-authored-by: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    d8774673
ai_messages_utils.test.ts 21.5 KB
编辑Web IDE

Replace ai_messages_utils.test.ts

拖放文件到此处或者 点击上传


取消
将在派生(fork)项目中中创建一个新的分支, 并开启一个新的合并请求。