{"record":{"id":"d3b8cdccff39ef07","repo":"microsoft/autogen","slug":"unknown-content-type","errorCode":null,"errorMessage":"Unknown content type","messagePattern":"Unknown content type","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.Anthropic/Converters/ContentBaseConverter.cs","lineNumber":32,"sourceCode":"        using var doc = JsonDocument.ParseValue(ref reader);\n        if (doc.RootElement.TryGetProperty(\"type\", out JsonElement typeProperty) && !string.IsNullOrEmpty(typeProperty.GetString()))\n        {\n            string? type = typeProperty.GetString();\n            var text = doc.RootElement.GetRawText();\n            switch (type)\n            {\n                case \"text\":\n                    return JsonSerializer.Deserialize<TextContent>(text, options) ?? throw new InvalidOperationException();\n                case \"image\":\n                    return JsonSerializer.Deserialize<ImageContent>(text, options) ?? throw new InvalidOperationException();\n                case \"tool_use\":\n                    return JsonSerializer.Deserialize<ToolUseContent>(text, options) ?? throw new InvalidOperationException();\n                case \"tool_result\":\n                    return JsonSerializer.Deserialize<ToolResultContent>(text, options) ?? throw new InvalidOperationException();\n            }\n        }\n\n        throw new JsonException(\"Unknown content type\");\n    }\n\n    public override void Write(Utf8JsonWriter writer, ContentBase value, JsonSerializerOptions options)\n    {\n        JsonSerializer.Serialize(writer, value, value.GetType(), options);\n    }\n}\n","sourceCodeStart":14,"sourceCodeEnd":40,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.Anthropic/Converters/ContentBaseConverter.cs#L14-L40","documentation":"AutoGen.Anthropic's ContentBaseConverter (a System.Text.Json polymorphic converter for ContentBase) throws JsonException('Unknown content type') when a content block's 'type' field is anything other than text, image, tool_use, or tool_result. This surfaces whenever the Anthropic API introduces a new block type the package doesn't know — most notably 'thinking' blocks from extended-thinking models and 'redacted_thinking'.","triggerScenarios":"Sending a conversation history back to a claude model with extended thinking enabled (assistant turns contain 'thinking' blocks); API returns a new content type in a response or in the input echo; using a newer Anthropic model than the AutoGen.Anthropic package supports.","commonSituations":"Upgrading the model (e.g. to a thinking-enabled claude) without upgrading AutoGen.Anthropic; replaying multi-turn histories that include tool_use/tool_result plus newer block types; beta features enabled via the 'anthropic-beta' header that add block types.","solutions":["Update AutoGen.Anthropic to a version that registers the new content types (thinking blocks are handled in newer releases).","As a workaround, filter unknown blocks from the history before resending (keep only text/tool_use/tool_result blocks).","Disable extended thinking / beta features that emit unsupported block types if you cannot upgrade yet.","If you control the DTOs, add a passthrough case for unknown types instead of throwing."],"exampleFix":"// before: history replay includes thinking blocks -> JsonException(\"Unknown content type\")\n\n// after: strip blocks the converter cannot handle before sending history back\nvar safeHistory = history\n    .Where(m => m.Content?.Type is \"text\" or \"tool_use\" or \"tool_result\")\n    .ToList();","handlingStrategy":"type-guard","validationCode":"var knownTypes = new HashSet<string> { \"text\", \"image\", \"tool_use\", \"tool_result\" };\nvar unknownBlocks = history.SelectMany(m => m.Content ?? []).Where(b => b?.Type is not null && !knownTypes.Contains(b.Type)).ToList();\nif (unknownBlocks.Count > 0) history = history.Select(m => m with { Content = m.Content?.Where(b => knownTypes.Contains(b?.Type ?? \"\")).ToList() }).ToList();","typeGuard":"static bool IsKnownContentBlock(string? type) => type is \"text\" or \"image\" or \"tool_use\" or \"tool_result\";","tryCatchPattern":"try { await agent.SendAsync(history); } catch (JsonException ex) when (ex.Message == \"Unknown content type\") { history = FilterToKnownBlocks(history); await agent.SendAsync(history); }","preventionTips":["Filter conversation history to known block types before replaying it to Anthropic (especially drop thinking/redacted_thinking blocks).","After switching to a new claude model, run one round-trip test with streaming and tool use to catch new block types early.","Track AutoGen.Anthropic release notes for content-type support before enabling Anthropic betas."],"tags":["anthropic","json-converter","content-block","thinking-blocks","api-drift","autogen"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}