anthropics / anthropics/claude-agent-sdk-python

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

Open
#856 0 comments 4 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
8.1k
Forks
1.3k
Avg merge
2d 31m
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.