AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Core: Content_blocks Raises TypeError On A V0 Multimodal Block That Carries An Id

Reading content_blocks on a legacy v0 multimodal block with an id raises TypeError due to duplicate id keyword argument in _convert_legacy_v0_content_block_to_v1.

highConfidence 95%LangChainAffected V1.6.3

Origin Analysis

In langchain_core/messages/block_translators/langchain_v0.py, _convert_legacy_v0_content_block_to_v1 builds extras from keys not in known_keys. For url, base64, and text source types, known_keys omits 'id', causing 'id' to remain in extras and be passed both explicitly and via **extras, leading to TypeError.
Using langchain-core 1.6.3, create a HumanMessage with content=[{"type": "image", "source_type": "url", "url": "https://example.com/image.png", "id": "block-1"}] and access message.content_blocks. This raises TypeError: got multiple values for keyword argument 'id'.

Fixing Code Block

Edge Case Audit

This fix is backward compatible and only affects previously failing code paths. No impact on concurrency or threading. Rollback: if unexpected issues arise, reverting to previous version will restore original behavior (including the bug). Ensure tests cover all seven branches to avoid regression.

Ecosystem Topology