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": {...}}
]
}
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": {...}}
]
}