sgl-project/sglang · error · ValueError
Anthropic redacted_thinking history is not supported
Error message
Anthropic redacted_thinking history is not supported
What it means
Raised while converting an Anthropic request to the internal chat-completion format: an assistant message in the conversation history contains a redacted_thinking block (Anthropic's encrypted, opaque thinking blocks), which SGLang cannot re-encode because it lacks Anthropic's encryption keys/context. The whole request is rejected rather than silently corrupting history.
Source
Thrown at python/sglang/srt/entrypoints/anthropic/serving.py:386
def _convert_assistant_thinking_blocks(
blocks: list[AnthropicContentBlock],
) -> tuple[Optional[str], Optional[str]]:
"""Reconstruct prior-turn thinking as ``(reasoning_content, text)``.
At most one is set: encoders that frame the reasoning channel take
it as ``reasoning_content``, everything else gets it re-wrapped and
spliced into content.
``redacted_thinking`` carries encrypted bytes that no local
parser can interpret, so we raise rather than silently drop it.
On non-reasoning models (no detector configured) the rewrap is
best-effort: we log a warning and drop the thinking text so a
history echo doesn't 400 the whole request — the prior thinking
is opaque context the model didn't need anyway.
"""
if any(block.type == "redacted_thinking" for block in blocks):
raise ValueError("Anthropic redacted_thinking history is not supported")
thinking_parts = [
block.thinking
for block in blocks
if block.type == "thinking" and block.thinking
]
if not thinking_parts:
return None, None
reasoning_text = "\n".join(thinking_parts)
if self.openai_serving_chat.supports_native_reasoning_history():
return reasoning_text, None
try:
return None, self.openai_serving_chat.wrap_reasoning_history(
reasoning_text
)
except ValueError as e:View on GitHub (pinned to 0132848349)
Solutions
- Strip redacted_thinking blocks from assistant history before sending (the code already drops plain 'thinking' text best-effort; redacted blocks must be removed client-side)
- Regenerate the history from plain text/transcript instead of raw Anthropic response objects
- If using an Anthropic SDK passthrough of prior responses, filter content blocks to types text/tool_use only
Example fix
# before
messages = [{"role": "assistant", "content": prior_anthropic_response_content}]
# after
messages = [{
"role": "assistant",
"content": [b for b in prior_anthropic_response_content
if b.get("type") not in ("redacted_thinking", "thinking")]
}] Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"text", "tool_use", "image", "document"}
for msg in messages:
if msg.get("role") == "assistant" and isinstance(msg.get("content"), list):
msg["content"] = [b for b in msg["content"] if b.get("type") in SUPPORTED] Type guard
def has_redacted_thinking(messages) -> bool:
return any(b.get("type") == "redacted_thinking"
for m in messages if isinstance(m.get("content"), list)
for b in m["content"]) Try / catch
try: resp = client.messages.create(...)
except ValueError as e:
if 'redacted_thinking' in str(e): strip_history_and_retry() Prevention
- Never replay raw Anthropic response blocks as history
- Store a normalized transcript, not the API response
When it happens
Trigger: POST /v1/messages where messages[] contains an assistant turn whose content includes {"type": "redacted_thinking", "data": "..."} — typically captured from a previous real Anthropic API response that was replayed as history.
Common situations: Replaying or continuing conversations originally served by Anthropic's API (which emits redacted_thinking for some safety-flagged thinking); logging request/response pairs and feeding them back; agent frameworks that store raw Anthropic responses as history.
Related errors
- tool_choice references tool {tool_name!r} but it is not in t
- tool_choice={tc_type!r} requires at least one custom tool; a
- thinking.budget_tokens must be >= 1024 (got {})
- thinking.budget_tokens is not allowed when thinking.type is
- thinking.display is not allowed when thinking.type is 'disab
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/4e1f5cd469e2c521.
Report an issue: GitHub.