Skip to content

[Bug/错误]: anthropic入站&anthropic出站会丢失请求体顶层的cache_control参数 #1484

@koast18

Description

@koast18

Pre-submission Checklist / 提交前检查

  • I have searched the existing issues and this bug has not been reported / 我已搜索现有 issues,此 Bug 尚未被报告
  • I have read the documentation / 我已阅读文档
  • I am using the latest version of AxonHub / 我正在使用 AxonHub 的最新版本

Bug Description / Bug 描述

入站请求

curl 'http://axonhub.local/v1/messages' \
  -H 'Accept: application/json' \
  -H 'X-Api-Key: ******' \
  -H 'User-Agent: axonhub/1.0' \
  -H 'Content-Type: application/json' \
  -H 'Anthropic-Version: 2023-06-01' \
  -d '{"model":"claude-opus-4-6","top_p":0.95,"stream":false,"messages":[{"role":"user","content":"Hi"}],"max_tokens":22280,"temperature":1,"cache_control":{"type":"ephemeral"}}'

出站请求

curl 'http://upstream.local/proxy/or-anthropic/v1/messages' \
  -H 'Accept: application/json' \
  -H 'X-Api-Key: ******' \
  -H 'User-Agent: axonhub/1.0' \
  -H 'Content-Type: application/json' \
  -H 'Anthropic-Version: 2023-06-01' \
  -d '{"model":"anthropic/claude-opus-4.6","top_p":0.95,"stream":false,"messages":[{"role":"user","content":"Hi"}],"max_tokens":22280,"temperature":1}'

可以发现cache_control这个参数丢失了,似乎是MessageRequest这个struct没有顶层的cache_control字段,go的默认行为是直接丢弃它? 导致在JSON反序列化的时候就丢失了。

Steps to Reproduce / 复现步骤

Expected Behavior / 期望行为

希望这里也能走cache_control标记重建的那个管线。

Error Message / 错误消息

Operating System / 操作系统

Linux (Ubuntu/Debian) / Linux(Ubuntu/Debian)

AxonHub Version / AxonHub 版本

v0.9.37

Usage Scenario / 使用场景

API

API Format / API 格式

Anthropic - Messages (/v1/messages) / Anthropic Messages

Channel Type / 渠道类型

Anthropic / Anthropic

Logs / 日志

Additional Context / 其他补充信息

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions