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 摘要。