anthropics / anthropics/claude-agent-sdk-python

Invalid tool_use.id format during session resume causes API 400 error

未关闭
#856 0 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
8.1k
派生
1.3k
平均合并
2 天 31 分钟
30 天内合并 PR
1

描述

claude-agent-sdk version 0.1.61

---
Bug: SDK generates invalid tool_use.id during session resume

Problem

The Claude Agent SDK generates tool_use.id values in the format functions.{ToolName}:{N}
(e.g., functions.AskUserQuestion:1), which contain . and : characters that violate the API's
validation pattern ^[a-zA-Z0-9_-]+$. On session resume, these historical messages are
replayed verbatim, causing a 400 error.

Evidence

API error:
messages.7.content.1.tool_use.id: String should match pattern '^[a-zA-Z0-9_-]+$'

Invalid IDs found in request body (captured via LLM proxy):
functions.AskUserQuestion:1 — contains '.' and ':'
functions.AskUserQuestion:2 — contains '.' and ':'
functions.AskUserQuestion:4 — contains '.' and ':'
functions.AskUserQuestion:5 — contains '.' and ':'

Valid IDs from the same session (different code path):
call_360410d3f1444f978a42a482 — valid
call_5d86f36491e247039a0aec00 — valid

Failing message (messages[7]):
{
"role": "assistant",
"content": [
{"type": "text", "text": "..."},
{"type": "tool_use", "id": "functions.AskUserQuestion:1", "name": "AskUserQuestion",
"input": {...}}
]
}

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。